本文整理汇总了PHP中sfPropel::importClass方法的典型用法代码示例。如果您正苦于以下问题:PHP sfPropel::importClass方法的具体用法?PHP sfPropel::importClass怎么用?PHP sfPropel::importClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfPropel
的用法示例。
在下文中一共展示了sfPropel::importClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modifyDatabase
/**
* 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);
}
}
}
示例2: modifyDatabase
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);
}
}
}
}