From ac6b00828ec3bce90cb0fb4014e397488d5976b2 Mon Sep 17 00:00:00 2001 From: Darien Hager Date: Wed, 10 Feb 2016 14:53:26 -0800 Subject: [PATCH 1/2] Add warning about a pitfall where the controller seems to be instantiated without using the service-definition --- cookbook/controller/service.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cookbook/controller/service.rst b/cookbook/controller/service.rst index 05c812df270..5fe15dbf741 100644 --- a/cookbook/controller/service.rst +++ b/cookbook/controller/service.rst @@ -76,6 +76,13 @@ Then you can define it as a service as follows: 'AppBundle\Controller\HelloController' )); +.. caution:: + + If you are managing your routes with PHP annotation, you may need to add an + ``@Route`` annotation to the controller-class which specifies its service + ID. If you don't, the system may try to construct your controller without + any arguments. See the `FrameworkExtraBundle documentation`_ for details. + Referring to the Service ------------------------ From 93bb21ce7ed993ff93eeb81f6ab7d97f8bd34b23 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Fri, 8 Jul 2016 15:33:34 +0200 Subject: [PATCH 2/2] Merge caution with annotations tip --- cookbook/controller/service.rst | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/cookbook/controller/service.rst b/cookbook/controller/service.rst index 5fe15dbf741..6c0cb850ae8 100644 --- a/cookbook/controller/service.rst +++ b/cookbook/controller/service.rst @@ -76,13 +76,6 @@ Then you can define it as a service as follows: 'AppBundle\Controller\HelloController' )); -.. caution:: - - If you are managing your routes with PHP annotation, you may need to add an - ``@Route`` annotation to the controller-class which specifies its service - ID. If you don't, the system may try to construct your controller without - any arguments. See the `FrameworkExtraBundle documentation`_ for details. - Referring to the Service ------------------------ @@ -126,7 +119,8 @@ the route ``_controller`` value: .. tip:: You can also use annotations to configure routing using a controller - defined as a service. See the `FrameworkExtraBundle documentation`_ for + defined as a service. Make sure you specify the service ID in the + ``@Route`` annotation. See the `FrameworkExtraBundle documentation`_ for details. .. tip:: @@ -345,4 +339,4 @@ controller: .. _`Controller class source code`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php .. _`base Controller class`: https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php -.. _`FrameworkExtraBundle documentation`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html +.. _`FrameworkExtraBundle documentation`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html#controller-as-service