當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。