本文整理汇总了PHP中BehaviorCollection::hasMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP BehaviorCollection::hasMethod方法的具体用法?PHP BehaviorCollection::hasMethod怎么用?PHP BehaviorCollection::hasMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BehaviorCollection
的用法示例。
在下文中一共展示了BehaviorCollection::hasMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHasMethodAsCallback
/**
* test hasMethod returning a 'callback'
*
* @return void
*/
public function testHasMethodAsCallback()
{
new Sample();
$Collection = new BehaviorCollection();
$Collection->init('Sample', array('Test', 'Test2'));
$result = $Collection->hasMethod('testMethod', true);
$expected = array('Test', 'testMethod');
$this->assertEquals($expected, $result);
$result = $Collection->hasMethod('resolveMethod', true);
$expected = array('Test2', 'resolveMethod');
$this->assertEquals($expected, $result);
$result = $Collection->hasMethod('mappingRobotOnTheRoof', true);
$expected = array('Test2', 'mapped', 'mappingRobotOnTheRoof');
$this->assertEquals($expected, $result);
}
示例2: hasMethod
/**
* Check that a method is callable on a model. This will check both the model's own methods, its
* inherited methods and methods that could be callable through behaviors.
*
* @param string $method The method to be called.
* @return boolean True on method being callable.
*/
public function hasMethod($method)
{
if (method_exists($this, $method)) {
return true;
}
if ($this->Behaviors->hasMethod($method)) {
return true;
}
return false;
}
示例3: hasMethod
/**
* Check that a method is callable on a model. This will check both the model's own methods, its
* inherited methods and methods that could be callable through behaviors.
*
* @param string $method The method to be called.
*
* @return bool True on method being callable.
*/
public function hasMethod($method)
{
if (method_exists($this, $method)) {
return TRUE;
}
return $this->Behaviors->hasMethod($method);
}