本文整理匯總了PHP中Cake\Event\Event::isStopped方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::isStopped方法的具體用法?PHP Event::isStopped怎麽用?PHP Event::isStopped使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cake\Event\Event
的用法示例。
在下文中一共展示了Event::isStopped方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testPropagation
/**
* Tests the event propagation stopping property
*
* @return void
* @triggers fake.event
*/
public function testPropagation()
{
$event = new Event('fake.event');
$this->assertFalse($event->isStopped());
$event->stopPropagation();
$this->assertTrue($event->isStopped());
}
示例2: dispatch
/**
* Dispatches a new event to all configured listeners
*
* @param string|\Cake\Event\Event $event the event key name or instance of Event
* @return \Cake\Event\Event
* @triggers $event
*/
public function dispatch($event)
{
if (is_string($event)) {
$event = new Event($event);
}
$listeners = $this->listeners($event->name());
if (empty($listeners)) {
return $event;
}
foreach ($listeners as $listener) {
if ($event->isStopped()) {
break;
}
$result = $this->_callListener($listener['callable'], $event);
if ($result === false) {
$event->stopPropagation();
}
if ($result !== null) {
$event->result = $result;
}
}
return $event;
}
示例3: buildValidator
/**
* Automatically add the translated validation rules if the event is not stopped
* and if the name of the validator is amongst the accepted ones.
*
* @source http://book.cakephp.org/3.0/en/core-libraries/validation.html#validating-data
*
* @param \Cake\Event\Event $event Fired when the validator object identified by $name is being built.
* @param \Cake\Validation\Validator $validator The validator object
* @param string $name The name of the validator oject
* @return void
*/
public function buildValidator(\Cake\Event\Event $event, \Cake\Validation\Validator $validator, $name)
{
$accepted = $this->config('accepted');
if ($event->isStopped() === false && ($accepted === null || in_array($name, (array) $accepted))) {
foreach ($this->getValidationRules() as $validationRule) {
call_user_func_array([$validator, 'add'], $validationRule);
}
}
}