Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ab4de02

Browse filesBrowse files
committed
Universally show _defaults when important
1 parent 58e694f commit ab4de02
Copy full SHA for ab4de02

File tree

5 files changed

+69
-31
lines changed
Filter options

5 files changed

+69
-31
lines changed

‎controller/argument_value_resolver.rst

Copy file name to clipboardExpand all lines: controller/argument_value_resolver.rst
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,12 @@ and adding a priority.
150150
151151
# app/config/services.yml
152152
services:
153+
_defaults:
154+
# ... be sure autowiring is enabled
155+
autowire: true
153156
# ...
154157
155158
AppBundle\ArgumentResolver\UserValueResolver:
156-
# arguments is not needed if you have autowire above under _defaults
157159
tags:
158160
- { name: controller.argument_value_resolver, priority: 50 }
159161
@@ -164,9 +166,12 @@ and adding a priority.
164166
<container xmlns="http://symfony.com/schema/dic/services"
165167
xmlns:xsi="'http://www.w3.org/2001/XMLSchema-Instance"
166168
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
167-
<!-- ... -->
168169
169170
<services>
171+
<!-- ... be sure autowiring is enabled -->
172+
<defaults autowire="true" ... />
173+
<!-- ... -->
174+
170175
<service id="AppBundle\ArgumentResolver\UserValueResolver">
171176
<tag name="controller.argument_value_resolver" priority="50" />
172177
</service>

‎controller/error_pages.rst

Copy file name to clipboardExpand all lines: controller/error_pages.rst
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,13 @@ In that case, you might want to override one or both of the ``showAction()`` and
269269
270270
# app/config/services.yml
271271
services:
272+
_defaults:
273+
# ... be sure autowiring is enabled
274+
autowire: true
272275
# ...
273276
274277
AppBundle\Controller\CustomExceptionController:
278+
public: true
275279
arguments:
276280
$debug: '%kernel.debug%'
277281
@@ -284,9 +288,11 @@ In that case, you might want to override one or both of the ``showAction()`` and
284288
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"
285289
>
286290
<services>
291+
<!-- ... be sure autowiring is enabled -->
292+
<defaults autowire="true" ... />
287293
<!-- ... -->
288294
289-
<service id="AppBundle\Controller\CustomExceptionController">
295+
<service id="AppBundle\Controller\CustomExceptionController" public="true">
290296
<argument key="$debug">%kernel.debug%</argument>
291297
</service>
292298
</services>

‎controller/soap_web_service.rst

Copy file name to clipboardExpand all lines: controller/soap_web_service.rst
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ Standard Edition), this is easy:
6161
# app/config/services.yml
6262
services:
6363
_defaults:
64-
# ...
65-
# be sure autowiring is enabled
64+
# ... be sure autowiring is enabled
6665
autowire: true
66+
# ...
6767
6868
# add Service/ to the list of directories to load services from
6969
AppBundle\:
@@ -79,7 +79,9 @@ Standard Edition), this is easy:
7979
http://symfony.com/schema/dic/services/services-1.0.xsd">
8080
8181
<services>
82+
<!-- ... be sure autowiring is enabled -->
8283
<defaults autowire="true" ... />
84+
<!-- ... -->
8385
8486
<!-- add Service/ to the list of directories to load services from -->
8587
<prototype namespace="AppBundle\" resource="../../src/AppBundle/{Service,Updates,Command,Form,EventSubscriber,Twig,Security}" />

‎controller/upload_file.rst

