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