Skip to content

Commit 9671b95

Browse files
committed
Merge remote-tracking branch 'origin/2.7' into 2.7
* origin/2.7: (51 commits) Avoid backticks in shell scripts Update optional_dependencies.rst Fix xml blocks [#7875] minor tweaks Minor fix Minor changes [#7773] fix line length Add helpful remarks on custom DataCollector Remove use of deprecated security.exception_listener.class parameter Update resources.rst Fix incoherent ut8mb4 collation in Doctrine setup Fix decorating service definition fix empty XML element [#7873] add missing toctree entries Reworded the introduction of the contributing docs [#7844] add XML and PHP config examples Property access [HttpFoundation] Fix clearstatcache first arg Explain how to provide a stack trace fix remaining setDefinition() call ...
2 parents 4fa4f4f + 6c8ca7c commit 9671b95

File tree

123 files changed

+1680
-1033
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1680
-1033
lines changed

_includes/service_container/_my_mailer.rst.inc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828

2929
// app/config/services.php
3030
use AppBundle\Mailer;
31-
use Symfony\Component\DependencyInjection\Definition;
3231

33-
$container->setDefinition('app.mailer', new Definition(
34-
Mailer::class,
35-
array('sendmail')
36-
));
32+
$container->register('app.mailer', Mailer::class)
33+
->addArgument('sendmail');

bundles/best_practices.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,17 @@ The end user can provide values in any configuration file:
348348
.. code-block:: xml
349349
350350
<!-- app/config/config.xml -->
351-
<parameters>
352-
<parameter key="acme_blog.author.email">[email protected]</parameter>
353-
</parameters>
351+
<?xml version="1.0" encoding="UTF-8" ?>
352+
<container xmlns="http://symfony.com/schema/dic/services"
353+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
354+
xsi:schemaLocation="http://symfony.com/schema/dic/services
355+
http://symfony.com/schema/dic/services/services-1.0.xsd">
356+
357+
<parameters>
358+
<parameter key="acme_blog.author.email">[email protected]</parameter>
359+
</parameters>
360+
361+
</container>
354362
355363
.. code-block:: php
356364

bundles/configuration.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ thrown)::
225225
$configuration = new Configuration();
226226

227227
$config = $this->processConfiguration($configuration, $configs);
228-
228+
229229
// you now have these 2 config keys
230230
// $config['twitter']['client_id'] and $config['twitter']['client_secret']
231231
}
@@ -424,7 +424,6 @@ Assuming the XSD file is called ``hello-1.0.xsd``, the schema location will be
424424
425425
<!-- app/config/config.xml -->
426426
<?xml version="1.0" ?>
427-
428427
<container xmlns="http://symfony.com/schema/dic/services"
429428
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
430429
xmlns:acme-hello="http://acme_company.com/schema/dic/hello"

bundles/prepend_extension.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ users to choose to remove functionality they are not using. Creating multiple
1212
bundles has the drawback that configuration becomes more tedious and settings
1313
often need to be repeated for various bundles.
1414

15-
It is possible to remove the disadvantage of the multiple bundle approach
15+
It is possible to remove the disadvantage of the multiple bundle approach
1616
by enabling a single Extension to prepend the settings for any bundle.
1717
It can use the settings defined in the ``app/config/config.yml``
1818
to prepend settings just as if they had been written explicitly by
@@ -116,11 +116,21 @@ The above would be the equivalent of writing the following into the
116116
.. code-block:: xml
117117
118118
<!-- app/config/config.xml -->
119-
<acme-something:config use-acme-goodbye="false">
120-
<acme-something:entity-manager-name>non_default</acme-something:entity-manager-name>
121-
</acme-something:config>
119+
<?xml version="1.0" encoding="UTF-8" ?>
120+
<container xmlns="http://symfony.com/schema/dic/services"
121+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
122+
xmlns:acme-something="http://example.org/schema/dic/acme_something"
123+
xmlns:acme-other="http://example.org/schema/dic/acme_other"
124+
xsi:schemaLocation="http://symfony.com/schema/dic/services
125+
http://symfony.com/schema/dic/services/services-1.0.xsd">
122126
123-
<acme-other:config use-acme-goodbye="false" />
127+
<acme-something:config use-acme-goodbye="false">
128+
<acme-something:entity-manager-name>non_default</acme-something:entity-manager-name>
129+
</acme-something:config>
130+
131+
<acme-other:config use-acme-goodbye="false" />
132+
133+
</container>
124134
125135
.. code-block:: php
126136

