本文整理匯總了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);
}