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


PHP Event::getName方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:parrotcage,项目名称:aves,代码行数:35,代码来源:ResourceListenerAggregate.php

示例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;
 }
开发者ID:rmarshall-quibids,项目名称:zf2,代码行数:32,代码来源:EventManager.php

示例3: listen

 /**
  * @param Event $e
  */
 public function listen(Event $e)
 {
     $this->caughtEvents[] = $e->getName();
     array_unique($this->caughtEvents);
 }
开发者ID:API-Skeletons,项目名称:zf-apigility-doctrine,代码行数:8,代码来源:EventCatcher.php


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