components/event_dispatcher.rst

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ answer.
2222
Consider the real-world example where you want to provide a plugin system
2323
for your project. A plugin should be able to add methods, or do something
2424
before or after a method is executed, without interfering with other plugins.
25-
This is not an easy problem to solve with single inheritance, and even if
25+
This is not an easy problem to solve with single inheritance, and even if
2626
multiple inheritance was possible with PHP, it comes with its own drawbacks.
2727

2828
The Symfony EventDispatcher component implements the `Mediator`_ pattern
@@ -198,7 +198,6 @@ determine which instance is passed.
198198
to tag services as event listeners::
199199

200200
use Symfony\Component\DependencyInjection\ContainerBuilder;
201-
use Symfony\Component\DependencyInjection\Definition;
202201
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
203202
use Symfony\Component\DependencyInjection\Reference;
204203
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
@@ -208,23 +207,19 @@ determine which instance is passed.
208207
$containerBuilder->addCompilerPass(new RegisterListenersPass());
209208

210209
// register the event dispatcher service
211-
$containerBuilder->setDefinition('event_dispatcher', new Definition(
212-
ContainerAwareEventDispatcher::class,
213-
array(new Reference('service_container'))
214-
));
210+
$containerBuilder->register('event_dispatcher', ContainerAwareEventDispatcher::class)
211+
->addArgument(new Reference('service_container'));
215212

216213
// register your event listener service
217-
$listener = new Definition(\AcmeListener::class);
218-
$listener->addTag('kernel.event_listener', array(
219-
'event' => 'acme.foo.action',
220-
'method' => 'onFooAction',
221-
));
222-
$containerBuilder->setDefinition('listener_service_id', $listener);
214+
$containerBuilder->register('listener_service_id', \AcmeListener::class)
215+
->addTag('kernel.event_listener', array(
216+
'event' => 'acme.foo.action',
217+
'method' => 'onFooAction',
218+
));
223219

224220
// register an event subscriber
225-
$subscriber = new Definition(\AcmeSubscriber::class);
226-
$subscriber->addTag('kernel.event_subscriber');
227-
$containerBuilder->setDefinition('subscriber_service_id', $subscriber);
221+
$containerBuilder->register('subscriber_service_id', \AcmeSubscriber::class)
222+
->addTag('kernel.event_subscriber');
228223

229224
By default, the listeners pass assumes that the event dispatcher's service
230225
id is ``event_dispatcher``, that event listeners are tagged with the
@@ -441,7 +436,7 @@ EventDispatcher Aware Events and Listeners
441436
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
442437

443438
The ``EventDispatcher`` always passes the dispatched event, the event's
444-
name and a reference to itself to the listeners. This can lead to some advanced
439+
name and a reference to itself to the listeners. This can lead to some advanced
445440
applications of the ``EventDispatcher`` including dispatching other events inside
446441
listeners, chaining events or even lazy loading listeners into the dispatcher object.
447442

components/http_foundation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ Please note that this will not work when the ``X-Sendfile`` header is set.
533533

534534
If you *just* created the file during this same request, the file *may* be sent
535535
without any content. This may be due to cached file stats that return zero for
536-
the size of the file. To fix this issue, call ``clearstatcache(false, $file)``
536+
the size of the file. To fix this issue, call ``clearstatcache(true, $file)``
537537
with the path to the binary file.
538538