Copy file name to clipboardExpand all lines: controller/upload_file.rst
+10-6Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ Now, register this class as a Doctrine listener:
380380
# app/config/services.yml
381381
services:
382382
_defaults:
383-
# make sure you have autowire enabled
383+
# ... be sure autowiring is enabled
384384
autowire: true
385385
# ...
386386
@@ -398,12 +398,16 @@ Now, register this class as a Doctrine listener:
398398
xsi:schemaLocation="http://symfony.com/schema/dic/services
399399
http://symfony.com/schema/dic/services/services-1.0.xsd"
400400
>
401-
<!-- ... -->
401+
<services>
402+
<!-- ... be sure autowiring is enabled -->
403+
<defaults autowire="true" ... />
404+
<!-- ... -->
402405
403-
<service id="AppBundle\EventListener\BrochureUploaderListener">
404-
<tag name="doctrine.event_listener" event="prePersist"/>
405-
<tag name="doctrine.event_listener" event="preUpdate"/>
406-
</service>
406+
<service id="AppBundle\EventListener\BrochureUploaderListener">
407+
<tag name="doctrine.event_listener" event="prePersist"/>
408+
<tag name="doctrine.event_listener" event="preUpdate"/>
409+
</service>
410+
</services>
407411
</container>
408412
409413
.. code-block:: php

‎doctrine/pdo_session_storage.rst

Copy file name to clipboardExpand all lines: doctrine/pdo_session_storage.rst
+41-20Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@ multiple web server environment.
1111

1212
Symfony has a built-in solution for database session storage called
1313
:class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\PdoSessionHandler`.
14-
To use it, you just need to change some parameters in the main configuration file:
14+
To use it, first register a new handler service:
1515

1616
.. configuration-block::
1717

1818
.. code-block:: yaml
1919
2020
# app/config/config.yml
21-
framework:
22-
session:
23-
# ...
24-
handler_id: session.handler.pdo
25-
2621
services:
27-
session.handler.pdo:
28-
class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
22+
# ...
23+
24+
Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
2925
public: false
3026
arguments:
3127
- 'mysql:dbname=mydatabase'
@@ -34,12 +30,10 @@ To use it, you just need to change some parameters in the main configuration fil
3430
.. code-block:: xml
3531
3632
<!-- app/config/config.xml -->
37-
<framework:config>
38-
<framework:session handler-id="session.handler.pdo" cookie-lifetime="3600" auto-start="true"/>
39-
</framework:config>
40-
4133
<services>
42-
<service id="session.handler.pdo" class="Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler" public="false">
34+
<!-- ... -->
35+
36+
<service id="Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler" public="false">
4337
<argument>mysql:dbname=mydatabase</argument>
4438
<argument type="collection">
4539
<argument key="db_username">myuser</argument>
@@ -51,22 +45,49 @@ To use it, you just need to change some parameters in the main configuration fil
5145
.. code-block:: php
5246
5347
// app/config/config.php
48+
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
49+
50+
$storageDefinition = $container->register(PdoSessionHandler::class)
51+
->setArguments(array(
52+
'mysql:dbname=mydatabase',
53+
array('db_username' => 'myuser', 'db_password' => 'mypassword')
54+
))
55+
;
56+
57+
Next, tell Symfony to use your service as the session handler:
58+
59+
.. configuration-block::
60+
61+
.. code-block:: yaml
62+
63+
# app/config/config.yml
64+
framework:
65+
session:
66+
# ...
67+
handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
68+
69+
.. code-block:: xml
70+
71+
<!-- app/config/config.xml -->
72+
<framework:config>
73+
<!-- ... -->
74+
<framework:session handler-id="Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler" cookie-lifetime="3600" auto-start="true"/>
75+
</framework:config>
76+
77+
.. code-block:: php
78+
79+
// app/config/config.php
80+
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
5481
5582
// ...
5683
$container->loadFromExtension('framework', array(
5784
// ...
5885
'session' => array(
5986
// ...
60-
'handler_id' => 'session.handler.pdo',
87+
'handler_id' => PdoSessionHandler::class,
6188
),
6289
));
6390
64-
$storageDefinition = new Definition(PdoSessionHandler::class, array(
65-
'mysql:dbname=mydatabase',
66-
array('db_username' => 'myuser', 'db_password' => 'mypassword')
67-
));
68-
$container->setDefinition('session.handler.pdo', $storageDefinition);
69-
7091
Configuring the Table and Column Names
7192
--------------------------------------
7293

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.