From 802244d3ae793764a7bece89831315a88483b4c4 Mon Sep 17 00:00:00 2001 From: Jules Pietri Date: Tue, 5 Mar 2019 18:31:54 +0100 Subject: [PATCH] Some route fixes left after #11085 --- components/routing.rst | 10 ++++++---- routing/hostname_pattern.rst | 13 ++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/components/routing.rst b/components/routing.rst index 1ca54d655ff..a46922505ea 100644 --- a/components/routing.rst +++ b/components/routing.rst @@ -277,12 +277,14 @@ If you're using the ``YamlFileLoader``, then route definitions look like this: # routes.yaml route1: - path: /foo - defaults: { _controller: 'MyController::fooAction' } + path: /foo + controller: MyController::fooAction + methods: GET|HEAD route2: - path: /foo/bar - defaults: { _controller: 'MyController::foobarAction' } + path: /foo/bar + controller: FooBarInvokableController + methods: PUT To load this file, you can use the following code. This assumes that your ``routes.yaml`` file is in the same directory as the below code:: diff --git a/routing/hostname_pattern.rst b/routing/hostname_pattern.rst index 2d341aa3c72..a9bec2e3802 100644 --- a/routing/hostname_pattern.rst +++ b/routing/hostname_pattern.rst @@ -381,8 +381,8 @@ You can also set the host option on imported routes: .. code-block:: php-annotations - // src/Controller/MainController.php - namespace Acme\HelloBundle\Controller; + // vendor/acme/acme-hello-bundle/src/Controller/MainController.php + namespace Acme\AcmeHelloBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; @@ -417,10 +417,13 @@ You can also set the host option on imported routes: .. code-block:: php // config/routes.php - $routes = $loader->import("@AcmeHelloBundle/Resources/config/routing.php"); - $routes->setHost('hello.example.com'); + namespace Symfony\Component\Routing\Loader\Configurator; - return $routes; + return function (RoutingConfigurator $routes) { + $routes->import("@AcmeHelloBundle/Resources/config/routing.php") + ->host('hello.example.com') + ; + }; The host ``hello.example.com`` will be set on each route loaded from the new routing resource.