本文整理匯總了PHP中Symfony\Component\EventDispatcher\Event::stopPropagation方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::stopPropagation方法的具體用法?PHP Event::stopPropagation怎麽用?PHP Event::stopPropagation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\EventDispatcher\Event
的用法示例。
在下文中一共展示了Event::stopPropagation方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onException
/**
* On dispatch event listener - called on any event
*
* @param Event $event
* @param string $eventName
* @return void
*/
public function onException(Event $event)
{
if ($event instanceof Amqp\ErrorEvent) {
$event->getEvent()->addHeader("x-exception", ["message" => $event->getException()->getMessage(), "code" => $event->getException()->getCode(), "class" => get_class($event->getException())]);
$this->postpone($event->getEvent());
$event->getEvent()->ack();
if ($this->stopPropagation) {
$event->stopPropagation();
}
}
}
示例2: onException
/**
* On dispatch event listener - called on any event
*
* @param Event $event
* @param string $eventName
* @return void
*/
public function onException(Event $event, $eventName)
{
if ($event instanceof Amqp\ErrorEvent) {
$event->getEvent()->addHeader("x-exception", ["message" => $event->getException()->getMessage(), "code" => $event->getException()->getCode(), "class" => get_class($event->getException())]);
$this->deadLetter($event->getEvent(), $event->getException());
$event->getEvent()->reject(null);
if ($this->stopPropagation) {
$event->stopPropagation();
}
}
}
示例3: __invoke
public function __invoke(SymfonyEvent $symfonyEvent)
{
if ($symfonyEvent instanceof Event) {
$event = $symfonyEvent;
} elseif ($symfonyEvent instanceof SymfonyEventWrapper) {
$event = $symfonyEvent->getWrappedEvent();
} else {
$event = new EventWrapper($symfonyEvent);
}
if (!$this->subscription->dispatch($event, $this->dispatcher)) {
$symfonyEvent->stopPropagation();
}
}
示例4: testStopPropagationAndIsPropagationStopped
public function testStopPropagationAndIsPropagationStopped()
{
$this->event->stopPropagation();
$this->assertTrue($this->event->isPropagationStopped());
}
示例5: postFoo
public function postFoo(Event $e)
{
$this->postFooInvoked = true;
$e->stopPropagation();
}
示例6: forward
private function forward($controller, Event $event)
{
$attributes = ['_controller' => $controller];
if ($event instanceof CustomActionResourceEvent) {
$attributes['id'] = $event->getResource()->getId();
}
$subRequest = $this->request->duplicate([], null, $attributes);
$response = $this->kernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
if ($event instanceof DisplayToolEvent || $event instanceof DisplayWidgetEvent) {
$event->setContent($response->getContent());
} else {
$event->setResponse($response);
}
$event->stopPropagation();
}
示例7: test_dispatch_with_stop_propagation
public function test_dispatch_with_stop_propagation()
{
myEventDispatch::reset();
$dispatcher = myEventDispatch::getDispatcher();
$event = new Event();
$event->triggeredEvent = [];
$uniqueId1 = md5(rand() . microtime());
$dispatcher->addListener('testevent', function (Event $event) {
$event->triggeredEvent[] = 1;
$event->stopPropagation();
}, $uniqueId1);
$dispatcher->addListener('testevent', function (Event $event) {
$event->triggeredEvent[] = 2;
}, $uniqueId1);
$dispatcher->dispatch('testevent', $event, $uniqueId1);
$this->assertEquals(array(1), $event->triggeredEvent);
$event = new Event();
$event->triggeredEvent = [];
$dispatcher->dispatch('testevent', $event);
$this->assertEquals(array(1), $event->triggeredEvent);
}
示例8: cancel
public function cancel($reason = null)
{
$this->event->stopPropagation();
parent::cancel($reason);
}
示例9: stop
/**
* Stop the propagation of the event to other listeners.
*
* @return void
*/
public function stop()
{
return parent::stopPropagation();
}