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 #801

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
118 changes: 65 additions & 53 deletions bundles/routing/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ To add the ``DynamicRouter``, use the following configuration:

.. code-block:: php

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

.. tip::

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

.. code-block:: php

$container->loadFromExtension('cmf_routing', array(
'chain' => array(
$container->loadFromExtension('cmf_routing', [
'chain' => [
'replace_symfony_router' => true,
),
));
],
]);


.. _reference-config-routing-dynamic:
Expand All @@ -125,7 +125,7 @@ generic_controller

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``
``AppBundle::Page::index`` or ``app.page_controller:indexAction``
notation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, actually, all controller formats are supported right? So maybe we shouldn't explicitely mention these 2 (as you can also do FQCN::methodName)


If the :doc:`CoreBundle <../core/introduction>` and
Expand All @@ -139,7 +139,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 +155,36 @@ type:

.. code-block:: yaml

# app/config/config.yml
cmf_routing:
dynamic:
controllers_by_type:
editable: acme_main.controller:editableAction
editable: app.cms_controller:editableAction
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As best practices don't suggest using controllers as services, what about using AppBundle:Cms:editable here?


.. code-block:: xml


<?xml version="1.0" encoding="UTF-8" ?>
<!-- app/config/config.xml -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be before the doctype

<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">app.cms_controller:editableAction</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.yml
$container->loadFromExtension('cmf_routing', [
'dynamic' => [
'controllers_by_type' => [
'editable' => 'app.cms_controller:editableAction',
],
],
]);

controllers_by_class
....................
Expand All @@ -203,6 +205,7 @@ choose this controller to handle the request.

.. code-block:: yaml

# app/config/config.yml
cmf_routing:
dynamic:
controllers_by_class:
Expand All @@ -211,6 +214,7 @@ choose this controller to handle the request.
.. code-block:: xml

<?xml version="1.0" encoding="UTF-8" ?>
<!-- app/config/config.xml -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

<container xmlns="http://symfony.com/schema/dic/services">

<config xmlns="http://cmf.symfony.com/schema/dic/routing">
Expand All @@ -226,10 +230,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,6 +262,7 @@ setting is set as controller.

.. code-block:: yaml

# app/config/config.yml
cmf_routing:
dynamic:
templates_by_class:
Expand All @@ -264,7 +272,7 @@ setting is set as controller.

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

<!-- app/config/config.xml -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

<config xmlns="http://cmf.symfony.com/schema/dic/routing">
<dynamic>
<template-by-class
Expand All @@ -278,10 +286,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 @@ -325,8 +336,8 @@ disables the limit entirely.

.. code-block:: xml

<!-- app/config/config.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<!-- app/config/config.xml -->
<container xmlns="http://symfony.com/schema/dic/services">
<config xmlns="http://cmf.symfony.com/schema/dic/routing">
<dynamic>
Expand All @@ -349,24 +360,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 +482,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 @@ -514,7 +526,7 @@ priority.
cmf_routing:
dynamic:
route_filters_by_id:
acme_main.routing.foo_filter: 100
app.routing_filter: 100

.. code-block:: xml

Expand All @@ -524,21 +536,21 @@ priority.

<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,
),
),
));
$container->loadFromExtension('cmf_routing', [
'dynamic' => [
'route_filters_by_id' => [
'app.routing_filter' => 100,
],
],
]);

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

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

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

Expand Down
Loading