Add simple behavior with Propel / Symfony

Add your behavior in a new file in :

lib/vendor/symfony/lib/plugins/sfPropelPlugin/lib/behavior/SfPropelBehaviorMyBehavior.php

Edit SfPropelBehaviorSymfony.php and add a loader for your new Behavior. Example :

public function modifyDatabase()
{
foreach ($this->getDatabase()->getTables() as $table)
{
$behaviors = $table->getBehaviors();

[…………]

// MyBehavior
if (!isset($behaviors[‘symfony_mybehavior’]))
{

$class = Propel::importClass($this->getBuildProperty(‘propel.behavior.symfony_mybehavior.class’));
$behavior = new $class();
$behavior->setName(‘symfony_mybehavior’);
$behavior->setParameters($parameters);
$table->addBehavior($behavior);

}

Edit config/propel.ini and add a new line with your new behavior

Rebuild your full models and enjoy !

Leave a Reply

Your email address will not be published. Required fields are marked *