[ 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\Event; 13 14 use Symfony\Component\HttpFoundation\Request; 15 use Symfony\Component\HttpKernel\HttpKernelInterface; 16 17 /** 18 * Allows filtering of a controller callable. 19 * 20 * You can call getController() to retrieve the current controller. With 21 * setController() you can set a new controller that is used in the processing 22 * of the request. 23 * 24 * Controllers should be callables. 25 * 26 * @author Bernhard Schussek <bschussek@gmail.com> 27 */ 28 class FilterControllerEvent extends KernelEvent 29 { 30 private $controller; 31 32 public function __construct(HttpKernelInterface $kernel, $controller, Request $request, $requestType) 33 { 34 parent::__construct($kernel, $request, $requestType); 35 36 $this->setController($controller); 37 } 38 39 /** 40 * Returns the current controller. 41 * 42 * @return callable 43 */ 44 public function getController() 45 { 46 return $this->controller; 47 } 48 49 /** 50 * Sets a new controller. 51 * 52 * @param callable $controller 53 * 54 * @throws \LogicException 55 */ 56 public function setController($controller) 57 { 58 // controller must be a callable 59 if (!\is_callable($controller)) { 60 throw new \LogicException(sprintf('The controller must be a callable (%s given).', $this->varToString($controller))); 61 } 62 63 $this->controller = $controller; 64 } 65 66 private function varToString($var) 67 { 68 if (\is_object($var)) { 69 return sprintf('Object(%s)', \get_class($var)); 70 } 71 72 if (\is_array($var)) { 73 $a = array(); 74 foreach ($var as $k => $v) { 75 $a[] = sprintf('%s => %s', $k, $this->varToString($v)); 76 } 77 78 return sprintf('Array(%s)', implode(', ', $a)); 79 } 80 81 if (\is_resource($var)) { 82 return sprintf('Resource(%s)', get_resource_type($var)); 83 } 84 85 if (null === $var) { 86 return 'null'; 87 } 88 89 if (false === $var) { 90 return 'false'; 91 } 92 93 if (true === $var) { 94 return 'true'; 95 } 96 97 return (string) $var; 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 |