From 229f9bd41aba0b8f99be4419deba68ae066c583e Mon Sep 17 00:00:00 2001 From: Evert Harmeling Date: Wed, 21 Dec 2022 11:27:54 +0100 Subject: [PATCH] Replace service name with FQCN class reference As there isn't any mention of `app.hello_controller` (no definition) and the previous chapter mentioned using the FQCN is what Symfony recommends (it eases refactoring, especially for `php` configuration) it makes much more sense to make use of the FQCN as the service identifier. And lined up the `yaml`-config (as done in the rest of the documentation; routing chapter) --- controller/service.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/controller/service.rst b/controller/service.rst index 724143e3046..f034f524f12 100644 --- a/controller/service.rst +++ b/controller/service.rst @@ -100,9 +100,9 @@ a service like: ``App\Controller\HelloController::index``: # config/routes.yaml hello: - path: /hello + path: /hello controller: App\Controller\HelloController::index - methods: GET + methods: GET .. code-block:: xml @@ -181,8 +181,8 @@ which is a common practice when following the `ADR pattern`_ # config/routes.yaml hello: - path: /hello/{name} - controller: app.hello_controller + path: /hello/{name} + controller: App\Controller\HelloController .. code-block:: xml @@ -194,16 +194,18 @@ which is a common practice when following the `ADR pattern`_ https://symfony.com/schema/routing/routing-1.0.xsd"> - app.hello_controller + App\Controller\HelloController .. code-block:: php + use App\Controller\HelloController; + // app/config/routing.php $collection->add('hello', new Route('/hello', [ - '_controller' => 'app.hello_controller', + '_controller' => HelloController::class, ])); Alternatives to base Controller Methods