[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\HttpKernel\Debug; 13 14 use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher as BaseTraceableEventDispatcher; 15 use Symfony\Component\EventDispatcher\Event; 16 use Symfony\Component\HttpKernel\KernelEvents; 17 use Symfony\Component\HttpKernel\Profiler\Profiler; 18 19 /** 20 * Collects some data about event listeners. 21 * 22 * This event dispatcher delegates the dispatching to another one. 23 * 24 * @author Fabien Potencier <fabien@symfony.com> 25 */ 26 class TraceableEventDispatcher extends BaseTraceableEventDispatcher 27 { 28 /** 29 * Sets the profiler. 30 * 31 * The traceable event dispatcher does not use the profiler anymore. 32 * The job is now done directly by the Profiler listener and the 33 * data collectors themselves. 34 * 35 * @param Profiler|null $profiler A Profiler instance 36 * 37 * @deprecated since version 2.4, to be removed in 3.0. 38 */ 39 public function setProfiler(Profiler $profiler = null) 40 { 41 @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.4 and will be removed in 3.0.', E_USER_DEPRECATED); 42 } 43 44 /** 45 * {@inheritdoc} 46 */ 47 protected function preDispatch($eventName, Event $event) 48 { 49 switch ($eventName) { 50 case KernelEvents::REQUEST: 51 $this->stopwatch->openSection(); 52 break; 53 case KernelEvents::VIEW: 54 case KernelEvents::RESPONSE: 55 // stop only if a controller has been executed 56 if ($this->stopwatch->isStarted('controller')) { 57 $this->stopwatch->stop('controller'); 58 } 59 break; 60 case KernelEvents::TERMINATE: 61 $token = $event->getResponse()->headers->get('X-Debug-Token'); 62 // There is a very special case when using built-in AppCache class as kernel wrapper, in the case 63 // of an ESI request leading to a `stale` response [B] inside a `fresh` cached response [A]. 64 // In this case, `$token` contains the [B] debug token, but the open `stopwatch` section ID 65 // is equal to the [A] debug token. Trying to reopen section with the [B] token throws an exception 66 // which must be caught. 67 try { 68 $this->stopwatch->openSection($token); 69 } catch (\LogicException $e) { 70 } 71 break; 72 } 73 } 74 75 /** 76 * {@inheritdoc} 77 */ 78 protected function postDispatch($eventName, Event $event) 79 { 80 switch ($eventName) { 81 case KernelEvents::CONTROLLER: 82 $this->stopwatch->start('controller', 'section'); 83 break; 84 case KernelEvents::RESPONSE: 85 $token = $event->getResponse()->headers->get('X-Debug-Token'); 86 $this->stopwatch->stopSection($token); 87 break; 88 case KernelEvents::TERMINATE: 89 // In the special case described in the `preDispatch` method above, the `$token` section 90 // does not exist, then closing it throws an exception which must be caught. 91 $token = $event->getResponse()->headers->get('X-Debug-Token'); 92 try { 93 $this->stopwatch->stopSection($token); 94 } catch (\LogicException $e) { 95 } 96 break; 97 } 98 } 99 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |