本文整理汇总了PHP中Propel\Generator\Model\Table::hasBehavior方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::hasBehavior方法的具体用法?PHP Table::hasBehavior怎么用?PHP Table::hasBehavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Propel\Generator\Model\Table
的用法示例。
在下文中一共展示了Table::hasBehavior方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hasCompositeNumberRangeBehavior
/**
* @param Table $table
*
* @return bool
*/
protected function hasCompositeNumberRangeBehavior(Table $table)
{
if ($table->hasBehavior(self::BEHAVIOR_NAME)) {
if ($table->hasBehavior('concrete_inheritance')) {
// we're a child in a concrete inheritance
$parentTableName = $table->getBehavior('concrete_inheritance')->getParameter('extends');
$parentTable = $table->getDatabase()->getTable($parentTableName);
if ($parentTable->hasBehavior(self::BEHAVIOR_NAME)) {
//we're a child of a concrete inheritance structure, so we're going to skip this
//round here because this behavior has also been attached by the parent table.
return false;
}
}
return true;
}
return false;
}
示例2: testHasBehaviors
public function testHasBehaviors()
{
$behavior1 = $this->getBehaviorMock('Foo');
$behavior2 = $this->getBehaviorMock('Bar');
$behavior3 = $this->getBehaviorMock('Baz');
$table = new Table();
$table->addBehavior($behavior1);
$table->addBehavior($behavior2);
$table->addBehavior($behavior3);
$this->assertCount(3, $table->getBehaviors());
$this->assertTrue($table->hasBehavior('Foo'));
$this->assertTrue($table->hasBehavior('Bar'));
$this->assertTrue($table->hasBehavior('Baz'));
$this->assertFalse($table->hasBehavior('Bab'));
$this->assertSame($behavior1, $table->getBehavior('Foo'));
$this->assertSame($behavior2, $table->getBehavior('Bar'));
$this->assertSame($behavior3, $table->getBehavior('Baz'));
}