Skip to content

Commit 2fae4b4

Browse files
committed
Merge branch '2.8' into 3.3
* 2.8: fix web_profiler full default conf set allow_if_all_abstain to false Add missing allow_if_all_abstain parameter Mentioned how to override each children of a choice type Reworded and improved the routing/external_resources article Documented how to load routes from objects/services
2 parents 8e086fe + 1a9b93c commit 2fae4b4

File tree

5 files changed

+110
-56
lines changed

5 files changed

+110
-56
lines changed

form/create_custom_field_type.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ link for details), create a ``shipping_widget`` block to handle this:
156156
<?php echo $view['form']->renderBlock('choice_widget') ?>
157157
<?php endif ?>
158158

159+
.. tip::
160+
161+
You can further customize the template used to render each children of the
162+
choice type. The block to override in that case is named "block name" +
163+
``_entry`` + "element name" (``label``, ``errors`` or ``widget``) (e.g. to
164+
customize the labels of the children of the Shipping widget you'd need to
165+
define ``{% block shipping_entry_label %} ... {% endblock %}``).
166+
159167
.. note::
160168

161169
Make sure the correct widget prefix is used. In this example the name should

reference/configuration/web_profiler.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Full Default Configuration
8181
toolbar: false
8282
position: bottom
8383
intercept_redirects: false
84-
excluded_ajax_paths: ^/bundles|^/_wdt
84+
excluded_ajax_paths: ^/(app(_[\\w]+)?\\.php/)?_wdt
8585
8686
# DEPRECATED, it can be removed safely from your configuration
8787
verbose: true
@@ -102,6 +102,6 @@ Full Default Configuration
102102
toolbar="false"
103103
verbose="true"
104104
intercept-redirects="false"
105-
excluded-ajax-paths="^/bundles|^/_wdt"
105+
excluded-ajax-paths="^/(app(_[\\w]+)?\\.php/)?_wdt"
106106
/>
107107
</container>

routing/custom_route_loader.rst

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,57 @@ containing :class:`Symfony\\Component\\Routing\\Route` objects.
5959
when they are defined in one of the default formats (e.g. XML, YML,
6060
PHP file).
6161

62+
Loading Routes with a Custom Service
63+
------------------------------------
64+
65+
.. versionadded:: 2.8
66+
The option to load routes using Symfony services was introduced in Symfony 2.8.
67+
68+
Using a regular Symfony service is the simplest way to load routes in a
69+
customized way. It's much easier than creating a full custom route loader, so
70+
you should always consider this option first.
71+
72+
To do so, define ``type: service`` as the type of the loaded routing resource
73+
and configure the service and method to call:
74+
75+
.. configuration-block::
76+
77+
.. code-block:: yaml
78+
79+
# app/config/routing.yml
80+
admin_routes:
81+
resource: 'admin_route_loader:loadRoutes'
82+
type: service
83+
84+
.. code-block:: xml
85+
86+
<!-- app/config/routing.xml -->
87+
<?xml version="1.0" encoding="UTF-8" ?>
88+
<routes xmlns="http://symfony.com/schema/routing"
89+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
90+
xsi:schemaLocation="http://symfony.com/schema/routing
91+
http://symfony.com/schema/routing/routing-1.0.xsd">
92+
93+
<import resource="admin_route_loader:loadRoutes" type="service"/>
94+
</routes>
95+
96+
.. code-block:: php
97+
98+
// app/config/routing.php
99+
use Symfony\Component\Routing\RouteCollection;
100+
101+
$collection = new RouteCollection();
102+
$collection->addCollection(
103+
$loader->import("admin_route_loader:loadRoutes", "service")
104+
);
105+
106+
return $collection;
107+
108+
In this example, the routes are loaded by calling the ``loadRoutes()`` method of
109+
the service whose ID is ``admin_route_loader``. Your service doesn't have to
110+
extend or implement any special class, but the called method must return a
111+
:class:`Symfony\\Component\\Routing\\RouteCollection` object.
112+
62113
Creating a custom Loader
63114
------------------------
64115

routing/external_resources.rst

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,37 @@
44
How to Include External Routing Resources
55
=========================================
66

7-
All routes are loaded via a single configuration file - usually ``app/config/routing.yml``
8-
(see :ref:`routing-creating-routes`). However, if you use routing annotations,
9-
you'll need to point the router to the controllers with the annotations.
10-
This can be done by "importing" directories into the routing configuration:
7+
Simple applications can define all their routes in a single configuration file -
8+
usually ``app/config/routing.yml`` (see :ref:`routing-creating-routes`).
9+
However, in most applications it's common to import routes definitions from
10+
different resources: PHP annotations in controller files, YAML or XML files
11+
stored in some directory, etc.
12+
13+
This can be done by importing routing resources from the main routing file:
1114

1215
.. configuration-block::
1316

