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


PHP EventDispatcherInterface::addListener方法代碼示例

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


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

示例1: notify

 public function notify(OrderCreatedEvent $event)
 {
     $captureToken = $this->tokenFactory->createToken($event->getOrder(), $event->getGatewayName());
     $this->eventDispatcher->addListener(KernelEvents::RESPONSE, function (FilterResponseEvent $event) use($captureToken) {
         $event->setResponse(new RedirectResponse($captureToken->getTargetUrl()));
     }, -1000);
 }
開發者ID:igaponov,項目名稱:shop,代碼行數:7,代碼來源:CaptureOrderSubscriber.php

示例2: addListener

 /**
  * {@inheritDoc}
  */
 public function addListener($eventName, $listener, $priority = 0)
 {
     if (!$this->primaryEventDispatcher) {
         throw new \RuntimeException('Undefined primary event dispatcher.');
     }
     $this->primaryEventDispatcher->addListener($eventName, $listener, $priority);
 }
開發者ID:Gtvar,項目名稱:FivePercent-ApiBundle,代碼行數:10,代碼來源:ChainEventDispatcher.php

示例3: execute

 /**
  * Executes controller.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return null|integer
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     if (!$input->getOption('stop-on-failure')) {
         return null;
     }
     $this->eventDispatcher->addListener(ScenarioTested::AFTER, array($this, 'exitOnFailure'), -100);
     $this->eventDispatcher->addListener(ExampleTested::AFTER, array($this, 'exitOnFailure'), -100);
 }
開發者ID:OverByThere,項目名稱:Behat,代碼行數:16,代碼來源:StopOnFailureController.php

示例4: registerListeners

 public function registerListeners(EventDispatcherInterface $dispatcher)
 {
     // Pre-render filters
     $dispatcher->addListener(Events::preRender($this), array($this, 'preFilterLayout'));
     $dispatcher->addListener(Events::preRender($this), array($this, 'preFilterRelativePosition'));
     // Post-render filters
     $dispatcher->addListener(Events::postRender($this), array($this, 'postFilterLayout'));
 }
開發者ID:manialib,項目名稱:manialink,代碼行數:8,代碼來源:Base.php

示例5: __construct

 /**
  * @param EventDispatcherInterface $dispatcher
  * @param OutputInterface          $output
  */
 public function __construct(EventDispatcherInterface $dispatcher, OutputInterface $output)
 {
     $this->output = $output;
     $dispatcher->addListener('elasticsearch.has_started_handling', [$this, 'onStartedHandling']);
     $dispatcher->addListener('elasticsearch.has_started_providing', [$this, 'onStartedProviding']);
     $dispatcher->addListener('elasticsearch.has_provided_document', [$this, 'onProvidedDocument']);
     $dispatcher->addListener('elasticsearch.has_finished_providing', [$this, 'onFinishedProviding']);
 }
開發者ID:gbprod,項目名稱:elasticsearch-dataprovider-bundle,代碼行數:12,代碼來源:ProvidingProgressBar.php

示例6: __construct

 /**
  * @param Router $router
  * @param Request $request
  * @param ActionFactoryInterface $action_factory
  * @param PresenterInterface $presenter
  * @param EventDispatcherInterface $event_dispatcher
  * @param EventHandlerInterface $exception_handler
  */
 public function __construct(Router $router, Request $request, ActionFactoryInterface $action_factory, PresenterInterface $presenter, EventDispatcherInterface $event_dispatcher, EventHandlerInterface $exception_handler)
 {
     $this->router = $router;
     $this->request = $request;
     $this->action_factory = $action_factory;
     $this->presenter = $presenter;
     $this->events = $event_dispatcher;
     $this->events->addListener(DispatchEvents::DISPATCH_ERROR, $exception_handler, DispatchEvents::LATE_EVENT);
 }
開發者ID:dlundgren,項目名稱:atc,代碼行數:17,代碼來源:Dispatch.php

示例7: __invoke

 public function __invoke($name, $value, $options)
 {
     $placeholder = '<!-- ' . uniqid('section.') . ' -->';
     $this->events->addListener(KernelEvents::RESPONSE, function (FilterResponseEvent $event) use($value, $placeholder) {
         $response = $event->getResponse();
         $response->setContent(str_replace($placeholder, $this->render($value), $response->getContent()));
     }, 10);
     return $placeholder;
 }
開發者ID:jacobjjc,項目名稱:PageKit-framework,代碼行數:9,代碼來源:DelayedRenderer.php

