1 | <?php |
||
27 | class Controller |
||
28 | { |
||
29 | /** |
||
30 | * @var Application |
||
31 | */ |
||
32 | protected $application; |
||
33 | |||
34 | /** |
||
35 | * Constructor. |
||
36 | * |
||
37 | * @param Application $app |
||
38 | */ |
||
39 | public function __construct(Application $app) |
||
43 | |||
44 | /** |
||
45 | * Returns a new AccessDeniedException. |
||
46 | * |
||
47 | * @param string $message |
||
48 | * |
||
49 | * @return AccessDeniedException |
||
50 | */ |
||
51 | protected function createAccessDeniedException($message = 'Access Denied.') |
||
55 | |||
56 | /** |
||
57 | * Returns a new NotFoundHttpException. |
||
58 | * |
||
59 | * @param string $message |
||
60 | * |
||
61 | * @return NotFoundHttpException |
||
62 | */ |
||
63 | protected function createNotFoundHttpException($message = 'Not Found') |
||
67 | |||
68 | /** |
||
69 | * Throws an exception unless the attributes are granted against the current authentication token. |
||
70 | * |
||
71 | * @param mixed $roles |
||
72 | * @param string $message |
||
73 | * |
||
74 | * @throws AccessDeniedException |
||
75 | */ |
||
76 | protected function denyAccessUnlessGranted($roles, $message = 'Access Denied.') |
||
85 | |||
86 | /** |
||
87 | * Gets Doctrine Entity Manager. |
||
88 | * |
||
89 | * @return EntityManager |
||
90 | */ |
||
91 | public function getEntityManager() |
||
95 | |||
96 | /** |
||
97 | * Gets the Form Factory. |
||
98 | * |
||
99 | * @return FormFactory |
||
100 | */ |
||
101 | public function getFormFactory() |
||
105 | |||
106 | /** |
||
107 | * Gets the project root directory. |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | public function getRootDir() |
||
115 | |||
116 | /** |
||
117 | * Gets the router. |
||
118 | * |
||
119 | * @return UrlGenerator |
||
120 | */ |
||
121 | public function getRouter() |
||
125 | |||
126 | /** |
||
127 | * Gets the session. |
||
128 | * |
||
129 | * @return Session |
||
130 | */ |
||
131 | public function getSession() |
||
135 | |||
136 | /** |
||
137 | * Gets the Twig service. |
||
138 | * |
||
139 | * @return Environment |
||
140 | */ |
||
141 | public function getTwig() |
||
145 | |||
146 | /** |
||
147 | * Gets the current authenticated user or null if not logged in. |
||
148 | * |
||
149 | * @return User|null |
||
150 | */ |
||
151 | public function getUser() |
||
160 | |||
161 | /** |
||
162 | * Redirects the user to another route. |
||
163 | * |
||
164 | * @param string $route |
||
165 | * @param array $parameters |
||
166 | * @param int $status |
||
167 | * |
||
168 | * @return RedirectResponse |
||
169 | */ |
||
170 | public function redirect($route, $parameters = [], $status = 302) |
||
174 | |||
175 | /** |
||
176 | * Redirects the user to another URL. |
||
177 | * |
||
178 | * @param string $url The URL to redirect to |
||
179 | * @param int $status The status code (302 by default) |
||
180 | * |
||
181 | * @return RedirectResponse |
||
182 | */ |
||
183 | public function redirectTo($url, $status = 302) |
||
187 | |||
188 | /** |
||
189 | * Generates a path from the given parameters. |
||
190 | * |
||
191 | * @param string $route |
||
192 | * @param mixed $parameters |
||
193 | * |
||
194 | * @return string |
||
195 | */ |
||
196 | public function path($route, $parameters = []) |
||
200 | |||
201 | /** |
||
202 | * Generates an absolute URL from the given parameters. |
||
203 | * |
||
204 | * @param string $route |
||
205 | * @param mixed $parameters |
||
206 | * |
||
207 | * @return string |
||
208 | */ |
||
209 | public function url($route, $parameters = []) |
||
213 | |||
214 | /** |
||
215 | * Renders a twig template. |
||
216 | * |
||
217 | * @param string $name |
||
218 | * @param array $context |
||
219 | * |
||
220 | * @return string |
||
221 | */ |
||
222 | public function render($name, array $context = []) |
||
226 | |||
227 | /** |
||
228 | * Adds a flash message. |
||
229 | * |
||
230 | * @param string $type |
||
231 | * @param string $message |
||
232 | */ |
||
233 | public function flash($type, $message) |
||
237 | |||
238 | /** |
||
239 | * Checks if user is granted a role. |
||
240 | * |
||
241 | * @param string $role |
||
242 | * |
||
243 | * @return bool |
||
244 | */ |
||
245 | public function isGranted($role) |
||
249 | |||
250 | /** |
||
251 | * Get a service from the container |
||
252 | * |
||
253 | * @param string $service |
||
254 | * |
||
255 | * @return mixed |
||
256 | */ |
||
257 | public function get($service) |
||
261 | |||
262 | /** |
||
263 | * Gets a service from the container. |
||
264 | * |
||
265 | * @param string $property |
||
266 | * |
||
267 | * @return mixed |
||
268 | */ |
||
269 | public function __get($property) |
||
273 | } |
||
274 |