539539
.. _component-http-foundation-json-response:

components/options_resolver.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ the ``Mailer`` class makes a mistake?
9898
.. code-block:: php
9999
100100
$mailer = new Mailer(array(
101-
'usernme' => 'johndoe', // usernAme misspelled
101+
'usernme' => 'johndoe', // usernme misspelled (instead of username)
102102
));
103103
104104
No error will be shown. In the best case, the bug will appear during testing,

components/property_access.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,23 +259,31 @@ can use setters, the magic ``__set()`` method or properties to set values::
259259
$this->lastName = $name;
260260
}
261261

262+
public function getLastName()
263+
{
264+
return $this->lastName;
265+
}
266+
267+
public function getChildren()
268+
{
269+
return $this->children;
270+
}
271+
262272
public function __set($property, $value)
263273
{
264274
$this->$property = $value;
265275
}
266-
267-
// ...
268276
}
269277

270278
$person = new Person();
271279

272280
$accessor->setValue($person, 'firstName', 'Wouter');
273-
$accessor->setValue($person, 'lastName', 'de Jong');
274-
$accessor->setValue($person, 'children', array(new Person()));
281+
$accessor->setValue($person, 'lastName', 'de Jong'); // setLastName is called
282+
$accessor->setValue($person, 'children', array(new Person())); // __set is called
275283

276284
var_dump($person->firstName); // 'Wouter'
277285
var_dump($person->getLastName()); // 'de Jong'
278-
var_dump($person->children); // array(Person());
286+
var_dump($person->getChildren()); // array(Person());
279287

280288
You can also use ``__call()`` to set values but you need to enable the feature,
281289
see `Enable other Features`_.

