Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

[routing] change doc to best practices #803

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 75 additions & 56 deletions bundles/routing/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ To add the ``DynamicRouter``, use the following configuration:

.. code-block:: yaml

# app/config/config.yml
cmf_routing:
chain:
routers_by_id:
Expand All @@ -36,6 +37,7 @@ To add the ``DynamicRouter``, use the following configuration:

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services">

Expand All @@ -50,14 +52,15 @@ To add the ``DynamicRouter``, use the following configuration:

.. code-block:: php

$container->loadFromExtension('cmf_routing', array(
'chain' => array(
'routers_by_id' => array(
// app/config/config.php
$container->loadFromExtension('cmf_routing', [
'chain' => [
'routers_by_id' => [
'cmf_routing.dynamic_router' => 200,
'router.default' => 100,
),
),
));
],
],
]);

.. tip::

Expand All @@ -79,12 +82,14 @@ default router, because :ref:`no other routers were set <reference-config-routin

.. code-block:: yaml

# app/config/config.yml
cmf_routing:
chain:
replace_symfony_router: true

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services">

Expand All @@ -98,11 +103,12 @@ default router, because :ref:`no other routers were set <reference-config-routin

.. code-block:: php

$container->loadFromExtension('cmf_routing', array(
'chain' => array(
// app/config/config.php
$container->loadFromExtension('cmf_routing', [
'chain' => [
'replace_symfony_router' => true,
),
));
],
]);


.. _reference-config-routing-dynamic:
Expand All @@ -123,10 +129,9 @@ generic_controller

**type**: ``string`` **default**: ``null``

The controller to use when the route enhancers only determined the template but
no explicit controller. The value is the name of a controller using either the
``AcmeDemoBundle::Page::index`` or ``acme_demo.controller.page:indexAction``
notation.
This configuration specifies the controller that is used when the route
enhancers define a template but no explicit controller. It accepts any valid
Symfony controller reference.

If the :doc:`CoreBundle <../core/introduction>` and
:doc:`ContentBundle <../content/introduction>` are registered, this
Expand All @@ -139,7 +144,7 @@ defaults to ``cmf_content.controller:indexAction``.

The default controller to use if none of the enhancers found a controller. The
value is the name of a controller using either the
``AcmeDemoBundle::Page::index`` or ``acme_demo.controller.page:indexAction``
``AppBundle::Page::index`` or ``app.page_controller:indexAction``
notation.

``controllers_by_type``
Expand All @@ -155,34 +160,36 @@ type:

.. code-block:: yaml

# app/config/config.yml
cmf_routing:
dynamic:
controllers_by_type:
editable: acme_main.controller:editableAction
editable: AppBundle:Cms:editable

.. code-block:: xml


<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services">

<config xmlns="http://cmf.symfony.com/schema/dic/routing">
<dynamic>
<controller-by-type type="editable">acme_main.controller:editableAction</controller-by-type>
<controller-by-type type="editable">AppBundle:Cms:editable</controller-by-type>
</dynamic>
</config>

</container>

.. code-block:: php

$container->loadFromExtension('cmf_routing', array(
'dynamic' => array(
'controllers_by_type' => array(
'editable' => 'acme_main.controller:editableAction',
),
),
));
// app/config/config.php
$container->loadFromExtension('cmf_routing', [
'dynamic' => [
'controllers_by_type' => [
'editable' => 'AppBundle:Cms:editable',
],
],
]);

controllers_by_class
....................
Expand All @@ -203,13 +210,15 @@ choose this controller to handle the request.

.. code-block:: yaml

# app/config/config.yml
cmf_routing:
dynamic:
controllers_by_class:
Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent: cmf_content.controller:indexAction

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services">

Expand All @@ -226,10 +235,13 @@ choose this controller to handle the request.

.. code-block:: php

$container->loadFromExtension('cmf_routing', array(
'dynamic' => array(
'controllers_by_class' => array(
'Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent' => 'cmf_content.controller:indexAction',
// app/config/config.php
use Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent;

$container->loadFromExtension('cmf_routing', [
'dynamic' => [
'controllers_by_class' => [
StaticContent::class => 'cmf_content.controller:indexAction',
),
),
));
Expand All @@ -255,16 +267,17 @@ setting is set as controller.

.. code-block:: yaml

# app/config/config.yml
cmf_routing:
dynamic:
templates_by_class:
Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent: CmfContentBundle:StaticContent:index.html.twig

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services">

<config xmlns="http://cmf.symfony.com/schema/dic/routing">
<dynamic>
<template-by-class
Expand All @@ -278,10 +291,13 @@ setting is set as controller.

.. code-block:: php

$container->loadFromExtension('cmf_routing', array(
'dynamic' => array(
'templates_by_class' => array(
'Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent' => 'CmfContentBundle:StaticContent:index.html.twig',
// app/config/config.php
use Symfony\Cmf\Bundle\ContentBundle\Document\StaticContent;

$container->loadFromExtension('cmf_routing', [
'dynamic' => [
'templates_by_class' => [
StaticContent::class => 'CmfContentBundle:StaticContent:index.html.twig',
),
),
));
Expand Down Expand Up @@ -349,24 +365,25 @@ disables the limit entirely.

.. code-block:: php

$container->loadFromExtension('cmf_routing', array(
'dynamic' => array(
'persistence' => array(
'phpcr' => array(
# app/config/config.php
$container->loadFromExtension('cmf_routing', [
'dynamic' => [
'persistence' => [
'phpcr' => [
'enabled' => false,
'manager_name' => null,
'route_basepaths' => array(
'route_basepaths' => [
'/cms/routes',
'/cms/simple',
)
],
'content_basepath' => '/cms/content',
'admin_basepath' => '/cms/routes',
'use_sonata_admin' => 'auto',
'enable_initializer' => true,
),
),
),
));
],
],
],
]);

enabled
*******
Expand Down Expand Up @@ -470,7 +487,7 @@ If ``true``, the ORM is included in the service container.
The name of the Doctrine Manager to use.

``route_class``
****************
***************

**type**: ``string`` **default**: ``'Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\Route'``

Expand Down Expand Up @@ -511,34 +528,36 @@ priority.

.. code-block:: yaml

# app/config/config.yml
cmf_routing:
dynamic:
route_filters_by_id:
acme_main.routing.foo_filter: 100
app.routing_filter: 100

.. code-block:: xml


<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services">

<config xmlns="http://cmf.symfony.com/schema/dic/routing">
<dynamic>
<route-filter-by-id id="acme_main.routing.foo_filter">100</route-filter-by-id>
<route-filter-by-id id="app.routing_filter">100</route-filter-by-id>
</dynamic>
</config>

</container>

.. code-block:: php

$container->loadFromExtension('cmf_routing', array(
'dynamic' => array(
'route_filters_by_id' => array(
'acme_main.routing.foo_filter' => 100,
),
),
));
// app/config/config.php
$container->loadFromExtension('cmf_routing', [
'dynamic' => [
'route_filters_by_id' => [
'app.routing_filter' => 100,
],
],
]);

``content_repository_service_id``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -568,7 +587,7 @@ service.
``locales``
~~~~~~~~~~~

**type**: ``array`` **default**: ``array()``
**type**: ``array`` **default**: ``[]``

To enable multi-language, set the valid locales in this option.

Expand Down
Loading