当前位置: 首页>>代码示例>>PHP>>正文


PHP EventDispatcher::dispatch方法代码示例

本文整理汇总了PHP中Symfony\Component\EventDispatcher\EventDispatcher::dispatch方法的典型用法代码示例。如果您正苦于以下问题:PHP EventDispatcher::dispatch方法的具体用法?PHP EventDispatcher::dispatch怎么用?PHP EventDispatcher::dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\EventDispatcher\EventDispatcher的用法示例。


在下文中一共展示了EventDispatcher::dispatch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: write

 /**
  * @param array $items
  */
 public function write(array $items)
 {
     //      file_put_contents('options.json', json_encode($items));
     foreach ($items as $item) {
         try {
             $this->webservice->sendAttributeOption($item);
         } catch (\Exception $e) {
             $event = new InvalidItemEvent(__CLASS__, $e->getMessage(), array(), ['code' => key($item)]);
             // Logging file
             $this->eventDispatcher->dispatch(EventInterface::INVALID_ITEM, $event);
             // Loggin Interface
             $this->stepExecution->addWarning(__CLASS__, $e->getMessage(), array(), ['code' => key($item)]);
             /** @var ClientErrorResponseException  $e */
             if ($e->getResponse()->getStatusCode() <= 404) {
                 $e = new \Exception($e->getResponse()->getReasonPhrase());
                 $this->stepExecution->addFailureException($e);
                 $exitStatus = new ExitStatus(ExitStatus::FAILED);
                 $this->stepExecution->setExitStatus($exitStatus);
             }
             // Handle next element.
         }
         $this->stepExecution->incrementWriteCount();
         $this->stepExecution->incrementSummaryInfo('write');
     }
 }
开发者ID:calin-marian,项目名称:DrupalCommerceConnectorBundle,代码行数:28,代码来源:AttributeOptionWriter.php

示例2: checkAndProxyEvent

 public function checkAndProxyEvent(CrawlerRequestEvent $event, $name)
 {
     $uri = $event->getRequest()->getUri();
     if ($this->matcher->matches($uri)) {
         $this->dispatcher->dispatch($name, $event);
     }
 }
开发者ID:LastCallMedia,项目名称:Crawler,代码行数:7,代码来源:MatchingProxy.php

示例3: execute

 /**
  * {@inheritdoc}
  */
 public function execute(EventDispatcher $dispatcher)
 {
     $this->ticksRemaining = $this->units;
     $dispatcher->dispatch(Events::STEP_BEFORE_EXECUTE, new StepEvent($this));
     call_user_func($this->executer, $this);
     $dispatcher->dispatch(Events::STEP_AFTER_EXECUTE, new StepEvent($this));
 }
开发者ID:skymeyer,项目名称:sugardev,代码行数:10,代码来源:Step.php

示例4: commit

 /**
  * {@inheritdoc}
  */
 public function commit()
 {
     while (!$this->messages->isEmpty()) {
         $message = $this->messages->dequeue();
         $this->eventDispatcher->dispatch($message->getName(), new GenericEvent($message));
     }
 }
开发者ID:palya-framework,项目名称:palya,代码行数:10,代码来源:SymfonyEventDispatcherBus.php

