本文整理匯總了PHP中Zend\EventManager\EventManagerInterface::triggerEvent方法的典型用法代碼示例。如果您正苦於以下問題:PHP EventManagerInterface::triggerEvent方法的具體用法?PHP EventManagerInterface::triggerEvent怎麽用?PHP EventManagerInterface::triggerEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\EventManager\EventManagerInterface
的用法示例。
在下文中一共展示了EventManagerInterface::triggerEvent方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
}
示例2: handleException
/**
* Handle an exception/throwable.
*
* @param Throwable|Exception $exception
* @param MvcEvent $event
* @param EventManagerInterface $events
* @return self
*/
private function handleException($exception, MvcEvent $event, EventManagerInterface $events)
{
$event->setName(MvcEvent::EVENT_DISPATCH_ERROR);
$event->setError(self::ERROR_EXCEPTION);
$event->setParam('exception', $exception);
$result = $events->triggerEvent($event);
$response = $result->last();
if ($response instanceof ResponseInterface) {
$event->setName(MvcEvent::EVENT_FINISH);
$event->setTarget($this);
$event->setResponse($response);
$this->response = $response;
$events->triggerEvent($event);
return $this;
}
return $this->completeRequest($event);
}
示例3: postDelete
/**
* Trigger the "postDelete" event
*
* Triggers the "postDelete" event mapping the following parameters:
* - $statement as "statement"
* - $result as "result"
*
* @param StatementInterface $statement
* @param ResultInterface $result
* @return void
*/
public function postDelete(StatementInterface $statement, ResultInterface $result)
{
$this->event->setName(static::EVENT_POST_DELETE);
$this->event->setParams(['statement' => $statement, 'result' => $result]);
$this->eventManager->triggerEvent($this->event);
}