[ Index ] |
PHP Cross Reference of phpBB-3.1.12-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\Request; 15 use Symfony\Component\HttpFoundation\Response; 16 use Symfony\Component\HttpFoundation\RedirectResponse; 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 * @param FilterControllerEvent $event The filter controller event 65 */ 66 public function onKernelController(FilterControllerEvent $event) 67 { 68 $this->controllers[$event->getRequest()] = $event->getController(); 69 } 70 71 /** 72 * @return bool Whether this request will result in a redirect 73 */ 74 public function getRedirect() 75 { 76 return $this->data['redirect']; 77 } 78 79 /** 80 * @return string|null The target URL 81 */ 82 public function getTargetUrl() 83 { 84 return $this->data['url']; 85 } 86 87 /** 88 * @return string|null The target route 89 */ 90 public function getTargetRoute() 91 { 92 return $this->data['route']; 93 } 94 95 /** 96 * {@inheritdoc} 97 */ 98 public function getName() 99 { 100 return 'router'; 101 } 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |