[ 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\DataCollector; 13 14 use Symfony\Component\HttpFoundation\RedirectResponse; 15 use Symfony\Component\HttpFoundation\Request; 16 use Symfony\Component\HttpFoundation\Response; 17 use Symfony\Component\HttpKernel\Event\FilterControllerEvent; 18 19 /** 20 * RouterDataCollector. 21 * 22 * @author Fabien Potencier <fabien@symfony.com> 23 */ 24 class RouterDataCollector extends DataCollector 25 { 26 protected $controllers; 27 28 public function __construct() 29 { 30 $this->controllers = new \SplObjectStorage(); 31 32 $this->data = array( 33 'redirect' => false, 34 'url' => null, 35 'route' => null, 36 ); 37 } 38 39 /** 40 * {@inheritdoc} 41 */ 42 public function collect(Request $request, Response $response, \Exception $exception = null) 43 { 44 if ($response instanceof RedirectResponse) { 45 $this->data['redirect'] = true; 46 $this->data['url'] = $response->getTargetUrl(); 47 48 if ($this->controllers->contains($request)) { 49 $this->data['route'] = $this->guessRoute($request, $this->controllers[$request]); 50 } 51 } 52 53 unset($this->controllers[$request]); 54 } 55 56 protected function guessRoute(Request $request, $controller) 57 { 58 return 'n/a'; 59 } 60 61 /** 62 * Remembers the controller associated to each request. 63 */ 64 public function onKernelController(FilterControllerEvent $event) 65 { 66 $this->controllers[$event->getRequest()] = $event->getController(); 67 } 68 69 /** 70 * @return bool Whether this request will result in a redirect 71 */ 72 public function getRedirect() 73 { 74 return $this->data['redirect']; 75 } 76 77 /** 78 * @return string|null The target URL 79 */ 80 public function getTargetUrl() 81 { 82 return $this->data['url']; 83 } 84 85 /** 86 * @return string|null The target route 87 */ 88 public function getTargetRoute() 89 { 90 return $this->data['route']; 91 } 92 93 /** 94 * {@inheritdoc} 95 */ 96 public function getName() 97 { 98 return 'router'; 99 } 100 }
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 |