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


PHP EventManagerInterface::trigger方法代碼示例

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


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

示例1: commit

 /**
  * {@inheritdoc}
  */
 public function commit()
 {
     while (!$this->messages->isEmpty()) {
         $message = $this->messages->dequeue();
         $this->eventManager->trigger($message->getName(), $message);
     }
 }
開發者ID:palya-framework,項目名稱:palya,代碼行數:10,代碼來源:ZendEventManagerBus.php

示例2: parse

 public function parse(MvcEvent $e)
 {
     $event = clone $e;
     $event->setName(__FUNCTION__);
     $event->setTarget($this);
     $this->events->trigger($event);
 }
開發者ID:i-MSCP,項目名稱:EnsembleKernel,代碼行數:7,代碼來源:ParsePages.php

示例3: execute

 /**
  * Executa a ação.
  *
  * @return mixin
  */
 public function execute()
 {
     $dataToUseAfterResponse = $this->_getDataToUseAfterResponse();
     if ($dataToUseAfterResponse === null) {
         return $this->error('Invalid session state. First you need to access the route "sta/oAuthConnect/ask".');
     }
     /** @var OAuthServiceInterface $oAuthService */
     $oAuthService = $this->getController()->getServiceLocator()->get('Sta\\OAuthConnect\\OAuthService\\' . $dataToUseAfterResponse['oAuthServiceName']);
     $requestedScopes = $dataToUseAfterResponse['scopes'];
     $authorizationResult = $oAuthService->isAuthorized($requestedScopes);
     if (!$authorizationResult instanceof AuthorizationResult) {
         return $this->error('This OAuth Service implementation method ' . get_class($oAuthService) . '::isAuthorized() must ' . 'return a instance of ' . \Sta\OAuthConnect\OAuthService\AuthorizationResult::class . '.');
     }
     $oAuthConnectEvent = new OAuthConnectEvent($authorizationResult, $oAuthService);
     $eventResponses = $this->events->trigger(OAuthConnectEvent::EVENT_OAUTH_RESPONSE, $oAuthConnectEvent, function ($r) {
         return $r instanceof Response;
     });
     $eventResult = $eventResponses->last();
     if ($eventResult instanceof Response) {
         return $eventResult;
     }
     $routeToRedirect = $dataToUseAfterResponse['continue'];
     if ($routeToRedirect) {
         return $this->getController()->redirect()->toRoute($routeToRedirect->getRoute(), $routeToRedirect->getParams(), $routeToRedirect->getOptions());
     } else {
         // foi uma autorizacao asincrona
         $viewModel = new ViewModel();
         $viewModel->setTerminal(true);
         if ($eventResult instanceof ApiProblem || class_exists('\\ZF\\ApiProblem\\ApiProblem') && $eventResult instanceof \ZF\ApiProblem\ApiProblem) {
             $viewModel->error = $eventResult->toArray();
         }
         return $viewModel;
     }
 }
開發者ID:stavarengo,項目名稱:o-auth-connect,代碼行數:39,代碼來源:AskForAuthorizationResponse.php

示例4: stopQuery

 public function stopQuery()
 {
     $this->profiles[$this->index]['stop'] = microtime(true);
     $this->profiles[$this->index]['elapse'] = $this->profiles[$this->index]['stop'] - $this->profiles[$this->index]['start'];
     if ($this->isLogging) {
         $this->profiles[$this->index]['logged'] = true;
         $this->events->trigger(self::EVENT_LOG_QUERY, $this, array('manager' => $this->name, 'query' => $this->profiles[$this->index]));
     }
     $this->index++;
 }
開發者ID:radnan,項目名稱:rdn-doctrine,代碼行數:10,代碼來源:Profiler.php

示例5: serialize

 public function serialize($subject, &$data = array(), SerializerInterface $serializer = null)
 {
     $event = new SerializeEvent($subject, $data, $this);
     $this->events->trigger(SerializeEvent::DESTRUCT, $event);
     $this->events->trigger(SerializeEvent::EXTRACT, $event);
     return $event->getData();
     //        if (is_array($subject)) {
     //            $result = array();
     //            foreach ($subject as $item) {
     //                $result[] = $this->serialize($item);
     //            }
     //            return $result;
     //        }
 }
開發者ID:nickvkaam,項目名稱:SpraySerializer,代碼行數:14,代碼來源:Serializer.php

