當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Event::stopPropagation方法代碼示例

本文整理匯總了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();
         }
     }
 }
開發者ID:gallna,項目名稱:amqp-event,代碼行數:18,代碼來源:PostponeSubscriber.php

示例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();
         }
     }
 }
開發者ID:gallna,項目名稱:amqp-event,代碼行數:18,代碼來源:DeadLetterSubscriber.php

示例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();
     }
 }
開發者ID:event-band,項目名稱:band-symfony-adapter,代碼行數:13,代碼來源:AdapterEventListener.php

示例4: testStopPropagationAndIsPropagationStopped

 public function testStopPropagationAndIsPropagationStopped()
 {
     $this->event->stopPropagation();
     $this->assertTrue($this->event->isPropagationStopped());
 }
開發者ID:usefulthink,項目名稱:symfony,代碼行數:5,代碼來源:EventTest.php

示例5: postFoo

 public function postFoo(Event $e)
 {
     $this->postFooInvoked = true;
     $e->stopPropagation();
 }
開發者ID:Ceciceciceci,項目名稱:MySJSU-Class-Registration,代碼行數:5,代碼來源:AbstractEventDispatcherTest.php

示例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();
 }
開發者ID:claroline,項目名稱:distribution,代碼行數:15,代碼來源:PluginListener.php

示例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);
 }
開發者ID:adon988,項目名稱:phpsocket.io,代碼行數:21,代碼來源:EventDispatcherTest.php

示例8: cancel

 public function cancel($reason = null)
 {
     $this->event->stopPropagation();
     parent::cancel($reason);
 }
開發者ID:phpextra,項目名稱:event-manager,代碼行數:5,代碼來源:SilexEvent.php

示例9: stop

 /**
  * Stop the propagation of the event to other listeners.
  *
  * @return void
  */
 public function stop()
 {
     return parent::stopPropagation();
 }
開發者ID:defra91,項目名稱:levecchiecredenze.it,代碼行數:9,代碼來源:Event.php


注:本文中的Symfony\Component\EventDispatcher\Event::stopPropagation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。