c25a0f1cf1a1a76cb0e246a31113ce571f97d2b1
[yaffs-website] / vendor / symfony / http-kernel / Event / GetResponseEvent.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\HttpFoundation\Response;
15
16 /**
17  * Allows to create a response for a request.
18  *
19  * Call setResponse() to set the response that will be returned for the
20  * current request. The propagation of this event is stopped as soon as a
21  * response is set.
22  *
23  * @author Bernhard Schussek <bschussek@gmail.com>
24  */
25 class GetResponseEvent extends KernelEvent
26 {
27     private $response;
28
29     /**
30      * Returns the response object.
31      *
32      * @return Response|null
33      */
34     public function getResponse()
35     {
36         return $this->response;
37     }
38
39     /**
40      * Sets a response and stops event propagation.
41      */
42     public function setResponse(Response $response)
43     {
44         $this->response = $response;
45
46         $this->stopPropagation();
47     }
48
49     /**
50      * Returns whether a response was set.
51      *
52      * @return bool Whether a response was set
53      */
54     public function hasResponse()
55     {
56         return null !== $this->response;
57     }
58 }