1 | <?php |
||
20 | class RestEvent extends Event |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * Request object |
||
25 | * |
||
26 | * @var \Symfony\Component\HttpFoundation\Request |
||
27 | */ |
||
28 | private $request = null; |
||
29 | |||
30 | /** |
||
31 | * Response object |
||
32 | * |
||
33 | * @var \Symfony\Component\HttpFoundation\Response |
||
34 | */ |
||
35 | private $response = null; |
||
36 | |||
37 | /** |
||
38 | * Controller which handles the request |
||
39 | * |
||
40 | * @var \Graviton\RestBundle\Controller\RestController |
||
41 | */ |
||
42 | private $controller = null; |
||
43 | |||
44 | /** |
||
45 | * Is there a response? |
||
46 | * |
||
47 | * @return boolean |
||
48 | */ |
||
49 | public function hasResponse() |
||
50 | { |
||
51 | return null !== $this->response; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Set the request object |
||
56 | * |
||
57 | * @param Request $request Request |
||
58 | * |
||
59 | * @return \Graviton\RestBundle\Event\RestEvent $this This |
||
60 | */ |
||
61 | 10 | public function setRequest(Request $request) |
|
67 | |||
68 | /** |
||
69 | * Get the request |
||
70 | * |
||
71 | * @return Request |
||
72 | */ |
||
73 | 10 | public function getRequest() |
|
77 | |||
78 | /** |
||
79 | * Set the response object and DON'T stop propagation -> Do this yourself |
||
80 | * if you need it... |
||
81 | * |
||
82 | * @param Response $response Response object |
||
83 | * |
||
84 | * @return \Graviton\RestBundle\Event\RestEvent $this This object |
||
85 | */ |
||
86 | public function setResponse(Response $response) |
||
87 | { |
||
88 | $this->response = $response; |
||
89 | |||
90 | return $this; |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * Get the response object |
||
95 | * |
||
96 | * @return Response $response Response object |
||
97 | */ |
||
98 | public function getResponse() |
||
102 | |||
103 | /** |
||
104 | * Set the controller for this request |
||
105 | * At the moment, the MainController doesn't extend the RestController. |
||
106 | * As soon this is refactored, we can add a type hint to the method |
||
107 | * |
||
108 | * @param RestController $controller Controller |
||
109 | * |
||
110 | * @return \Graviton\RestBundle\Event\RestEvent $this This object |
||
111 | */ |
||
112 | public function setController($controller) |
||
118 | |||
119 | /** |
||
120 | * Get the controller |
||
121 | * |
||
122 | * @return RestController $controller Controller |
||
123 | */ |
||
124 | public function getController() |
||
128 | } |
||
129 |