Skip to content

Commit

Permalink
minor #6734 Add little caution to add service id for @route annotatio…
Browse files Browse the repository at this point in the history
…n (DHager, WouterJ)

This PR was merged into the 2.7 branch.

Discussion
----------

Add little caution to add service id for @route annotation

Finishes #6258

Original PR description:

 > I just ran into this problem and it took me a while. Without the `@Route(service="myid")` annotation, the controller was *always* being instantiated without any arguments, completely ignoring my service-definition.

 > Not sure how far back/forward this applies to other versions.

Commits
-------

93bb21c Merge caution with annotations tip
ac6b008 Add warning about a pitfall where the controller seems to be instantiated without using the service-definition
  • Loading branch information
wouterj committed Jul 9, 2016
2 parents 240f639 + 93bb21c commit 812dbfd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cookbook/controller/service.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,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::
Expand Down Expand Up @@ -338,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

0 comments on commit 812dbfd

Please sign in to comment.