示例5: build

 /**
  * Create, configure and build datagrid
  *
  * @param DatagridConfiguration $config
  *
  * @return DatagridInterface
  */
 public function build(DatagridConfiguration $config)
 {
     $class = $config->offsetGetByPath(self::BASE_DATAGRID_CLASS_PATH, $this->baseDatagridClass);
     $name = $config->getName();
     /** @var Acceptor $acceptor */
     $acceptor = new $this->acceptorClass($config);
     /** @var DatagridInterface $datagrid */
     $datagrid = new $class($name, $acceptor);
     $event = new BuildBefore($datagrid, $config);
     $this->eventDispatcher->dispatch(BuildBefore::NAME, $event);
     // duplicate event dispatch with grid name
     $this->eventDispatcher->dispatch(BuildBefore::NAME . '.' . $name, $event);
     $this->buildDataSource($datagrid, $config);
     foreach ($this->extensions as $extension) {
         if ($extension->isApplicable($config)) {
             $acceptor->addExtension($extension);
         }
     }
     $acceptor->processConfiguration();
     $event = new BuildAfter($datagrid);
     $this->eventDispatcher->dispatch(BuildAfter::NAME, $event);
     // duplicate event dispatch with grid name
     $this->eventDispatcher->dispatch(BuildAfter::NAME . '.' . $name, $event);
     return $datagrid;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:32,代码来源:Builder.php

示例6: fire

 protected function fire($event, Event $eventType)
 {
     foreach ($this->scenario->getGroups() as $group) {
         $this->dispatcher->dispatch($event . '.' . $group, $eventType);
     }
     $this->dispatcher->dispatch($event, $eventType);
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:7,代码来源:Actor.php

示例7: dispatchEvent

 /**
  * Dispatch event.
  *
  * @param string $name
  * @param Event  $event
  */
 private function dispatchEvent($name, Event $event)
 {
     if (null === $this->eventDispatcher) {
         return;
     }
     $this->eventDispatcher->dispatch($name, $event);
 }
开发者ID:thekabal,项目名称:tki,代码行数:13,代码来源:FileFilterIterator.php

示例8: createPrimaryMenu

 /**
  * Navbar Menu
  * 
  * @param array $options
  * @return ItemInterface
  */
 public function createPrimaryMenu(array $options)
 {
     $menu = $this->factory->createItem('root');
     $this->eventDispatcher->dispatch(WebsiteEvents::PRIMARY_MENU_INIT, new PrimaryMenuEvent($menu, $this->factory));
     $this->reorderMenuItems($menu);
     return $menu;
 }
开发者ID:artscorestudio,项目名称:website-bundle,代码行数:13,代码来源:MenuBuilder.php

示例9: onCommitDone

 public function onCommitDone()
 {
     $this->eventDispatcher->dispatch('commitDone', new CommitDoneEvent());
     foreach ($this->onCommitDoneCallbacks as $callback) {
         call_user_func($callback);
     }
 }
开发者ID:miknatr,项目名称:grace,代码行数:7,代码来源:DispatchedModelObserver.php

示例10: request

 /**
  * @param string $method
  * @param string$uri
  * @param array $queryParams
  * @param array $requestParams
  * @param array $options
  * @param bool $secured
  *
  * @return array|stdClass
  * @throws GuzzleException
  * @throws Exception
  */
 public function request($method, $uri, array $queryParams, array $requestParams, array $options, $secured)
 {
     $this->eventDispatcher->dispatch(BeforeClientRequestEvent::NAME, new BeforeClientRequestEvent($method, $uri, $queryParams, $requestParams, $options, $secured));
     $originalRequest = ['method' => $method, 'uri' => $uri, 'queryParams' => $queryParams, 'requestParams' => $requestParams, 'option' => $options, 'secured' => $secured];
     //Check for on behalf of in order to inject it if needed
     $isOnBehalfOfUsedInParams = false;
     foreach ([&$queryParams, &$requestParams] as &$paramsArray) {
         if (array_key_exists('on_behalf_of', $paramsArray)) {
             //isset is not used because id skips null-s
             if (null !== $paramsArray['on_behalf_of']) {
                 $this->session->setOnBehalfOf($paramsArray['on_behalf_of']);
                 $isOnBehalfOfUsedInParams = true;
             } else {
                 $onBehalfOf = $this->session->getOnBehalfOf();
                 if (null !== $onBehalfOf) {
                     $paramsArray['on_behalf_of'] = $onBehalfOf;
                 }
             }
         }
     }
     try {
         //Wrap whole section if someone, for example, throws exceptions for PHP warnings etc.
         if ($secured) {
             //Perhaps check here if auth token set?
             $options['headers']['X-Auth-Token'] = $this->session->getAuthToken();
         }
         $queryParams = array_filter($queryParams);
         $requestParams = array_filter($requestParams);
         if (count($requestParams) > 0) {
             if (!isset($options['form_params'])) {
                 $options['form_params'] = [];
             }
             $options['form_params'] = array_merge($options['form_params'], $requestParams);
         }
         //Force no-exceptions in order to provide descriptive error messages
         $options['http_errors'] = false;
         $url = $this->applyApiBaseUrl($uri, $queryParams);
         $response = $this->client->request($method, $url, $options);
         switch ($response->getStatusCode()) {
             case 200:
                 $data = json_decode($response->getBody()->getContents());
                 return $data;
             default:
                 //Everything that's not 200 consider error and dispatch event
                 $event = new ClientHttpErrorEvent($response, $requestParams, $method, $url, $originalRequest);
                 $this->eventDispatcher->dispatch(ClientHttpErrorEvent::NAME, $event);
                 $interceptedResponse = $event->getInterceptedResponse();
                 if (null !== $interceptedResponse) {
                     return $interceptedResponse;
                 }
         }
     } finally {
         //If on-behalf-of was injected through params, clear it now
         if ($isOnBehalfOfUsedInParams) {
             $this->session->clearOnBehalfOf();
         }
     }
     throw new Exception($response->getBody()->getContents());
 }
开发者ID:CurrencyCloud,项目名称:currencycloud-php,代码行数:71,代码来源:Client.php

示例11: handleResponse

 public function handleResponse(ApiResponse $response)
 {
     if (null != $this->eventDispatcher) {
         $event = new ApiResponseEvent($response);
         $this->eventDispatcher->dispatch(ApiEvent::API_RESPONSE, $event);
     }
     return $response;
 }
开发者ID:spiasecki,项目名称:ubirimi,代码行数:8,代码来源:ApiClient.php

示例12: buildForm

 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $tags = $this->topicManager->getAvailableTags();
     $builder->add('mainPost', "post")->add('tags', 'entity', array("choices" => $tags, 'class' => 'SymbbCoreForumBundle:Topic\\Tag', 'required' => false, "multiple" => true))->add('locked', 'checkbox', array('required' => false, 'label' => 'close topic'))->add('id', 'hidden')->add('forum', 'entity', array('class' => 'SymbbCoreForumBundle:Forum', 'disabled' => true));
     // create Event to manipulate Post Form
     $event = new FormTopicEvent($builder, $this->translator, $this->topicManager, $this->userManager, $this->groupManager);
     $this->dispatcher->dispatch('symbb.core.forum.topic.form.create', $event);
 }
开发者ID:symbb,项目名称:symbb,代码行数:8,代码来源:TopicType.php

示例13: resolveCiActions

 public function resolveCiActions(Request $request)
 {
     $event = new CiActionResolveEvent($request);
     if ($this->config['detect_controllers'] !== false) {
         $this->event_dispatcher->dispatch('nercury.ci_action_resolve', $event);
     }
     return $event->getResolvedActions();
 }
开发者ID:rocktopus,项目名称:NercuryCodeIgniterBundle,代码行数:8,代码来源:CiHelperService.php

示例14: testChangePermissionsForCommittedSqon

 /**
  * Verifies that permissions are changed.
  */
 public function testChangePermissionsForCommittedSqon()
 {
     chmod($this->path, 0644);
     $this->dispatcher->addSubscriber(new ChmodSubscriber(0755));
     $this->dispatcher->dispatch(AfterCommitEvent::NAME, new AfterCommitEvent($this->sqon));
     clearstatcache(true, $this->path);
     self::assertEquals('755', substr(sprintf('%o', fileperms($this->path)), -3, 3), 'The file permissions were not set.');
 }
开发者ID:sqon,项目名称:sqon,代码行数:11,代码来源:ChmodSubscriberTest.php

示例15: setCacheForEntity

 /**
  * Set cache
  *
  * @param EntityLoadEvent $event
  *
  * @return void
  */
 public function setCacheForEntity(EntityLoadEvent $event)
 {
     $entity = $event->getEntity();
     if (!$entity->isLoaded()) {
         $this->cache->set($entity);
         $this->dispatcher->dispatch('cache.set', new CacheEvent($entity));
     }
 }
开发者ID:itkg,项目名称:core,代码行数:15,代码来源:CacheListener.php


注:本文中的Symfony\Component\EventDispatcher\EventDispatcher::dispatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。