1 | <?php |
||
24 | class Controller |
||
25 | { |
||
26 | /** |
||
27 | * @var Application |
||
28 | */ |
||
29 | protected $application; |
||
30 | |||
31 | /** |
||
32 | * Constructor. |
||
33 | * |
||
34 | * @param Application $app |
||
35 | */ |
||
36 | public function __construct(Application $app) |
||
40 | |||
41 | /** |
||
42 | * Gets Doctrine Entity Manager. |
||
43 | * |
||
44 | * @return EntityManager |
||
45 | */ |
||
46 | public function getEntityManager() |
||
50 | |||
51 | /** |
||
52 | * Gets the Form Factory. |
||
53 | * |
||
54 | * @return FormFactory |
||
55 | */ |
||
56 | public function getFormFactory() |
||
60 | |||
61 | /** |
||
62 | * Gets the router. |
||
63 | * |
||
64 | * @return UrlGenerator |
||
65 | */ |
||
66 | public function getRouter() |
||
70 | |||
71 | /** |
||
72 | * Gets the session. |
||
73 | * |
||
74 | * @return Session |
||
75 | */ |
||
76 | public function getSession() |
||
80 | |||
81 | /** |
||
82 | * Gets the Twig service. |
||
83 | * |
||
84 | * @return Twig_Environment |
||
85 | */ |
||
86 | public function getTwig() |
||
90 | |||
91 | /** |
||
92 | * Redirects the user to another route. |
||
93 | * |
||
94 | * @param string $route |
||
95 | * @param array $parameters |
||
96 | * @param int $status |
||
97 | * |
||
98 | * @return RedirectResponse |
||
99 | */ |
||
100 | public function redirect($route, $parameters = [], $status = 302) |
||
104 | |||
105 | /** |
||
106 | * Redirects the user to another URL. |
||
107 | * |
||
108 | * @param string $url The URL to redirect to |
||
109 | * @param int $status The status code (302 by default) |
||
110 | * |
||
111 | * @return RedirectResponse |
||
112 | */ |
||
113 | public function redirectTo($url, $status = 302) |
||
117 | |||
118 | /** |
||
119 | * Generates a path from the given parameters. |
||
120 | * |
||
121 | * @param string $route |
||
122 | * @param mixed $parameters |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | public function path($route, $parameters = []) |
||
130 | |||
131 | /** |
||
132 | * Generates an absolute URL from the given parameters. |
||
133 | * |
||
134 | * @param string $route |
||
135 | * @param mixed $parameters |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | public function url($route, $parameters = []) |
||
143 | |||
144 | /** |
||
145 | * Renders a twig template. |
||
146 | * |
||
147 | * @param string $name |
||
148 | * @param array $context |
||
149 | * |
||
150 | * @return string |
||
151 | */ |
||
152 | public function render($name, array $context = []) |
||
156 | |||
157 | /** |
||
158 | * Adds a flash message. |
||
159 | * |
||
160 | * @param string $type |
||
161 | * @param string $message |
||
162 | */ |
||
163 | public function flash($type, $message) |
||
167 | |||
168 | /** |
||
169 | * Gets the current authenticated user. |
||
170 | * |
||
171 | * @return UserInterface|null |
||
172 | */ |
||
173 | public function getUser() |
||
180 | |||
181 | /** |
||
182 | * Checks if user is granted a role. |
||
183 | * |
||
184 | * @param string $role |
||
185 | * |
||
186 | * @return bool |
||
187 | */ |
||
188 | public function isGranted($role) |
||
192 | |||
193 | /** |
||
194 | * Get a service from the container |
||
195 | * |
||
196 | * @param string $service |
||
197 | * |
||
198 | * @return mixed |
||
199 | */ |
||
200 | public function get($service) |
||
204 | |||
205 | /** |
||
206 | * Gets a service from the container. |
||
207 | * |
||
208 | * @param string $property |
||
209 | * |
||
210 | * @return mixed |
||
211 | */ |
||
212 | public function __get($property) |
||
216 | } |
||
217 |