本文整理汇总了PHP中Zend\EventManager\Event::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::getName方法的具体用法?PHP Event::getName怎么用?PHP Event::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\EventManager\Event
的用法示例。
在下文中一共展示了Event::getName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
/**
* Determines if we're dealing with the required Resource
* before dispatching to actions
*
* @param Event $e
* @return mixed|void
*/
public function dispatch(Event $e)
{
switch ($e->getName()) {
case 'create.post':
case 'update.post':
case 'patch.post':
/**
* Redirect client to newly created resource
*/
$controller = $e->getTarget();
if ($controller instanceof ResourceController) {
$resource = $controller->getResource();
if ($resource instanceof Resource) {
$model = $e->getParam('resource');
if ($model instanceof ResourceJsonModel) {
$object = $model->getPayload();
if ($object instanceof BackendResourceInterface) {
$e->stopPropagation(true);
$response = $controller->redirect()->toRoute('api/default', array('resource' => $resource->getIdentifier(), 'id' => $object->getId()));
return $response;
//@TODO remove until fixed CORS redirect
}
}
}
}
break;
}
}
示例2: triggerStaticHandlers
/**
* Emit handlers matching the current identifier found in the static handler
*
* @param callback $callback
* @param Event $event
* @param ResponseCollection $responses
* @return ResponseCollection
*/
protected function triggerStaticHandlers($callback, Event $event, ResponseCollection $responses)
{
if (!($staticConnections = $this->getStaticConnections())) {
return $responses;
}
$identifiers = (array) $this->identifier;
foreach ($identifiers as $id) {
if (!($handlers = $staticConnections->getHandlers($id, $event->getName()))) {
continue;
}
foreach ($handlers as $handler) {
$responses->push(call_user_func($handler->getCallback(), $event));
if ($event->propagationIsStopped()) {
$responses->setStopped(true);
break;
}
if (call_user_func($callback, $responses->last())) {
$responses->setStopped(true);
break;
}
}
}
return $responses;
}
示例3: listen
/**
* @param Event $e
*/
public function listen(Event $e)
{
$this->caughtEvents[] = $e->getName();
array_unique($this->caughtEvents);
}