From d57ab116427bc5772303d3f71d529bf2a084d827 Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Sun, 24 Nov 2019 17:06:07 +0100 Subject: [PATCH 1/2] Updated docs referencing MicroKernelTrait::configureRoutes() --- .../front_controllers_and_kernel.rst | 2 +- configuration/micro_kernel_trait.rst | 24 ++++++++++++------- setup/flex.rst | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/configuration/front_controllers_and_kernel.rst b/configuration/front_controllers_and_kernel.rst index 42f6dcb2bdc..9a98e169c71 100644 --- a/configuration/front_controllers_and_kernel.rst +++ b/configuration/front_controllers_and_kernel.rst @@ -85,7 +85,7 @@ you must implement them all: :method:`Symfony\\Component\\HttpKernel\\KernelInterface::registerBundles` It must return an array of all bundles needed to run the application. -:method:`Symfony\\Bundle\\FrameworkBundle\\Kernel\\MicroKernelTrait::configureRoutes` +:method:`Symfony\\Bundle\\FrameworkBundle\\Kernel\\MicroKernelTrait::configureRouting` It adds individual routes or collections of routes to the application (for example loading the routes defined in some config file). diff --git a/configuration/micro_kernel_trait.rst b/configuration/micro_kernel_trait.rst index d43d0bfe591..1e9c40a53b0 100644 --- a/configuration/micro_kernel_trait.rst +++ b/configuration/micro_kernel_trait.rst @@ -28,7 +28,7 @@ Next, create an ``index.php`` file that defines the kernel class and executes it use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Kernel as BaseKernel; - use Symfony\Component\Routing\RouteCollectionBuilder; + use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; require __DIR__.'/vendor/autoload.php'; @@ -51,7 +51,7 @@ Next, create an ``index.php`` file that defines the kernel class and executes it ]); } - protected function configureRoutes(RouteCollectionBuilder $routes) + protected function configureRouting(RoutingConfigurator $routes): void { // kernel is a service that points to this class // optional 3rd argument is the route name @@ -98,9 +98,9 @@ that define your bundles, your services and your routes: of what you see in a normal ``config/packages/*`` file). You can also register services directly in PHP or load external configuration files (shown below). -**configureRoutes(RouteCollectionBuilder $routes)** +**configureRouting(RoutingConfigurator $routes)** Your job in this method is to add routes to the application. The - ``RouteCollectionBuilder`` has methods that make adding routes in PHP more + ``RoutingConfigurator`` has methods that make adding routes in PHP more fun. You can also load external routing files (shown below). Advanced Example: Twig, Annotations and the Web Debug Toolbar @@ -138,7 +138,7 @@ hold the kernel. Now it looks like this:: use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel as BaseKernel; - use Symfony\Component\Routing\RouteCollectionBuilder; + use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; class Kernel extends BaseKernel { @@ -171,16 +171,22 @@ hold the kernel. Now it looks like this:: } } - protected function configureRoutes(RouteCollectionBuilder $routes) + protected function configureRouting(RoutingConfigurator $routes): void { // import the WebProfilerRoutes, only if the bundle is enabled if (isset($this->bundles['WebProfilerBundle'])) { - $routes->import('@WebProfilerBundle/Resources/config/routing/wdt.xml', '/_wdt'); - $routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml', '/_profiler'); + $routes + ->import('@WebProfilerBundle/Resources/config/routing/wdt.xml') + ->prefix('/_wdt') + ; + $routes + ->import('@WebProfilerBundle/Resources/config/routing/profiler.xml') + ->prefix('/_profiler') + ; } // load the annotation routes - $routes->import(__DIR__.'/../src/Controller/', '/', 'annotation'); + $routes->import(__DIR__.'/../src/Controller/', 'annotation'); } // optional, to use the standard Symfony cache directory diff --git a/setup/flex.rst b/setup/flex.rst index 87d40dd6c70..83df0762272 100644 --- a/setup/flex.rst +++ b/setup/flex.rst @@ -107,7 +107,7 @@ manual steps: Make sure that your previous configuration files don't have ``imports`` declarations pointing to resources already loaded by ``Kernel::configureContainer()`` - or ``Kernel::configureRoutes()`` methods. + or ``Kernel::configureRouting()`` methods. #. Move the rest of the ``app/`` contents as follows (and after that, remove the ``app/`` directory): From 14ee1f9845c1e0e1962cb2f07ea5ad8db3374137 Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Mon, 25 Nov 2019 14:02:34 +0300 Subject: [PATCH 2/2] Added versionadded paragraphs --- configuration/front_controllers_and_kernel.rst | 4 ++++ configuration/micro_kernel_trait.rst | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/configuration/front_controllers_and_kernel.rst b/configuration/front_controllers_and_kernel.rst index 9a98e169c71..95fd0445e0b 100644 --- a/configuration/front_controllers_and_kernel.rst +++ b/configuration/front_controllers_and_kernel.rst @@ -89,6 +89,10 @@ you must implement them all: It adds individual routes or collections of routes to the application (for example loading the routes defined in some config file). +.. versionadded:: 5.1 + + The ``configureRouting`` method was introduced in Symfony 5.1. + :method:`Symfony\\Bundle\\FrameworkBundle\\Kernel\\MicroKernelTrait::configureContainer` It loads the application configuration from config files or using the ``loadFromExtension()`` method and can also register new container parameters diff --git a/configuration/micro_kernel_trait.rst b/configuration/micro_kernel_trait.rst index 1e9c40a53b0..7b71738ea34 100644 --- a/configuration/micro_kernel_trait.rst +++ b/configuration/micro_kernel_trait.rst @@ -103,6 +103,10 @@ that define your bundles, your services and your routes: ``RoutingConfigurator`` has methods that make adding routes in PHP more fun. You can also load external routing files (shown below). +.. versionadded:: 5.1 + + The ``configureRouting`` method was introduced in Symfony 5.1. + Advanced Example: Twig, Annotations and the Web Debug Toolbar -------------------------------------------------------------