/** * Looks for tables marked as I18N and adds behaviors. */ public function modifyDatabase() { $translationBehavior = sfPropel::importClass($this->getBuildProperty('propel.behavior.symfony_i18n_translation.class')); foreach ($this->getDatabase()->getTables() as $table) { $behaviors = $table->getBehaviors(); if (!isset($behaviors['symfony_i18n']) && 'true' == $table->getAttribute('isI18N')) { $i18nTable = $this->getDatabase()->getTable($table->getAttribute('i18nTable')); // add the current behavior to the translatable model $behavior = clone $this; $behavior->setParameters(array('i18n_table' => $i18nTable->getName())); $table->addBehavior($behavior); // add the translation behavior to the translation model $behavior = new $translationBehavior(); $behavior->setName('symfony_i18n_translation'); $behavior->setParameters(array('culture_column' => $this->getCultureColumn($i18nTable)->getName())); $i18nTable->addBehavior($behavior); } } }
public function modifyDatabase() { foreach ($this->getDatabase()->getTables() as $table) { $behaviors = $table->getBehaviors(); if (!isset($behaviors['symfony'])) { $behavior = clone $this; $table->addBehavior($behavior); } // symfony behaviors if (!isset($behaviors['symfony_behaviors']) && $this->getBuildProperty('propel.builder.addBehaviors')) { $class = sfPropel::importClass($this->getBuildProperty('propel.behavior.symfony_behaviors.class')); $behavior = new $class(); $behavior->setName('symfony_behaviors'); $table->addBehavior($behavior); } // timestampable if (!isset($behaviors['symfony_timestampable'])) { $parameters = array(); foreach ($table->getColumns() as $column) { if (!isset($parameters['create_column']) && in_array($column->getName(), array('created_at', 'created_on'))) { $parameters['create_column'] = $column->getName(); } if (!isset($parameters['update_column']) && in_array($column->getName(), array('updated_at', 'updated_on'))) { $parameters['update_column'] = $column->getName(); } } if ($parameters) { $class = sfPropel::importClass($this->getBuildProperty('propel.behavior.symfony_timestampable.class')); $behavior = new $class(); $behavior->setName('symfony_timestampable'); $behavior->setParameters($parameters); $table->addBehavior($behavior); } } } }