示例6: addEventManagement

 /**
  * @param AccessInterceptorInterface $proxy
  * @param EventManager               $eventManager
  */
 public function addEventManagement(AccessInterceptorInterface $proxy)
 {
     $proxy->setMethodPrefixInterceptor('find', function ($proxy, $instance, $method, $params, &$returnEarly) {
         $results = $this->eventManager->trigger('preFind', $instance);
         if ($results->stopped()) {
             $returnEarly = true;
             return $results->last();
         }
     });
     $proxy->setMethodSuffixInterceptor('find', function ($proxy, $instance, $method, $params, $returnValue, &$returnEarly) {
         $this->eventManager->trigger('postFind', $instance, ['row' => $returnValue]);
     });
     $proxy->setMethodPrefixInterceptor('insert', function ($proxy, $instance, $method, $params, &$returnEarly) {
         $returnEarly = true;
         $this->eventManager->trigger('preInsert', $instance, ['values' => &$params['values']]);
         return $instance->insert($params['values']);
     });
     $proxy->setMethodPrefixInterceptor('update', function ($proxy, $instance, $method, $params, &$returnEarly) {
         $returnEarly = true;
         $this->eventManager->trigger('preUpdate', $instance, ['values' => &$params['values']]);
         return $instance->update($params['values'], $params['id']);
     });
     $proxy->setMethodSuffixInterceptor('update', function ($proxy, $instance, $method, $params, $returnValue, &$returnEarly) {
         $this->eventManager->trigger('onSave', $instance, ['row' => $returnValue]);
     });
     $proxy->setMethodSuffixInterceptor('delete', function ($proxy, $instance, $method, $params, $returnValue, &$returnEarly) {
         $this->eventManager->trigger('onDelete', $instance);
     });
     $proxy->setMethodSuffixInterceptor('getQueryFindAll', function ($proxy, $instance, $method, $params, $returnValue, &$returnEarly) {
         $this->eventManager->trigger('postFindAll', $instance, ['qb' => $returnValue, 'criteria' => $params['criteria']]);
     });
 }
開發者ID:comphppuebla,項目名稱:restful-extensions,代碼行數:36,代碼來源:TableProxyFactory.php

示例7: handle

 /**
  * @param CommandQueryInterface $commandInterface
  *
  * @return mixed
  * @throws \Exception
  */
 public final function handle(CommandQueryInterface $commandInterface)
 {
     $this->eventManager->trigger(self::commandEventPre($commandInterface::name()), $commandInterface);
     try {
         if (TRUE === $commandInterface instanceof CommandQueryInputFilterAwareInterface) {
             $commandInterface->validate();
         }
         $result = $this->process($commandInterface);
     } catch (\Exception $exception) {
         $this->eventManager->trigger(self::commandEventError($commandInterface::name(), $commandInterface, ['commandError' => $exception]));
         throw $exception;
     }
     $this->eventManager->trigger(self::commandEventPost($commandInterface::name(), $commandInterface));
     return $result;
 }
開發者ID:Code-Mine-Development,項目名稱:CommandQuery,代碼行數:21,代碼來源:AbstractCommandHandler.php

示例8: authenticate

 /**
  * Authenticates against the supplied adapter
  *
  * @? This is currently a BC break the original takes an auth adapter as a parameter. This still conforms to the interface though.
  *
  * @param array $authenticationContext
  * @return Result
  */
 public function authenticate($authenticationContext = [])
 {
     $event = new Authenticate();
     $event->setTarget($this);
     $event->setParams($authenticationContext);
     $event->setPreviousResult($this->getResult());
     $this->events->triggerEvent($event);
     $result = $event->getResult();
     if ($result->isValid()) {
         $event = new AuthenticationSucceeded();
     } else {
         $event = new AuthenticationFailed();
     }
     $event->setTarget($this);
     $event->setResult($result);
     $event->setParams($authenticationContext);
     $this->events->trigger($event);
     /**
      * ZF-7546 - prevent multiple successive calls from storing inconsistent results
      * Ensure storage has clean state
      */
     if ($this->hasIdentity()) {
         $this->clearIdentity();
     }
     $this->getStorage()->write($result);
     return $result;
 }
開發者ID:carnage,項目名稱:zend-authentication,代碼行數:35,代碼來源:AuthenticationService.php

示例9: postDelete

 public function postDelete(StatementInterface $statement, ResultInterface $result)
 {
     $this->event->setTarget($this->tableGateway);
     $this->event->setName(__FUNCTION__);
     $this->event->setParams(array('statement' => $statement, 'result' => $result));
     $this->eventManager->trigger($this->event);
 }
開發者ID:Rovak,項目名稱:zf2,代碼行數:7,代碼來源:EventFeature.php

示例10: authorizationPost

 /**
  * Trigger the authorization.post event
  *
  * @param MvcEvent $mvcEvent
  * @return null|Response
  */
 public function authorizationPost(MvcEvent $mvcEvent)
 {
     if (!$mvcEvent->getRequest() instanceof HttpRequest || $mvcEvent->getRequest()->isOptions()) {
         return;
     }
     $responses = $this->events->trigger(MvcAuthEvent::EVENT_AUTHORIZATION_POST, $this->mvcAuthEvent, function ($r) {
         return $r instanceof Response;
     });
     return $responses->last();
 }
開發者ID:qapa,項目名稱:zf-mvc-auth,代碼行數:16,代碼來源:MvcRouteListener.php

