e0d46aa4ce3e8a9934c0e046faf86a2ce197de07
[yaffs-website] / vendor / symfony / http-kernel / Event / FilterControllerEvent.php
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\HttpKernel\HttpKernelInterface;
15 use Symfony\Component\HttpFoundation\Request;
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     /**
31      * The current controller.
32      */
33     private $controller;
34
35     public function __construct(HttpKernelInterface $kernel, callable $controller, Request $request, $requestType)
36     {
37         parent::__construct($kernel, $request, $requestType);
38
39         $this->setController($controller);
40     }
41
42     /**
43      * Returns the current controller.
44      *
45      * @return callable
46      */
47     public function getController()
48     {
49         return $this->controller;
50     }
51
52     /**
53      * Sets a new controller.
54      *
55      * @param callable $controller
56      */
57     public function setController(callable $controller)
58     {
59         $this->controller = $controller;
60     }
61 }