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