components/validator/resources.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ In this example, the validation metadata is retrieved executing the
4545
public static function loadValidatorMetadata(ClassMetadata $metadata)
4646
{
4747
$metadata->addPropertyConstraint('name', new Assert\NotBlank());
48-
$metadata->addPropertyConstraint('name', new Asert\Length(array(
48+
$metadata->addPropertyConstraint('name', new Assert\Length(array(
4949
'min' => 5,
5050
'max' => 20,
5151
)));

configuration/environments.rst

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,22 @@ accomplished easily and transparently:
6969
7070
.. code-block:: xml
7171
72-
<imports>
73-
<import resource="config.xml" />
74-
</imports>
72+
<?xml version="1.0" encoding="UTF-8" ?>
73+
<container xmlns="http://symfony.com/schema/dic/services"
74+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
75+
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
76+
xsi:schemaLocation="http://symfony.com/schema/dic/services
77+
http://symfony.com/schema/dic/services/services-1.0.xsd
78+
http://symfony.com/schema/dic/doctrine
79+
http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
7580
76-
<!-- ... -->
81+
<imports>
82+
<import resource="config.xml" />
83+
</imports>
84+
85+
<!-- ... -->
86+
87+
</container>
7788
7889
.. code-block:: php
7990
@@ -104,11 +115,22 @@ configuration file:
104115
.. code-block:: xml
105116
106117
<!-- app/config/config_dev.xml -->
107-
<imports>
108-
<import resource="config.xml" />
109-
</imports>
118+
<?xml version="1.0" encoding="UTF-8" ?>
119+
<container xmlns="http://symfony.com/schema/dic/services"
120+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
121+
xmlns:webprofiler="http://symfony.com/schema/dic/webprofiler"
122+
xsi:schemaLocation="http://symfony.com/schema/dic/services
123+
http://symfony.com/schema/dic/services/services-1.0.xsd
124+
http://symfony.com/schema/dic/webprofiler
125+
http://symfony.com/schema/dic/webprofiler/webprofiler-1.0.xsd">
126+
127+
<imports>
128+
<import resource="config.xml" />
129+
</imports>
130+
131+
<webprofiler:config toolbar="true" />
110132
111-
<webprofiler:config toolbar="true" />
133+
</container>
112134
113135
.. code-block:: php
114136
@@ -201,7 +223,18 @@ this code and changing the environment string.
201223
202224
.. code-block:: xml
203225
204-
<doctrine:dbal logging="%kernel.debug%" />
226+
<?xml version="1.0" encoding="UTF-8" ?>
227+
<container xmlns="http://symfony.com/schema/dic/services"
228+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
229+
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
230+
xsi:schemaLocation="http://symfony.com/schema/dic/services
231+
http://symfony.com/schema/dic/services/services-1.0.xsd
232+
http://symfony.com/schema/dic/doctrine
233+
http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
234+
235+
<doctrine:dbal logging="%kernel.debug%" />
236+
237+
</container>
205238
206239
.. code-block:: php
207240
@@ -283,13 +316,24 @@ The best way to accomplish this is via a new environment called, for example,
283316
.. code-block:: xml
284317
285318
<!-- app/config/config_benchmark.xml -->
286-
<imports>
287-
<import resource="config_prod.xml" />
288-
</imports>
289-
290-
<framework:config>
291-
<framework:profiler only-exceptions="false" />
292-
</framework:config>
319+
<?xml version="1.0" encoding="UTF-8" ?>
320+
<container xmlns="http://symfony.com/schema/dic/services"
321+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
322+
xmlns:framework="http://symfony.com/schema/dic/symfony"
323+
xsi:schemaLocation="http://symfony.com/schema/dic/services
324+
http://symfony.com/schema/dic/services/services-1.0.xsd
325+
http://symfony.com/schema/dic/symfony
326+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
327+
328+
<imports>
329+
<import resource="config_prod.xml" />
330+
</imports>
331+
332+
<framework:config>
333+
<framework:profiler only-exceptions="false" />
334+
</framework:config>
335+
336+
</container>
293337
294338
.. code-block:: php
295339

configuration/external_parameters.rst

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,26 @@ You can now reference these parameters wherever you need them.
103103
104104
.. code-block:: xml
105105
106-
<!-- xmlns:doctrine="http://symfony.com/schema/dic/doctrine" -->
107-
<!-- xsi:schemaLocation="http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd"> -->
108-
109-
<doctrine:config>
110-
<doctrine:dbal
111-
driver="pdo_mysql"
112-
dbname="symfony_project"
113-
user="%database.user%"
114-
password="%database.password%"
115-
/>
116-
</doctrine:config>
106+
<!-- app/config/config.xml -->
107+
<?xml version="1.0" encoding="UTF-8" ?>
108+
<container xmlns="http://symfony.com/schema/dic/services"
109+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
110+
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
111+
xsi:schemaLocation="http://symfony.com/schema/dic/services
112+
http://symfony.com/schema/dic/services/services-1.0.xsd
113+
http://symfony.com/schema/dic/doctrine
114+
http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
115+
116+
<doctrine:config>
117+
<doctrine:dbal
118+
driver="pdo_mysql"
119+
dbname="symfony_project"
120+
user="%database.user%"
121+
password="%database.password%"
122+
/>
123+
</doctrine:config>
124+
125+
</container>
117126
118127
.. code-block:: php
119128
@@ -150,9 +159,17 @@ in the container. The following imports a file named ``parameters.php``.
150159
.. code-block:: xml
151160
152161
<!-- app/config/config.xml -->
153-
<imports>
154-
<import resource="parameters.php" />
155-
</imports>
162+
<?xml version="1.0" encoding="UTF-8" ?>
163+
<container xmlns="http://symfony.com/schema/dic/services"
164+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
165+
xsi:schemaLocation="http://symfony.com/schema/dic/services
166+
http://symfony.com/schema/dic/services/services-1.0.xsd">
167+
168+
<imports>
169+
<import resource="parameters.php" />
170+
</imports>
171+
172+
</container>
156173
157174
.. code-block:: php
158175

0 commit comments

Comments
 (0)