当前位置: 首页>>代码示例>>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;未经允许,请勿转载。