Skip to content

Commit 43fff9b

Browse files
committed
Merge branch '4.0'
* 4.0: fix web_profiler full default conf set allow_if_all_abstain to false [#9132] some minor tweaks Mention that hassers are supported in GetSetMethodNormalizer Mention the website-skeleton in the getting started guide add an alias for the profiler service Fixed wrong variable name Fixed typos in monolog_console Add missing allow_if_all_abstain parameter Explained how to build multiple configurations Fixed the import in the PHP Array Cache adapter article Update grammar mistake Mentioned how to override each children of a choice type Fix environment variable name Add a note about running Doctrine commands on Windows Update doctrine.rst Reworded and improved the routing/external_resources article Documented how to load routes from objects/services
2 parents 3c90085 + d1d9934 commit 43fff9b

File tree

15 files changed

+205
-60
lines changed

15 files changed

+205
-60
lines changed

configuration/environments.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ always run the application in the dev environment, independent of the
131131
argument to the ``Kernel`` constructor. This specifies if the application
132132
should run in "debug mode". Regardless of the environment, a Symfony
133133
application can be run with debug mode set to ``true`` or ``false``
134-
(respectively ``1`` or ``0`` for the ``APP_ENV`` variable defined in
134+
(respectively ``1`` or ``0`` for the ``APP_DEBUG`` variable defined in
135135
``.env``). This affects many things in the application, such as displaying
136136
stacktraces on error pages or if cache files are dynamically rebuilt on
137137
each request. Though not a requirement, debug mode is generally set to

controller/service.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Alternatives to base Controller Methods
8989
When using a controller defined as a service, you can still extend any of the
9090
:ref:`normal base controller <the-base-controller-class-services>` classes and
9191
use their shortcuts. But, you don't need to! You can choose to extend *nothing*,
92-
and use dependency injection to access difference services.
92+
and use dependency injection to access different services.
9393

9494
The base `Controller class source code`_ is a great way to see how to accomplish
9595
common tasks. For example, ``$this->render()`` is usually used to render a Twig

doctrine.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@ you can query the database directly:
370370
371371
$ php bin/console doctrine:query:sql 'SELECT * FROM product'
372372
373+
# on Windows systems not using Powershell, run this command instead:
374+
# php bin/console doctrine:query:sql "SELECT * FROM product"
375+
373376
Take a look at the previous example in more detail:
374377

375378
.. _doctrine-entity-manager:

form/create_custom_field_type.rst

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

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

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

frontend/encore/advanced-config.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,48 @@ But be careful not to accidentally override any config from Encore:
4040
// BAD - this replaces any extensions added by Encore
4141
// config.resolve.extensions = ['json'];
4242
43+
Defining Multiple Webpack Configurations
44+
----------------------------------------
45+
46+
Webpack supports passing an `array of configurations`_, which are processed in
47+
parallel. Webpack Encore includes a ``reset()`` object allowing to reset the
48+
state of the current configuration to build a new one:
49+
50+
.. code-block:: javascript
51+
52+
// define the first configuration
53+
Encore
54+
.setOutputPath('web/build/')
55+
.setPublicPath('/build')
56+
.addEntry('app', './assets/js/main.js')
57+
.addStyleEntry('global', './assets/css/global.scss')
58+
.enableSassLoader()
59+
.autoProvidejQuery()
60+
.enableSourceMaps(!Encore.isProduction())
61+
;
62+
63+
// build the first configuration
64+
const firstConfig = Encore.getWebpackConfig();
65+
66+
// reset Encore to build the second config
67+
Encore.reset();
68+
69+
// define the second configuration
70+
Encore
71+
.setOutputPath('web/build/')
72+
.setPublicPath('/build')
73+
.addEntry('mobile', './assets/js/mobile.js')
74+
.addStyleEntry('mobile', './assets/css/mobile.less')
75+
.enableLessLoader()
76+
.enableSourceMaps(!Encore.isProduction())
77+
;
78+
79+
// build the second configuration
80+
const secondConfig = Encore.getWebpackConfig();
81+
82+
// export the final configuration as an array of multiple configurations
83+
module.exports = [firstConfig, secondConfig];
84+
4385
.. _`configuration options`: https://webpack.js.org/configuration/
4486
.. _`Webpack's watchOptions`: https://webpack.js.org/configuration/watch/#watchoptions
87+
.. _`array of configurations`: https://github.com/webpack/docs/wiki/configuration#multiple-configurations

logging/monolog_console.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ current log level and the console verbosity.
3535
The example above could then be rewritten as::
3636

3737
use Psr\Log\LoggerInterface;
38+
use Symfony\Component\Console\Command\Command;
3839
use Symfony\Component\Console\Input\InputInterface;
3940
use Symfony\Component\Console\Output\OutputInterface;
4041
// ...
@@ -43,7 +44,7 @@ The example above could then be rewritten as::
4344
{
4445
private $logger;
4546

46-
public function __constructor(LoggerInterface $logger)
47+
public function __construct(LoggerInterface $logger)
4748
{
4849
$this->logger = $logger;
4950
}

profiler/matchers.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,35 @@ class in your controllers to manage the profiler programmatically::
2929
// ...
3030
}
3131
}
32+
33+
In order for the profiler to be injected into your controller you need to
34+
create an alias pointing to the existing ``profiler`` service:
35+
36+
.. configuration-block::
37+
38+
.. code-block:: yaml
39+
40+
# config/services.yaml
41+
services:
42+
Symfony\Component\HttpKernel\Profiler\Profiler: '@profiler'
43+
44+
.. code-block:: xml
45+
46+
<!-- config/services.xml -->
47+
<?xml version="1.0" encoding="UTF-8" ?>
48+
<container xmlns="http://symfony.com/schema/dic/services"
49+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
50+
xsi:schemaLocation="http://symfony.com/schema/dic/services
51+
http://symfony.com/schema/dic/services/services-1.0.xsd">
52+
53+
<services>
54+
<service id="Symfony\Component\HttpKernel\Profiler\Profiler" alias="profiler" />
55+
</services>
56+
</container>
57+
58+
.. code-block:: php
59+
60+
// config/services.php
61+
use Symfony\Component\HttpKernel\Profiler\Profiler;
62+
63+
$container->setAlias(Profiler::class, 'profiler');

quick_tour/the_architecture.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ Thanks to a new recipe installed by Flex, look at the ``.env`` file again:
298298
+ DATABASE_URL=mysql://db_user:[email protected]:3306/db_name
299299
+ ###< doctrine/doctrine-bundle ###
300300
301-
The new ``DATBASE_URL`` environment variable was added *automatically* and is already
301+
The new ``DATABASE_URL`` environment variable was added *automatically* and is already
302302
referenced by the new ``doctrine.yaml`` configuration file. By combining environment
303303
variables and Flex, you're using industry best practices without any extra effort.
304304

reference/configuration/web_profiler.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Full Default Configuration
6262
web_profiler:
6363
toolbar: false
6464
intercept_redirects: false
65-
excluded_ajax_paths: ^/bundles|^/_wdt
65+
excluded_ajax_paths: ^/(app(_[\\w]+)?\\.php/)?_wdt
6666
6767
.. code-block:: xml
6868
@@ -79,6 +79,6 @@ Full Default Configuration
7979
<web-profiler:config
8080
toolbar="false"
8181
intercept-redirects="false"
82-
excluded-ajax-paths="^/bundles|^/_wdt"
82+
excluded-ajax-paths="^/(app(_[\\w]+)?\\.php/)?_wdt"
8383
/>
8484
</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, YAML,
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: 47 additions & 49 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 ``config/routes.yaml``
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 ``config/routes.yaml`` (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
# config/routes.yaml
17-
controllers:
18-
resource: ../src/Controller/
19-
type: annotation
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
26+
resource: '../src/Controller/'
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,7 +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-
<import resource="../src/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="../src/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" />
3159
</routes>
3260
3361
.. code-block:: php
@@ -37,56 +65,26 @@ This can be done by "importing" directories into the routing configuration:
3765
3866
$collection = new RouteCollection();
3967
$collection->addCollection(
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
4072
$loader->import("../src/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")
4179
);
4280
4381
return $collection;
4482
4583
.. note::
4684

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

50-
The ``resource`` key loads the given routing resource. In this example the
51-
resource is a directory and all files in that directory are parsed and put into
52-
the routing.
53-
54-
.. note::
55-
56-
You can also include other routing configuration files:
57-
58-
.. configuration-block::
59-
60-
.. code-block:: yaml
61-
62-
# config/routes.yaml
63-
app:
64-
resource: '@ThirdPartyBundle/Resources/config/routing.yaml'
65-
66-
.. code-block:: xml
67-
68-
<!-- config/routes.xml -->
69-
<?xml version="1.0" encoding="UTF-8" ?>
70-
<routes xmlns="http://symfony.com/schema/routing"
71-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
72-
xsi:schemaLocation="http://symfony.com/schema/routing
73-
http://symfony.com/schema/routing/routing-1.0.xsd">
74-
75-
<import resource="@ThirdPartyBundle/Resources/config/routing.xml" />
76-
</routes>
77-
78-
.. code-block:: php
79-
80-
// config/routes.php
81-
use Symfony\Component\Routing\RouteCollection;
82-
83-
$collection = new RouteCollection();
84-
$collection->addCollection(
85-
$loader->import("@ThirdPartyBundle/Resources/config/routing.php")
86-
);
87-
88-
return $collection;
89-
9088
Prefixing Imported Routes
9189
~~~~~~~~~~~~~~~~~~~~~~~~~
9290

security/voters.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ security configuration:
293293
security:
294294
access_decision_manager:
295295
strategy: unanimous
296+
allow_if_all_abstain: false
296297
297298
.. code-block:: xml
298299
@@ -306,7 +307,7 @@ security configuration:
306307
>
307308
308309
<config>
309-
<access-decision-manager strategy="unanimous" />
310+
<access-decision-manager strategy="unanimous" allow-if-all-abstain="false" />
310311
</config>
311312
</srv:container>
312313
@@ -316,5 +317,6 @@ security configuration:
316317
$container->loadFromExtension('security', array(
317318
'access_decision_manager' => array(
318319
'strategy' => 'unanimous',
320+
'allow_if_all_abstain' => false,
319321
),
320322
));

0 commit comments

Comments
 (0)