本文整理匯總了PHP中Observer::bound方法的典型用法代碼示例。如果您正苦於以下問題:PHP Observer::bound方法的具體用法?PHP Observer::bound怎麽用?PHP Observer::bound使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Observer
的用法示例。
在下文中一共展示了Observer::bound方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __call
/**
* Catch all calls, fire events and remap to real instance
*
* @access public
* @param string $method
* @param array $args
* @return mixed
*/
public function __call($method, array $args = array())
{
$event = $this->observer->createEvent()->setMethod($method)->setParams($args)->setInstance($this)->setType('before');
$before = $this->observer->trigger()->getResult();
if ($event->isPropagationStopped()) {
return $before;
}
/** @var \Closure $closure */
if ($closure = $this->observer->bound($method)) {
$callback = $closure->bindTo($this, $this);
$result = Executor::callClosure($callback, $event->getParams());
} else {
$result = Executor::call($this(true), $method, $event->getParams());
}
$event->setType('after')->setResult($result);
return $this->observer->trigger()->getResult();
}