Skip to content

Commit f817323

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: Simplified the contribution article for Symfony Docs Update routing.rst [#6590] fix version in versionadded directive Added note on YAML mappings as objects use static Yaml API Adding a description for the use_microseconds parameter introduced in MonologBundle v2.11 Clarify signed requests in the ESI renderer
2 parents c196b09 + e706ecf commit f817323

File tree

8 files changed

+222
-213
lines changed

8 files changed

+222
-213
lines changed

book/http_cache.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,12 @@ One great advantage of the ESI renderer is that you can make your application
12061206
as dynamic as needed and at the same time, hit the application as little as
12071207
possible.
12081208

1209+
.. caution::
1210+
1211+
The fragment listener only responds to signed requests. Requests are only
1212+
signed when using the fragment renderer and the ``render_esi`` Twig
1213+
function.
1214+
12091215
.. note::
12101216

12111217
Once you start using ESI, remember to always use the ``s-maxage``

components/yaml/introduction.rst

Lines changed: 24 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,20 @@ acts as a thin wrapper that simplifies common uses.
9595
Reading YAML Files
9696
~~~~~~~~~~~~~~~~~~
9797

98-
The :method:`Symfony\\Component\\Yaml\\Parser::parse` method parses a YAML
98+
The :method:`Symfony\\Component\\Yaml\\Yaml::parse` method parses a YAML
9999
string and converts it to a PHP array:
100100

101101
.. code-block:: php
102102
103-
use Symfony\Component\Yaml\Parser;
103+
use Symfony\Component\Yaml\Yaml;
104104
105-
$yaml = new Parser();
105+
$value = Yaml::parse(file_get_contents('/path/to/file.yml'));
106106
107-
$value = $yaml->parse(file_get_contents('/path/to/file.yml'));
107+
.. caution::
108+
109+
Because it is currently possible to pass a filename to this method, you
110+
must validate the input first. Passing a filename is deprecated in
111+
Symfony 2.2, and was removed in Symfony 3.0.
108112

109113
If an error occurs during parsing, the parser throws a
110114
:class:`Symfony\\Component\\Yaml\\Exception\\ParseException` exception
@@ -116,71 +120,49 @@ error occurred:
116120
use Symfony\Component\Yaml\Exception\ParseException;
117121
118122
try {
119-
$value = $yaml->parse(file_get_contents('/path/to/file.yml'));
123+
$value = Yaml::parse(file_get_contents('/path/to/file.yml'));
120124
} catch (ParseException $e) {
121125
printf("Unable to parse the YAML string: %s", $e->getMessage());
122126
}
123127
124-
.. tip::
125-
126-
As the parser is re-entrant, you can use the same parser object to load
127-
different YAML strings.
128-
129-
It may also be convenient to use the
130-
:method:`Symfony\\Component\\Yaml\\Yaml::parse` wrapper method:
131-
132-
.. code-block:: php
133-
134-
use Symfony\Component\Yaml\Yaml;
135-
136-
$yaml = Yaml::parse(file_get_contents('/path/to/file.yml'));
128+
.. _components-yaml-dump:
137129

138-
The :method:`Symfony\\Component\\Yaml\\Yaml::parse` static method takes a YAML
139-
string or a file containing YAML. Internally, it calls the
140-
:method:`Symfony\\Component\\Yaml\\Parser::parse` method, but enhances the
141-
error if something goes wrong by adding the filename to the message.
130+
Objects for Mappings
131+
....................
142132

143-
.. caution::
133+
.. versionadded:: 2.7
134+
Support for parsing mappings as objects was introduced in Symfony 2.7.
144135

145-
Because it is currently possible to pass a filename to this method, you
146-
must validate the input first. Passing a filename is deprecated in
147-
Symfony 2.2, and will be removed in Symfony 3.0.
136+
Yaml :ref:`mappings <yaml-format-collections>` are basically associative
137+
arrays. You can instruct the parser to return mappings as objects (i.e.
138+
``\stdClass`` instances) by setting the fourth argument to ``true``::
148139

149-
.. _components-yaml-dump:
140+
$object = Yaml::parse('{"foo": "bar"}', false, false, true);
141+
echo get_class($object); // stdClass
142+
echo $object->foo; // bar
150143

151144
Writing YAML Files
152145
~~~~~~~~~~~~~~~~~~
153146

154-
The :method:`Symfony\\Component\\Yaml\\Dumper::dump` method dumps any PHP
147+
The :method:`Symfony\\Component\\Yaml\\Yaml::dump` method dumps any PHP
155148
array to its YAML representation:
156149

157150
.. code-block:: php
158151
159-
use Symfony\Component\Yaml\Dumper;
152+
use Symfony\Component\Yaml\Yaml;
160153
161154
$array = array(
162155
'foo' => 'bar',
163156
'bar' => array('foo' => 'bar', 'bar' => 'baz'),
164157
);
165158
166-
$dumper = new Dumper();
167-
168-
$yaml = $dumper->dump($array);
159+
$yaml = Yaml::dump($array);
169160
170161
file_put_contents('/path/to/file.yml', $yaml);
171162
172163
If an error occurs during the dump, the parser throws a
173164
:class:`Symfony\\Component\\Yaml\\Exception\\DumpException` exception.
174165

175-
If you only need to dump one array, you can use the
176-
:method:`Symfony\\Component\\Yaml\\Yaml::dump` static method shortcut:
177-
178-
.. code-block:: php
179-
180-
use Symfony\Component\Yaml\Yaml;
181-
182-
$yaml = Yaml::dump($array);
183-
184166
Array Expansion and Inlining
185167
............................
186168

@@ -192,7 +174,7 @@ representation:
192174
193175
{ foo: bar, bar: { foo: bar, bar: baz } }
194176
195-
The second argument of the :method:`Symfony\\Component\\Yaml\\Dumper::dump`
177+
The second argument of the :method:`Symfony\\Component\\Yaml\\Yaml::dump`
196178
method customizes the level at which the output switches from the expanded
197179
representation to the inline one:
198180

components/yaml/yaml_format.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ YAML uses the ISO-8601 standard to express dates:
165165
# simple date
166166
2002-12-14
167167
168+
.. _yaml-format-collections:
169+
168170
Collections
169171
-----------
170172

0 commit comments

Comments
 (0)