示例11: parsePage

 /**
  * Parse a single page into a navigation configuration
  *
  * @param  Page $page
  * @return array
  * @throws Exception\RuntimeException
  */
 public function parsePage(PageInterface $page)
 {
     $meta = $page->getMetaData();
     $navPage = Page::factory(array('type' => 'mvc', 'route' => (string) $page->getId(), 'label' => $meta->getNavigationTitle(), 'visible' => $page->isVisible()));
     $event = new Event();
     $event->setName(__FUNCTION__ . '.' . $page->getModule());
     $event->setTarget($this);
     $event->setParams(array('page' => $page, 'navigation' => $navPage));
     $this->events->trigger($event);
     return $navPage;
 }
開發者ID:i-MSCP,項目名稱:EnsembleKernel,代碼行數:18,代碼來源:Navigation.php

示例12: createInstantiationListener

 /**
  * Bulds a listener closure responsible for triggering events on service instantiation
  *
  * @param EventManagerInterface $eventManager
  *
  * @return \Closure
  */
 private function createInstantiationListener(EventManagerInterface $eventManager)
 {
     return function ($proxy, $instance, $method, $params, $returnValue) use($eventManager) {
         $eventName = 'create' === $method ? ServiceManagerEvent::EVENT_SERVICEMANAGER_CREATE : ServiceManagerEvent::EVENT_SERVICEMANAGER_GET;
         $serviceName = $params['name'];
         if (is_array($serviceName)) {
             list($canonicalName, $serviceName) = $serviceName;
         } else {
             $canonicalName = strtolower(strtr($serviceName, array('-' => '', '_' => '', ' ' => '', '\\' => '', '/' => '')));
         }
         $eventManager->trigger(new ServiceManagerEvent($eventName, $proxy, $returnValue, $serviceName, $canonicalName));
     };
 }
開發者ID:rhodium289,項目名稱:sandbox,代碼行數:20,代碼來源:ServiceManagerAccessInterceptorsFactory.php

示例13: trigger

 /**
  * @param $name
  * @param $entity
  */
 private function trigger($name, &$entity)
 {
     if (!empty($entity) && $entity instanceof Collection) {
         $this->eventManager->addIdentifiers(get_class($entity->getFirst()));
     } else {
         $this->eventManager->addIdentifiers(get_class($entity));
     }
     $event = new Event($name, $this, compact('entity'));
     $this->eventManager->trigger($event);
     if ($event->getParam('entity') && $event->getParam('entity') instanceof EntityInterface) {
         $entity = $event->getParam('entity');
     }
 }
開發者ID:t4web,項目名稱:base,代碼行數:17,代碼來源:DbRepository.php

示例14: handleRequest

 /**
  * (non-PHPdoc).
  *
  * @see \Zend\Json\Server\Server::_handle()
  */
 protected function handleRequest()
 {
     try {
         $request = $this->getRequest();
         if ($request->isParseError() === true) {
             throw new ParseErrorException();
         }
         $this->events->trigger('sendRequest.pre', $this, array('methode' => $request->getMethod()));
         if (($ret = $this->getParentHandle()) instanceof RPCERROR && ($ret = $ret->getData()) instanceof \Exception) {
             throw $ret;
         }
     } catch (AbstractException $e) {
         if (isset($this->options['log'])) {
             $this->container->get($this->options['log'])->err('(' . $e->getCode() . ') ' . $e->getMessage());
         }
         return $this->fault($e->getMessage(), $e->getCode());
     } catch (\Exception $e) {
         if (isset($this->options['log'])) {
             $this->container->get($this->options['log'])->err('(' . $e->getCode() . ') ' . $e->getMessage() . ' in ' . $e->getFile() . ' line ' . $e->getLine(), $e->getTrace());
         }
         return isset($this->options['environment']) && $this->options['environment'] === "dev" ? $this->fault('(' . $e->getCode() . ') ' . $e->getMessage() . ' in ' . $e->getFile() . ' line ' . $e->getLine(), $e->getCode(), $e->getTrace()) : $this->fault('Internal error', RPCERROR::ERROR_INTERNAL);
     }
 }
開發者ID:buse974,項目名稱:jrpc,代碼行數:28,代碼來源:Server.php

示例15: authorizationPost

 /**
  * Trigger the authorization.post event
  *
  * @param MvcEvent $event
  * @return null|Response
  */
 public function authorizationPost(MvcEvent $event)
 {
     if (!$event->getRequest() instanceof HttpRequest || $event->getRequest()->isOptions()) {
         return;
     }
     // Check if dealing with an unrestricted route
     if (!$this->isRestrictedRoute($event->getRouteMatch()->getMatchedRouteName())) {
         return;
     }
     $responses = $this->events->trigger(AccessControlEvent::EVENT_AUTHORIZATION_POST, $this->accessControlEvent, function ($r) {
         return $r instanceof Response;
     });
     return $responses->last();
 }
開發者ID:parrotcage,項目名稱:fovea,代碼行數:20,代碼來源:MvcDispatchListener.php


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