當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Event::getResponse方法代碼示例

本文整理匯總了PHP中Symfony\Component\EventDispatcher\Event::getResponse方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::getResponse方法的具體用法?PHP Event::getResponse怎麽用?PHP Event::getResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\EventDispatcher\Event的用法示例。


在下文中一共展示了Event::getResponse方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: postDispatch

 /**
  * {@inheritdoc}
  */
 protected 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);
             break;
         case KernelEvents::TERMINATE:
             // 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.
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             try {
                 $this->stopwatch->stopSection($token);
             } catch (\LogicException $e) {
             }
             break;
     }
 }
開發者ID:NivalM,項目名稱:VacantesJannaMotors,代碼行數:24,代碼來源:TraceableEventDispatcher.php

示例2: 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

示例3: dispatch

 /**
  * {@inheritdoc}
  */
 public function dispatch($eventName, Event $event = null)
 {
     switch ($eventName) {
         case 'kernel.request':
             $this->stopwatch->openSection();
             break;
         case 'kernel.view':
         case 'kernel.response':
             // stop only if a controller has been executed
             try {
                 $this->stopwatch->stop('controller');
             } catch (\LogicException $e) {
             }
             break;
         case 'kernel.terminate':
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             $this->stopwatch->openSection($token);
             break;
     }
     $e1 = $this->stopwatch->start($eventName, 'section');
     parent::dispatch($eventName, $event);
     $e1->stop();
     switch ($eventName) {
         case 'kernel.controller':
             $this->stopwatch->start('controller', 'section');
             break;
         case 'kernel.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 'kernel.terminate':
             $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;
     }
     return $event;
 }
開發者ID:laubosslink,項目名稱:lab,代碼行數:48,代碼來源:ContainerAwareTraceableEventDispatcher.php

示例4: dispatch

 /**
  * {@inheritdoc}
  */
 public function dispatch($eventName, Event $event = null)
 {
     switch ($eventName) {
         case 'kernel.request':
             $this->stopwatch->openSection();
             break;
         case 'kernel.view':
         case 'kernel.response':
             // stop only if a controller has been executed
             try {
                 $this->stopwatch->stop('controller');
             } catch (\LogicException $e) {
             }
             break;
         case 'kernel.terminate':
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             $this->stopwatch->openSection($token);
             break;
     }
     $e1 = $this->stopwatch->start($eventName, 'section');
     parent::dispatch($eventName, $event);
     $e1->stop();
     switch ($eventName) {
         case 'kernel.controller':
             $this->stopwatch->start('controller', 'section');
             break;
         case 'kernel.response':
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             $this->stopwatch->stopSection($token);
             $this->updateProfile($token);
             break;
         case 'kernel.terminate':
             $this->stopwatch->stopSection($token);
             $this->updateProfile($token);
             break;
     }
     return $event;
 }
開發者ID:richardmiller,項目名稱:symfony,代碼行數:41,代碼來源:ContainerAwareTraceableEventDispatcher.php

示例5: 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

示例6: 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

示例7: onResponse

 public function onResponse(Event $event)
 {
     $response = $event->getResponse();
     /* @var $response \Symfony\Component\HttpFoundation\Response */
     $session = $event->getRequest()->getSession();
     /* @var $session \Symfony\Component\HttpFoundation\Session */
     $response->headers->setCookie(new Cookie('locale', $session->get('localeIdentified')));
     if (null !== $this->logger) {
         $this->logger->info(sprintf('Locale Cookie set to: [ %s ]', $session->get('localeIdentified')));
     }
 }
開發者ID:rdohms,項目名稱:LocaleBundle,代碼行數:11,代碼來源:LocaleDetectorListener.php

示例8: 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);
             break;
         case KernelEvents::TERMINATE:
             // 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.
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             try {
                 $this->stopwatch->stopSection($token);
             } catch (\LogicException $e) {
             }
             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:ningcaichen,項目名稱:laravel-4.1-quick-start-cn,代碼行數:26,代碼來源:TraceableEventDispatcher.php


注:本文中的Symfony\Component\EventDispatcher\Event::getResponse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。