33
33
*
34
34
* @author Fabien Potencier <fabien@symfony.com>
35
35
*/
36
- class Controller extends ContainerAware
36
+ abstract class Controller extends ContainerAware
37
37
{
38
38
/**
39
39
* Generates a URL from the given parameters.
@@ -46,7 +46,7 @@ class Controller extends ContainerAware
46
46
*
47
47
* @see UrlGeneratorInterface
48
48
*/
49
- public function generateUrl ($ route , $ parameters = array (), $ referenceType = UrlGeneratorInterface::ABSOLUTE_PATH )
49
+ protected function generateUrl ($ route , $ parameters = array (), $ referenceType = UrlGeneratorInterface::ABSOLUTE_PATH )
50
50
{
51
51
return $ this ->container ->get ('router ' )->generate ($ route , $ parameters , $ referenceType );
52
52
}
@@ -60,7 +60,7 @@ public function generateUrl($route, $parameters = array(), $referenceType = UrlG
60
60
*
61
61
* @return Response A Response instance
62
62
*/
63
- public function forward ($ controller , array $ path = array (), array $ query = array ())
63
+ protected function forward ($ controller , array $ path = array (), array $ query = array ())
64
64
{
65
65
$ path ['_controller ' ] = $ controller ;
66
66
$ subRequest = $ this ->container ->get ('request_stack ' )->getCurrentRequest ()->duplicate ($ query , null , $ path );
@@ -76,7 +76,7 @@ public function forward($controller, array $path = array(), array $query = array
76
76
*
77
77
* @return RedirectResponse
78
78
*/
79
- public function redirect ($ url , $ status = 302 )
79
+ protected function redirect ($ url , $ status = 302 )
80
80
{
81
81
return new RedirectResponse ($ url , $ status );
82
82
}
@@ -155,7 +155,7 @@ protected function denyAccessUnlessGranted($attributes, $object = null, $message
155
155
*
156
156
* @return string The rendered view
157
157
*/
158
- public function renderView ($ view , array $ parameters = array ())
158
+ protected function renderView ($ view , array $ parameters = array ())
159
159
{
160
160
return $ this ->container ->get ('templating ' )->render ($ view , $ parameters );
161
161
}
@@ -169,7 +169,7 @@ public function renderView($view, array $parameters = array())
169
169
*
170
170
* @return Response A Response instance
171
171
*/
172
- public function render ($ view , array $ parameters = array (), Response $ response = null )
172
+ protected function render ($ view , array $ parameters = array (), Response $ response = null )
173
173
{
174
174
return $ this ->container ->get ('templating ' )->renderResponse ($ view , $ parameters , $ response );
175
175
}
@@ -183,7 +183,7 @@ public function render($view, array $parameters = array(), Response $response =
183
183
*
184
184
* @return StreamedResponse A StreamedResponse instance
185
185
*/
186
- public function stream ($ view , array $ parameters = array (), StreamedResponse $ response = null )
186
+ protected function stream ($ view , array $ parameters = array (), StreamedResponse $ response = null )
187
187
{
188
188
$ templating = $ this ->container ->get ('templating ' );
189
189
@@ -212,7 +212,7 @@ public function stream($view, array $parameters = array(), StreamedResponse $res
212
212
*
213
213
* @return NotFoundHttpException
214
214
*/
215
- public function createNotFoundException ($ message = 'Not Found ' , \Exception $ previous = null )
215
+ protected function createNotFoundException ($ message = 'Not Found ' , \Exception $ previous = null )
216
216
{
217
217
return new NotFoundHttpException ($ message , $ previous );
218
218
}
@@ -229,7 +229,7 @@ public function createNotFoundException($message = 'Not Found', \Exception $prev
229
229
*
230
230
* @return AccessDeniedException
231
231
*/
232
- public function createAccessDeniedException ($ message = 'Access Denied ' , \Exception $ previous = null )
232
+ protected function createAccessDeniedException ($ message = 'Access Denied ' , \Exception $ previous = null )
233
233
{
234
234
return new AccessDeniedException ($ message , $ previous );
235
235
}
@@ -243,7 +243,7 @@ public function createAccessDeniedException($message = 'Access Denied', \Excepti
243
243
*
244
244
* @return Form
245
245
*/
246
- public function createForm ($ type , $ data = null , array $ options = array ())
246
+ protected function createForm ($ type , $ data = null , array $ options = array ())
247
247
{
248
248
return $ this ->container ->get ('form.factory ' )->create ($ type , $ data , $ options );
249
249
}
@@ -256,7 +256,7 @@ public function createForm($type, $data = null, array $options = array())
256
256
*
257
257
* @return FormBuilder
258
258
*/
259
- public function createFormBuilder ($ data = null , array $ options = array ())
259
+ protected function createFormBuilder ($ data = null , array $ options = array ())
260
260
{
261
261
return $ this ->container ->get ('form.factory ' )->createBuilder ('form ' , $ data , $ options );
262
262
}
@@ -270,7 +270,7 @@ public function createFormBuilder($data = null, array $options = array())
270
270
* Symfony to inject the Request object into your controller
271
271
* method instead by type hinting it in the method's signature.
272
272
*/
273
- public function getRequest ()
273
+ protected function getRequest ()
274
274
{
275
275
return $ this ->container ->get ('request_stack ' )->getCurrentRequest ();
276
276
}
@@ -282,7 +282,7 @@ public function getRequest()
282
282
*
283
283
* @throws \LogicException If DoctrineBundle is not available
284
284
*/
285
- public function getDoctrine ()
285
+ protected function getDoctrine ()
286
286
{
287
287
if (!$ this ->container ->has ('doctrine ' )) {
288
288
throw new \LogicException ('The DoctrineBundle is not registered in your application. ' );
@@ -300,7 +300,7 @@ public function getDoctrine()
300
300
*
301
301
* @see Symfony\Component\Security\Core\Authentication\Token\TokenInterface::getUser()
302
302
*/
303
- public function getUser ()
303
+ protected function getUser ()
304
304
{
305
305
if (!$ this ->container ->has ('security.context ' )) {
306
306
throw new \LogicException ('The SecurityBundle is not registered in your application. ' );
@@ -324,7 +324,7 @@ public function getUser()
324
324
*
325
325
* @return bool true if the service id is defined, false otherwise
326
326
*/
327
- public function has ($ id )
327
+ protected function has ($ id )
328
328
{
329
329
return $ this ->container ->has ($ id );
330
330
}
@@ -336,7 +336,7 @@ public function has($id)
336
336
*
337
337
* @return object The service
338
338
*/
339
- public function get ($ id )
339
+ protected function get ($ id )
340
340
{
341
341
return $ this ->container ->get ($ id );
342
342
}
0 commit comments