1417
.. code-block:: yaml
1518
1619
# app/config/routing.yml
17-
app:
20+
app_file:
21+
# loads routes from the given routing file stored in some bundle
22+
resource: '@AcmeOtherBundle/Resources/config/routing.yml'
23+
24+
app_annotations:
25+
# loads routes from the PHP annotations of the controllers found in that directory
1826
resource: '@AppBundle/Controller/'
19-
type: annotation # required to enable the Annotation reader for this resource
27+
type: annotation
28+
29+
app_directory:
30+
# loads routes from the YAML or XML files found in that directory
31+
resource: '../legacy/routing/'
32+
type: directory
33+
34+
app_bundle:
35+
# loads routes from the YAML or XML files found in some bundle directory
36+
resource: '@AppBundle/Resources/config/routing/public/'
37+
type: directory
2038
2139
.. code-block:: xml
2240
@@ -27,8 +45,17 @@ This can be done by "importing" directories into the routing configuration:
2745
xsi:schemaLocation="http://symfony.com/schema/routing
2846
http://symfony.com/schema/routing/routing-1.0.xsd">
2947
30-
<!-- the type is required to enable the annotation reader for this resource -->
31-
<import resource="@AppBundle/Controller/" type="annotation"/>
48+
<!-- loads routes from the given routing file stored in some bundle -->
49+
<import resource="@AcmeOtherBundle/Resources/config/routing.yml" />
50+
51+
<!-- loads routes from the PHP annotations of the controllers found in that directory -->
52+
<import resource="@AppBundle/Controller/" type="annotation" />
53+
54+
<!-- loads routes from the YAML or XML files found in that directory -->
55+
<import resource="../legacy/routing/" type="directory" />
56+
57+
<!-- loads routes from the YAML or XML files found in some bundle directory -->
58+
<import resource="@AppBundle/Resources/config/routing/public/" type="directory" />
3259
</routes>
3360
3461
.. code-block:: php
@@ -38,60 +65,26 @@ This can be done by "importing" directories into the routing configuration:
3865
3966
$collection = new RouteCollection();
4067
$collection->addCollection(
41-
// second argument is the type, which is required to enable
42-
// the annotation reader for this resource
68+
// loads routes from the given routing file stored in some bundle
69+
$loader->import("@AcmeOtherBundle/Resources/config/routing.yml")
70+
71+
// loads routes from the PHP annotations of the controllers found in that directory
4372
$loader->import("@AppBundle/Controller/", "annotation")
73+
74+
// loads routes from the YAML or XML files found in that directory
75+
$loader->import("../legacy/routing/", "directory")
76+
77+
// loads routes from the YAML or XML files found in some bundle directory
78+
$loader->import("@AppBundle/Resources/config/routing/public/", "directory")
4479
);
4580
4681
return $collection;
4782
4883
.. note::
4984

50-
When importing resources from YAML, the key (e.g. ``app``) is meaningless.
85+
When importing resources from YAML, the key (e.g. ``app_file``) is meaningless.
5186
Just be sure that it's unique so no other lines override it.
5287

53-
The ``resource`` key loads the given routing resource. In this example the
54-
resource is a directory, where the ``@AppBundle`` shortcut syntax resolves
55-
to the full path of the AppBundle. When pointing to a directory, all files
56-
in that directory are parsed and put into the routing.
57-
58-
.. note::
59-
60-
You can also include other routing configuration files, this is often
61-
used to import the routing of third party bundles:
62-
63-
.. configuration-block::
64-
65-
.. code-block:: yaml
66-
67-
# app/config/routing.yml
68-
app:
69-
resource: '@AcmeOtherBundle/Resources/config/routing.yml'
70-
71-
.. code-block:: xml
72-
73-
<!-- app/config/routing.xml -->
74-
<?xml version="1.0" encoding="UTF-8" ?>
75-
<routes xmlns="http://symfony.com/schema/routing"
76-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
77-
xsi:schemaLocation="http://symfony.com/schema/routing
78-
http://symfony.com/schema/routing/routing-1.0.xsd">
79-
80-
<import resource="@AcmeOtherBundle/Resources/config/routing.xml" />
81-
</routes>
82-
83-
.. code-block:: php
84-
85-
// app/config/routing.php
86-
use Symfony\Component\Routing\RouteCollection;
87-
88-
$collection = new RouteCollection();
89-
$collection->addCollection(
90-
$loader->import("@AcmeOtherBundle/Resources/config/routing.php")
91-
);
92-
93-
return $collection;
94-
9588
Prefixing Imported Routes
9689
~~~~~~~~~~~~~~~~~~~~~~~~~
9790

security/voters.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ security configuration:
295295
security:
296296
access_decision_manager:
297297
strategy: unanimous
298+
allow_if_all_abstain: false
298299
299300
.. code-block:: xml
300301
@@ -308,7 +309,7 @@ security configuration:
308309
>
309310
310311
<config>
311-
<access-decision-manager strategy="unanimous" />
312+
<access-decision-manager strategy="unanimous" allow-if-all-abstain="false" />
312313
</config>
313314
</srv:container>
314315
@@ -318,5 +319,6 @@ security configuration:
318319
$container->loadFromExtension('security', array(
319320
'access_decision_manager' => array(
320321
'strategy' => 'unanimous',
322+
'allow_if_all_abstain' => false,
321323
),
322324
));

0 commit comments

Comments
 (0)