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


PHP Event::setName方法代碼示例

本文整理匯總了PHP中Symfony\Component\EventDispatcher\Event::setName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::setName方法的具體用法?PHP Event::setName怎麽用?PHP Event::setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\EventDispatcher\Event的用法示例。


在下文中一共展示了Event::setName方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testAddSuccessFlashLegacy

 /**
  * @group legacy
  */
 public function testAddSuccessFlashLegacy()
 {
     if (!method_exists($this->event, 'setDispatcher')) {
         $this->markTestSkipped('Legacy test which requires Symfony <3.0.');
     }
     $this->event->setName(FOSUserEvents::CHANGE_PASSWORD_COMPLETED);
     $this->listener->addSuccessFlash($this->event);
 }
開發者ID:acorbel,項目名稱:FOSUserBundle,代碼行數:11,代碼來源:FlashListenerTest.php

示例2: dispatch

 /**
  * Dispatches an event to all registered listeners.
  *
  * @param string $eventName The name of the event to dispatch. The name of
  *                          the event is the name of the method that is
  *                          invoked on listeners.
  * @param Event  $event The event to pass to the event handlers/listeners.
  *                          If not supplied, an empty Event instance is created.
  *
  * @return Event
  *
  * @api
  */
 public function dispatch($eventName, Event $event = null)
 {
     if ($event == null) {
         $event = new Event();
     }
     $event->setName($eventName);
     $event->setDispatcher($this);
     $this->laravelDispatcher->fire($eventName, $event);
     $this->symfonyDispatcher->dispatch($eventName, $event);
     $event->setDispatcher($this);
     return $event;
 }
開發者ID:okaufmann,項目名稱:google-movies-client-laravel,代碼行數:25,代碼來源:EventDispatcherAdapter.php

示例3: dispatch

 public function dispatch($eventName, Event $event = null, $group = null)
 {
     if (!isset($this->events[$eventName])) {
         return 0;
     }
     if (!$event) {
         $event = new Event();
     }
     $event->setName($eventName);
     if ($group === null) {
         return $this->brocast($event);
     }
     if (!isset($this->groupEvents[$group][$eventName])) {
         return 0;
     }
     $listeners = [];
     foreach ($this->groupEvents[$group][$eventName] as $uniqueKey) {
         if (isset($this->events[$eventName]) && isset($this->events[$eventName][$uniqueKey])) {
             foreach ($this->events[$eventName][$uniqueKey] as $listenerArray) {
                 list($listener, $priority) = $listenerArray;
                 $listeners[$priority][] = $listener;
             }
         }
     }
     krsort($listeners);
     $processCount = 0;
     foreach ($listeners as $listener) {
         foreach ($listener as $callback) {
             if ($event && $event->isPropagationStopped()) {
                 return $processCount;
             }
             $callback($event);
             $processCount++;
         }
     }
     return $processCount;
 }
開發者ID:adon988,項目名稱:phpsocket.io,代碼行數:37,代碼來源:EventDispatcher.php

示例4: testSetName

 public function testSetName()
 {
     $this->event->setName('foo');
     $this->assertEquals('foo', $this->event->getName());
 }
開發者ID:usefulthink,項目名稱:symfony,代碼行數:5,代碼來源:EventTest.php

示例5: testLegacySetName

 public function testLegacySetName()
 {
     $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
     $this->event->setName('foo');
     $this->assertEquals('foo', $this->event->getName());
 }
開發者ID:EnmanuelCode,項目名稱:backend-laravel,代碼行數:6,代碼來源:EventTest.php

示例6: testHasListenersOnLazyLoad

 public function testHasListenersOnLazyLoad()
 {
     $event = new Event();
     $service = $this->getMock('Symfony\\Component\\EventDispatcher\\Tests\\Service');
     $container = new Container();
     $container->set('service.listener', $service);
     $dispatcher = new ContainerAwareEventDispatcher($container);
     $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
     $event->setDispatcher($dispatcher);
     $event->setName('onEvent');
     $service->expects($this->once())->method('onEvent')->with($event);
     $this->assertTrue($dispatcher->hasListeners());
     if ($dispatcher->hasListeners('onEvent')) {
         $dispatcher->dispatch('onEvent');
     }
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:16,代碼來源:ContainerAwareEventDispatcherTest.php

示例7: dispatch

 /**
  * {@inheritdoc}
  */
 public function dispatch($event_name, Event $event = NULL)
 {
     if ($event === NULL) {
         $event = new Event();
     }
     $event->setDispatcher($this);
     $event->setName($event_name);
     if (isset($this->listeners[$event_name])) {
         // Sort listeners if necessary.
         if (isset($this->unsorted[$event_name])) {
             krsort($this->listeners[$event_name]);
             unset($this->unsorted[$event_name]);
         }
         // Invoke listeners and resolve callables if necessary.
         foreach ($this->listeners[$event_name] as $priority => &$definitions) {
             foreach ($definitions as $key => &$definition) {
                 if (!isset($definition['callable'])) {
                     $definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]];
                 }
                 $definition['callable']($event, $event_name, $this);
                 if ($event->isPropagationStopped()) {
                     return $event;
                 }
             }
         }
     }
     return $event;
 }
開發者ID:akapivo,項目名稱:www.dmi.be,代碼行數:31,代碼來源:ContainerAwareEventDispatcher.php

示例8: createEvent

 /**
  * {@inheritDoc}
  */
 protected function createEvent(InputInterface $input)
 {
     $event = new Event();
     $event->setName($input->getArgument('name'));
     return $event;
 }
開發者ID:event-band,項目名稱:band-symfony-adapter,代碼行數:9,代碼來源:PublishCommand.php

示例9: testAddSuccessFlash

 public function testAddSuccessFlash()
 {
     $this->event->setName(LuupabInvoiceEvents::INVOICE_CREATE_COMPLETED);
     $this->listener->addSuccessFlash($this->event);
 }
開發者ID:Luupab,項目名稱:InvoiceBundle,代碼行數:5,代碼來源:FlashListenerTest.php

示例10: testAddSuccessFlashLegacy

 public function testAddSuccessFlashLegacy()
 {
     $this->event->setName(FOSUserEvents::CHANGE_PASSWORD_COMPLETED);
     $this->listener->addSuccessFlash($this->event);
 }
開發者ID:Dren-x,項目名稱:mobitnew,代碼行數:5,代碼來源:FlashListenerTest.php

示例11: testHasListenersOnLazyLoad

 public function testHasListenersOnLazyLoad()
 {
     $event = new Event();
     $service = $this->getMock('SilexCMF\\Core\\Tests\\Service');
     $container = new Application();
     $container['service.listener'] = Application::share(function () use($service) {
         return $service;
     });
     $dispatcher = new PimpleAwareEventDispatcher();
     $dispatcher->setContainer($container);
     $dispatcher->addListenerService('onEvent', ['service.listener', 'onEvent']);
     $event->setDispatcher($dispatcher);
     $event->setName('onEvent');
     $service->expects(static::once())->method('onEvent')->with($event);
     static::assertTrue($dispatcher->hasListeners());
     if ($dispatcher->hasListeners('onEvent')) {
         $dispatcher->dispatch('onEvent');
     }
 }
開發者ID:sunnyct,項目名稱:silexcmf-core,代碼行數:19,代碼來源:PimpleAwareEventDispatcherTest.php


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