示例8: prepareForInitCollections

 protected function prepareForInitCollections()
 {
     $this->user->expects($this->any())->method('getUID')->will($this->returnValue('alice'));
     $this->userSession->expects($this->once())->method('getUser')->will($this->returnValue($this->user));
     $this->dispatcher->addListener(CommentsEntityEvent::EVENT_ENTITY, function (CommentsEntityEvent $event) {
         $event->addEntityCollection('files', function () {
             return true;
         });
     });
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:10,代碼來源:RootCollectionTest.php

示例9: execute

 /**
  * {@inheritdoc}
  */
 public function execute($object = NULL)
 {
     $url = $this->urlGenerator->generateFromPath($this->configuration['url'], array('absolute' => TRUE));
     $response = new RedirectResponse($url);
     $listener = function ($event) use($response) {
         $event->setResponse($response);
     };
     // Add the listener to the event dispatcher.
     $this->dispatcher->addListener(KernelEvents::RESPONSE, $listener);
 }
開發者ID:davidsoloman,項目名稱:drupalconsole.com,代碼行數:13,代碼來源:GotoAction.php

示例10: registerListeners

 protected function registerListeners(EventDispatcherInterface $dispatcher)
 {
     // $dispatcher->addListener takes two parameters: an event name, and a callable
     // Default events names can be found in Manialib\XML\Rendering\Events
     // There are some "global" events
     $dispatcher->addListener(Events::PRE_RENDER, array($this, 'preGlobalRender'));
     // But also some events related to the current instance.
     // Manialib\XML\Rendering\Events provides shortcuts to generate instance-related event names
     $dispatcher->addListener(Events::preRender($this), array($this, 'preThisRender'));
     // Full documetation of Event Dispatcher at
     // http://symfony.com/doc/current/components/event_dispatcher/index.html
 }
開發者ID:manialib,項目名稱:xml,代碼行數:12,代碼來源:events.php

示例11: add

 /**
  * @param StateMachineInterface|Callback $smOrCallback
  * @param string                         $event
  * @param callable                       $callable
  * @param array                          $specs
  *
  * @return CallbackHandler
  */
 protected function add($smOrCallback, $event, $callable = null, array $specs = array())
 {
     if ($smOrCallback instanceof Callback) {
         $this->dispatcher->addListener($event, $smOrCallback);
         return $this;
     }
     trigger_error('Use of CallbackHandler::add without a Callback instance is deprecated and will be removed in 2.0', E_USER_DEPRECATED);
     $specs = $this->specResolver->resolve($specs);
     $callback = CallbackBuilder::create($smOrCallback, $specs['from'], $specs['to'], $specs['on'], $callable)->getCallback();
     $this->dispatcher->addListener($event, $callback);
     return $this;
 }
開發者ID:Rioji,項目名稱:Finite,代碼行數:20,代碼來源:CallbackHandler.php

示例12: setupProgressListeners

 /**
  * @param EventDispatcherInterface $dispatcher
  * @param ProgressHelper           $progress
  * @param OutputInterface          $output
  */
 protected function setupProgressListeners(EventDispatcherInterface $dispatcher, ProgressHelper $progress, OutputInterface $output)
 {
     $dispatcher->addListener(IoEvents::PRE_EXPORT_FEED, function (ExportFeedEvent $event) use($progress, $output) {
         $output->writeln(sprintf('Exporting feed for <info>%s</info> to <info>%s</info>', $event->getType()->getName(), $event->getFile()));
         $progress->start($output, $event->getTotal());
     });
     $dispatcher->addListener(IoEvents::POST_EXPORT_ITEM, function () use($progress) {
         $progress->advance(1);
     });
     $dispatcher->addListener(IoEvents::POST_EXPORT_FEED, function () use($progress) {
         $progress->finish();
     });
 }
開發者ID:mvanduijker,項目名稱:FMIoBundle,代碼行數:18,代碼來源:ExportCreateCommand.php

示例13: attachEvents

 /**
  * @inheritDoc
  */
 protected function attachEvents(OutputInterface $output, EventDispatcherInterface $dispatcher)
 {
     $this->output = $output;
     if ($output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) {
         $dispatcher->addListener(EventInterface::COLLECTION_BEFORE, [$this, 'onCollectionBefore']);
         $dispatcher->addListener(EventInterface::COLLECTION_AFTER, [$this, 'onCollectionAfter']);
         $dispatcher->addListener(EventInterface::MIGRATION_BEFORE, [$this, 'onMigrationBefore']);
         $dispatcher->addListener(EventInterface::MIGRATION_AFTER, [$this, 'onMigrationAfter']);
     }
     if ($this->saveChanges) {
         $dispatcher->addListener(EventInterface::MIGRATION_AFTER, [$this, 'saveVersionListener']);
     }
 }
開發者ID:baleen,項目名稱:cli,代碼行數:16,代碼來源:MigrateHandler.php

示例14: createGrid

 /**
  * @ActivityListQueryDesigner $queryDesigner
  *
  * @return DatagridInterface
  */
 public function createGrid(ActivityListQueryDesigner $source)
 {
     $this->datagridConfigurationBuilder->setGridName('related-activity');
     $this->datagridConfigurationBuilder->setSource($source);
     $config = $this->datagridConfigurationBuilder->getConfiguration();
     $stopPropagationListener = function (Event $e) {
         $e->stopPropagation();
     };
     $this->eventDispatcher->addListener(BuildBefore::NAME, $stopPropagationListener, 255);
     $grid = $this->gridBuilderLink->getService()->build($config, new ParameterBag());
     $this->eventDispatcher->removeListener(BuildBefore::NAME, $stopPropagationListener);
     return $grid;
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:18,代碼來源:DatagridHelper.php

示例15: subscribe

 /**
  * {@inheritdoc}
  */
 protected function subscribe(EventDispatcherInterface $dispatcher)
 {
     // Install the YAML configuration file.
     $this->getConfig();
     /** @var Application $app */
     $app = $this->getContainer();
     // Storage events test callback class
     $storageEventTests = new StorageEventTests($app['storage']);
     // Storage event listeners
     $dispatcher->addListener(StorageEvents::PRE_SAVE, [$storageEventTests, 'eventPreSave']);
     $dispatcher->addListener(StorageEvents::POST_SAVE, [$storageEventTests, 'eventPostSave']);
     $dispatcher->addListener(StorageEvents::PRE_DELETE, [$storageEventTests, 'eventPreDelete']);
     $dispatcher->addListener(StorageEvents::POST_DELETE, [$storageEventTests, 'eventPreDelete']);
 }
開發者ID:robbert-vdh,項目名稱:bolt,代碼行數:17,代碼來源:TesterEventsExtension.php


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