1 | <?php |
||
25 | class Controller |
||
26 | { |
||
27 | /** |
||
28 | * @var Application |
||
29 | */ |
||
30 | protected $application; |
||
31 | |||
32 | /** |
||
33 | * Constructor. |
||
34 | * |
||
35 | * @param Application $app |
||
36 | */ |
||
37 | public function __construct(Application $app) |
||
41 | |||
42 | /** |
||
43 | * Gets Doctrine Entity Manager. |
||
44 | * |
||
45 | * @return EntityManager |
||
46 | */ |
||
47 | public function getEntityManager() |
||
51 | |||
52 | /** |
||
53 | * Gets the Form Factory. |
||
54 | * |
||
55 | * @return FormFactory |
||
56 | */ |
||
57 | public function getFormFactory() |
||
61 | |||
62 | /** |
||
63 | * Gets the project root directory. |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | public function getRootDir() |
||
71 | |||
72 | /** |
||
73 | * Gets the router. |
||
74 | * |
||
75 | * @return UrlGenerator |
||
76 | */ |
||
77 | public function getRouter() |
||
81 | |||
82 | /** |
||
83 | * Gets the session. |
||
84 | * |
||
85 | * @return Session |
||
86 | */ |
||
87 | public function getSession() |
||
91 | |||
92 | /** |
||
93 | * Gets the Twig service. |
||
94 | * |
||
95 | * @return Twig_Environment |
||
96 | */ |
||
97 | public function getTwig() |
||
101 | |||
102 | /** |
||
103 | * Redirects the user to another route. |
||
104 | * |
||
105 | * @param string $route |
||
106 | * @param array $parameters |
||
107 | * @param int $status |
||
108 | * |
||
109 | * @return RedirectResponse |
||
110 | */ |
||
111 | public function redirect($route, $parameters = [], $status = 302) |
||
115 | |||
116 | /** |
||
117 | * Redirects the user to another URL. |
||
118 | * |
||
119 | * @param string $url The URL to redirect to |
||
120 | * @param int $status The status code (302 by default) |
||
121 | * |
||
122 | * @return RedirectResponse |
||
123 | */ |
||
124 | public function redirectTo($url, $status = 302) |
||
128 | |||
129 | /** |
||
130 | * Generates a path from the given parameters. |
||
131 | * |
||
132 | * @param string $route |
||
133 | * @param mixed $parameters |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | public function path($route, $parameters = []) |
||
141 | |||
142 | /** |
||
143 | * Generates an absolute URL from the given parameters. |
||
144 | * |
||
145 | * @param string $route |
||
146 | * @param mixed $parameters |
||
147 | * |
||
148 | * @return string |
||
149 | */ |
||
150 | public function url($route, $parameters = []) |
||
154 | |||
155 | /** |
||
156 | * Renders a twig template. |
||
157 | * |
||
158 | * @param string $name |
||
159 | * @param array $context |
||
160 | * |
||
161 | * @return string |
||
162 | */ |
||
163 | public function render($name, array $context = []) |
||
167 | |||
168 | /** |
||
169 | * Adds a flash message. |
||
170 | * |
||
171 | * @param string $type |
||
172 | * @param string $message |
||
173 | */ |
||
174 | public function flash($type, $message) |
||
178 | |||
179 | /** |
||
180 | * Gets the current authenticated user. |
||
181 | * |
||
182 | * @return UserInterface|null |
||
183 | */ |
||
184 | public function getUser() |
||
191 | |||
192 | /** |
||
193 | * Checks if user is granted a role. |
||
194 | * |
||
195 | * @param string $role |
||
196 | * |
||
197 | * @return bool |
||
198 | */ |
||
199 | public function isGranted($role) |
||
203 | |||
204 | /** |
||
205 | * Get a service from the container |
||
206 | * |
||
207 | * @param string $service |
||
208 | * |
||
209 | * @return mixed |
||
210 | */ |
||
211 | public function get($service) |
||
215 | |||
216 | /** |
||
217 | * Gets a service from the container. |
||
218 | * |
||
219 | * @param string $property |
||
220 | * |
||
221 | * @return mixed |
||
222 | */ |
||
223 | public function __get($property) |
||
227 | } |
||
228 |