Skip to content

Commit 95344ff

Browse files
committed
minor #11089 Some route fixes left after #11085 (Jules Pietri)
This PR was merged into the 4.2 branch. Discussion ---------- Some route fixes left after #11085 Round 2 :). Commits ------- 802244d Some route fixes left after #11085
2 parents bf1c431 + 802244d commit 95344ff

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

components/routing.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,14 @@ If you're using the ``YamlFileLoader``, then route definitions look like this:
277277
278278
# routes.yaml
279279
route1:
280-
path: /foo
281-
defaults: { _controller: 'MyController::fooAction' }
280+
path: /foo
281+
controller: MyController::fooAction
282+
methods: GET|HEAD
282283
283284
route2:
284-
path: /foo/bar
285-
defaults: { _controller: 'MyController::foobarAction' }
285+
path: /foo/bar
286+
controller: FooBarInvokableController
287+
methods: PUT
286288
287289
To load this file, you can use the following code. This assumes that your
288290
``routes.yaml`` file is in the same directory as the below code::

routing/hostname_pattern.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ You can also set the host option on imported routes:
381381

382382
.. code-block:: php-annotations
383383
384-
// src/Controller/MainController.php
385-
namespace Acme\HelloBundle\Controller;
384+
// vendor/acme/acme-hello-bundle/src/Controller/MainController.php
385+
namespace Acme\AcmeHelloBundle\Controller;
386386
387387
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
388388
use Symfony\Component\Routing\Annotation\Route;
@@ -417,10 +417,13 @@ You can also set the host option on imported routes:
417417
.. code-block:: php
418418
419419
// config/routes.php
420-
$routes = $loader->import("@AcmeHelloBundle/Resources/config/routing.php");
421-
$routes->setHost('hello.example.com');
420+
namespace Symfony\Component\Routing\Loader\Configurator;
422421
423-
return $routes;
422+
return function (RoutingConfigurator $routes) {
423+
$routes->import("@AcmeHelloBundle/Resources/config/routing.php")
424+
->host('hello.example.com')
425+
;
426+
};
424427
425428
The host ``hello.example.com`` will be set on each route loaded from the new
426429
routing resource.

0 commit comments

Comments
 (0)