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


PHP Event::getRequestType方法代码示例

本文整理汇总了PHP中Symfony\Component\EventDispatcher\Event::getRequestType方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::getRequestType方法的具体用法?PHP Event::getRequestType怎么用?PHP Event::getRequestType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\EventDispatcher\Event的用法示例。


在下文中一共展示了Event::getRequestType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onCoreResponse

 /**
  * filter the `core.response` event to decorated the action
  *
  * @param \Symfony\Component\EventDispatcher\Event $event
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function onCoreResponse(Event $event)
 {
     $response = $event->getResponse();
     $requestType = $event->getRequestType();
     $request = $event->getRequest();
     if ($this->isDecorable($request, $requestType, $response)) {
         $page = $this->defineCurrentPage($request);
         // only decorate hybrid page and page with decorate = true
         if ($page && $page->isHybrid() && $page->getDecorate()) {
             $parameters = array('content' => $response->getContent());
             $response = $this->renderPage($page, $parameters, $response);
         }
     }
     return $response;
 }
开发者ID:norfil,项目名称:SonataPageBundle,代码行数:21,代码来源:BaseCmsPageManager.php

示例2: postDispatch

 private function postDispatch($eventName, Event $event)
 {
     switch ($eventName) {
         case KernelEvents::CONTROLLER:
             $this->stopwatch->start('controller', 'section');
             break;
         case KernelEvents::RESPONSE:
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             $this->stopwatch->stopSection($token);
             if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
                 // The profiles can only be updated once they have been created
                 // that is after the 'kernel.response' event of the main request
                 $this->updateProfiles($token, true);
             }
             break;
         case KernelEvents::TERMINATE:
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             $this->stopwatch->stopSection($token);
             // The children profiles have been updated by the previous 'kernel.response'
             // event. Only the root profile need to be updated with the 'kernel.terminate'
             // timing informations.
             $this->updateProfiles($token, false);
             break;
     }
     foreach ($this->wrappedListeners[$this->id] as $wrapped) {
         $this->dispatcher->removeListener($eventName, $wrapped);
         $this->dispatcher->addListener($eventName, $this->wrappedListeners[$this->id][$wrapped]);
     }
     unset($this->wrappedListeners[$this->id]);
 }
开发者ID:ronnylt,项目名称:symfony,代码行数:30,代码来源:TraceableEventDispatcher.php

示例3: postDispatch

 private function postDispatch($eventName, $eventId, Event $event)
 {
     switch ($eventName) {
         case KernelEvents::CONTROLLER:
             $this->stopwatch->start('controller', 'section');
             break;
         case KernelEvents::RESPONSE:
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             $this->stopwatch->stopSection($token);
             if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
                 // The profiles can only be updated once they have been created
                 // that is after the 'kernel.response' event of the main request
                 $this->updateProfiles($token, true);
             }
             break;
         case KernelEvents::TERMINATE:
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             // In the special case described in the `preDispatch` method above, the `$token` section
             // does not exist, then closing it throws an exception which must be caught.
             try {
                 $this->stopwatch->stopSection($token);
             } catch (\LogicException $e) {
             }
             // The children profiles have been updated by the previous 'kernel.response'
             // event. Only the root profile need to be updated with the 'kernel.terminate'
             // timing information.
             $this->updateProfiles($token, false);
             break;
     }
     foreach ($this->wrappedListeners[$eventId] as $wrapped) {
         $this->dispatcher->removeListener($eventName, $wrapped);
         $this->dispatcher->addListener($eventName, $this->wrappedListeners[$eventId][$wrapped]);
     }
     unset($this->wrappedListeners[$eventId]);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:35,代码来源:TraceableEventDispatcher.php

示例4: onKernelResponse

 /**
  * Runs after filters.
  *
  * Handler for onKernelResponse.
  */
 public function onKernelResponse(Event $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
         $this['dispatcher']->dispatch(SilexEvents::AFTER, $event);
     }
 }
开发者ID:hhamon,项目名称:Silex,代码行数:11,代码来源:Application.php

示例5: onKernelRequest

 /**
  * Method call on the first request
  * @param Event $event The kernel request event
  */
 public function onKernelRequest(Event $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST == $event->getRequestType()) {
         $this->cacheResetter->setRequest($event->getRequest());
     }
 }
开发者ID:valentin-claras,项目名称:CacheExtraBundle,代码行数:10,代码来源:CacheResetterListener.php


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