Yaffs site version 1.1
[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     /**
28      * The response object.
29      *
30      * @var Response
31      */
32     private $response;
33
34     /**
35      * Returns the response object.
36      *
37      * @return Response
38      */
39     public function getResponse()
40     {
41         return $this->response;
42     }
43
44     /**
45      * Sets a response and stops event propagation.
46      *
47      * @param Response $response
48      */
49     public function setResponse(Response $response)
50     {
51         $this->response = $response;
52
53         $this->stopPropagation();
54     }
55
56     /**
57      * Returns whether a response was set.
58      *
59      * @return bool Whether a response was set
60      */
61     public function hasResponse()
62     {
63         return null !== $this->response;
64     }
65 }