Skip to content

Commit f04468a

Browse files
committed
Merge remote-tracking branch 'upstream/2.7' into 2.7
2 parents df5bbb7 + c347444 commit f04468a

File tree

11 files changed

+117
-49
lines changed

11 files changed

+117
-49
lines changed

components/filesystem.rst

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ exists
7979
~~~~~~
8080

8181
:method:`Symfony\\Component\\Filesystem\\Filesystem::exists` checks for the
82-
presence of all files or directories and returns ``false`` if a file is missing::
82+
presence of one or more files or directories and returns ``false`` if any of
83+
them is missing::
8384

8485
// this directory exists, return true
8586
$fs->exists('/tmp/photos');
8687

87-
// rabbit.jpg exists, bottle.png does not exists, return false
88+
// rabbit.jpg exists, bottle.png does not exist, return false
8889
$fs->exists(array('rabbit.jpg', 'bottle.png'));
8990

9091
.. note::
@@ -95,10 +96,11 @@ presence of all files or directories and returns ``false`` if a file is missing:
9596
copy
9697
~~~~
9798

98-
:method:`Symfony\\Component\\Filesystem\\Filesystem::copy` is used to copy
99-
files. If the target already exists, the file is copied only if the source
100-
modification date is later than the target. This behavior can be overridden by
101-
the third boolean argument::
99+
:method:`Symfony\\Component\\Filesystem\\Filesystem::copy` makes a copy of a
100+
single file (use :method:`Symfony\\Component\\Filesystem\\Filesystem::mirror` to
101+
copy directories). If the target already exists, the file is copied only if the
102+
source modification date is later than the target. This behavior can be overridden
103+
by the third boolean argument::
102104

103105
// works only if image-ICC has been modified after image.jpg
104106
$fs->copy('image-ICC.jpg', 'image.jpg');
@@ -128,8 +130,8 @@ your own with the second argument. The third argument is the access time::
128130
chown
129131
~~~~~
130132

131-
:method:`Symfony\\Component\\Filesystem\\Filesystem::chown` is used to change
132-
the owner of a file. The third argument is a boolean recursive option::
133+
:method:`Symfony\\Component\\Filesystem\\Filesystem::chown` changes the owner of
134+
a file. The third argument is a boolean recursive option::
133135

134136
// set the owner of the lolcat video to www-data
135137
$fs->chown('lolcat.mp4', 'www-data');
@@ -144,8 +146,8 @@ the owner of a file. The third argument is a boolean recursive option::
144146
chgrp
145147
~~~~~
146148

147-
:method:`Symfony\\Component\\Filesystem\\Filesystem::chgrp` is used to change
148-
the group of a file. The third argument is a boolean recursive option::
149+
:method:`Symfony\\Component\\Filesystem\\Filesystem::chgrp` changes the group of
150+
a file. The third argument is a boolean recursive option::
149151

150152
// set the group of the lolcat video to nginx
151153
$fs->chgrp('lolcat.mp4', 'nginx');
@@ -160,8 +162,8 @@ the group of a file. The third argument is a boolean recursive option::
160162
chmod
161163
~~~~~
162164

163-
:method:`Symfony\\Component\\Filesystem\\Filesystem::chmod` is used to change
164-
the mode of a file. The fourth argument is a boolean recursive option::
165+
:method:`Symfony\\Component\\Filesystem\\Filesystem::chmod` changes the mode or
166+
permissions of a file. The fourth argument is a boolean recursive option::
165167

166168
// set the mode of the video to 0600
167169
$fs->chmod('video.ogg', 0600);
@@ -176,8 +178,8 @@ the mode of a file. The fourth argument is a boolean recursive option::
176178
remove
177179
~~~~~~
178180

179-
:method:`Symfony\\Component\\Filesystem\\Filesystem::remove` is used to remove
180-
files, symlinks, directories easily::
181+
:method:`Symfony\\Component\\Filesystem\\Filesystem::remove` deletes files,
182+
directories and symlinks::
181183

182184
$fs->remove(array('symlink', '/path/to/directory', 'activity.log'));
183185

@@ -189,8 +191,8 @@ files, symlinks, directories easily::
189191
rename
190192
~~~~~~
191193

192-
:method:`Symfony\\Component\\Filesystem\\Filesystem::rename` is used to rename
193-
files and directories::
194+
:method:`Symfony\\Component\\Filesystem\\Filesystem::rename` changes the name
195+
of a single file or directory::
194196

195197
// rename a file
196198
$fs->rename('/tmp/processed_video.ogg', '/path/to/store/video_647.ogg');
@@ -213,8 +215,8 @@ support symbolic links, a third boolean argument is available::
213215
makePathRelative
214216
~~~~~~~~~~~~~~~~
215217

216-
:method:`Symfony\\Component\\Filesystem\\Filesystem::makePathRelative` returns
217-
the relative path of a directory given another one::
218+
:method:`Symfony\\Component\\Filesystem\\Filesystem::makePathRelative` takes two
219+
absolute paths and returns the relative path from the second path to the first one::
218220

219221
// returns '../'
220222
$fs->makePathRelative(
@@ -227,8 +229,10 @@ the relative path of a directory given another one::
227229
mirror
228230
~~~~~~
229231

230-
:method:`Symfony\\Component\\Filesystem\\Filesystem::mirror` mirrors a
231-
directory::
232+
:method:`Symfony\\Component\\Filesystem\\Filesystem::mirror` copies all the
233+
contents of the source directory into the target one (use the
234+
:method:`Symfony\\Component\\Filesystem\\Filesystem::copy` method to copy single
235+
files)::
232236

233237
$fs->mirror('/path/to/source', '/path/to/target');
234238

@@ -253,8 +257,8 @@ dumpFile
253257
.. versionadded:: 2.3
254258
The ``dumpFile()`` was introduced in Symfony 2.3.
255259

256-
:method:`Symfony\\Component\\Filesystem\\Filesystem::dumpFile` allows you to
257-
dump contents to a file. It does this in an atomic manner: it writes a temporary
260+
:method:`Symfony\\Component\\Filesystem\\Filesystem::dumpFile` saves the given
261+
contents into a file. It does this in an atomic manner: it writes a temporary
258262
file first and then moves it to the new file location when it's finished.
259263
This means that the user will always see either the complete old file or
260264
complete new file (but never a partially-written file)::

components/finder.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ the Finder instance.
5555
:phpfunction:`iterator_to_array` method, or get the number of items with
5656
:phpfunction:`iterator_count`.
5757

58+
.. caution::
59+
60+
The ``Finder`` object doesn't reset its internal state automatically.
61+
This means that you need to create a new instance if you do not want
62+
get mixed results.
63+
5864
.. caution::
5965

6066
When searching through multiple locations passed to the

console/command_in_controller.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ Run this command from inside your controller via::
4343

4444
$input = new ArrayInput(array(
4545
'command' => 'swiftmailer:spool:send',
46+
// (optional) define the value of command arguments
47+
'fooArgument' => 'barValue',
48+
// (optional) pass options to the command
4649
'--message-limit' => $messages,
4750
));
51+
4852
// You can use NullOutput() if you don't need the output
4953
$output = new BufferedOutput();
5054
$application->run($input, $output);

deployment/platformsh.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ In this guide, it is assumed your codebase is already versioned with Git.
1616
Get a Project on Platform.sh
1717
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1818

19-
You need to subscribe to a `Platform.sh project`_. Choose the development plan
20-
and go through the checkout process. Once your project is ready, give it a name
21-
and choose: **Import an existing site**.
19+
You need to `subscribe to a Platform.sh plan`_ and go through the checkout process.
20+
Once your project is ready, give it a name and choose: **Import an existing site**.
2221

2322
Prepare Your Application
2423
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -189,6 +188,7 @@ soon be able to see it in your browser.
189188
.. _`Platform.sh`: https://platform.sh
190189
.. _`Platform.sh documentation`: https://docs.platform.sh/frameworks/symfony.html
191190
.. _`Platform.sh project`: https://accounts.platform.sh/platform/buy-now
191+
.. _`subscribe to a Platform.sh plan`: https://accounts.platform.sh/platform/buy-now
192192
.. _`Platform.sh configuration files`: https://docs.platform.sh/configuration/services.html
193193
.. _`GitHub`: https://github.com/platformsh/platformsh-examples
194194
.. _`available services`: https://docs.platform.sh/reference/configuration-files/#configure-services

http_cache.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Nottingham's `Cache Tutorial`_.
3333
.. index::
3434
single: Cache; Proxy
3535
single: Cache; Reverse proxy
36-
single: Cache; Gateway
3736

3837
.. _gateway-caches:
3938

@@ -286,11 +285,15 @@ Safe Methods: Only caching GET or HEAD requests
286285
HTTP caching only works for "safe" HTTP methods (like GET and HEAD). This means
287286
two things:
288287

289-
* Don't try to cache PUT, POST or DELETE requests. It won't work and with good
290-
reason. These methods are meant to be used when mutating the state of your application
288+
* Don't try to cache PUT or DELETE requests. It won't work and with good reason.
289+
These methods are meant to be used when mutating the state of your application
291290
(e.g. deleting a blog post). Caching them would prevent certain requests from hitting
292291
and mutating your application.
293292

293+
* POST requests are generally considered uncachable, but `they can be cached`_
294+
when they include explicit freshness information. However POST caching is not
295+
widely implemented, so you should avoid it if possible.
296+
294297
* You should *never* change the state of your application (e.g. update a blog post)
295298
when responding to a GET or HEAD request. If those requests are cached, future
296299
requests may not actually hit your server.
@@ -366,3 +369,4 @@ Learn more
366369
.. _`RFC 7234 - Caching`: https://tools.ietf.org/html/rfc7234
367370
.. _`RFC 7232 - Conditional Requests`: https://tools.ietf.org/html/rfc7232
368371
.. _`FOSHttpCacheBundle`: http://foshttpcachebundle.readthedocs.org/
372+
.. _`they can be cached`: https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-20#section-2.3.4

page_creation.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ If you're returning HTML from your controller, you'll probably want to render
9494
a template. Fortunately, Symfony comes with `Twig`_: a templating language that's
9595
easy, powerful and actually quite fun.
9696

97-
First, make sure that ``LuckyController`` extends Symfony's base
98-
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller` class::
97+
First, import the base :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller`
98+
class as shown on line 5 below. Then, let your ``LuckyController`` class
99+
extend the base class::
99100

100101
// src/AppBundle/Controller/LuckyController.php
101102
// ...

reference/configuration/doctrine.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ Full Default Configuration
108108
# True to use a pooled server with the oci8 driver
109109
pooled: ~
110110
111-
# the version of your database engine
112-
server_version: ~
113-
114111
# Configuring MultipleActiveResultSets for the pdo_sqlsrv driver
115112
MultipleActiveResultSets: ~
116113

security/named_encoders.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,51 @@ the name of the encoder to use::
124124
return null; // use the default encoder
125125
}
126126
}
127+
128+
If you created your own password encoder implementing the
129+
:class:`Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface`,
130+
you must register a service for it in order to use it as a named encoder:
131+
132+
.. configuration-block::
133+
134+
.. code-block:: yaml
135+
136+
# app/config/security.yml
137+
security:
138+
# ...
139+
encoders:
140+
app_encoder:
141+
id: 'app.password_encoder_service'
142+
143+
.. code-block:: xml
144+
145+
<!-- app/config/security.xml -->
146+
<?xml version="1.0" encoding="UTF-8" ?>
147+
<srv:container xmlns="http://symfony.com/schema/dic/security"
148+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
149+
xmlns:srv="http://symfony.com/schema/dic/services"
150+
xsi:schemaLocation="http://symfony.com/schema/dic/services
151+
http://symfony.com/schema/dic/services/services-1.0.xsd"
152+
>
153+
154+
<config>
155+
<!-- ... -->
156+
<encoder class="app_encoder"
157+
id="app.password_encoder_service" />
158+
</config>
159+
</srv:container>
160+
161+
.. code-block:: php
162+
163+
// app/config/security.php
164+
$container->loadFromExtension('security', array(
165+
// ...
166+
'encoders' => array(
167+
'app_encoder' => array(
168+
'id' => 'app.password_encoder_service'
169+
),
170+
),
171+
));
172+
173+
This creates an encoder named ``app_encoder`` from a service named
174+
``app.password_encoder_service``.

service_container/parameters.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ and hidden with the service definition:
8080
.. code-block:: php
8181
8282
use AppBundle\Mailer;
83-
use Symfony\Component\DependencyInjection\Reference;
8483
8584
$container->setParameter('mailer.transport', 'sendmail');
8685

session/proxy_examples.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,22 @@ guest sessions.
8888
Encryption of Session Data
8989
--------------------------
9090

91-
If you wanted to encrypt the session data, you could use the proxy to encrypt
92-
and decrypt the session as required::
91+
If you want to encrypt the session data, you can use the proxy to encrypt and
92+
decrypt the session as required. The following example uses the `php-encryption`_
93+
library, but you can adapt it to any other library that you may be using::
9394

9495
// src/AppBundle/Session/EncryptedSessionProxy.php
9596
namespace AppBundle\Session;
9697

98+
use Defuse\Crypto\Crypto;
99+
use Defuse\Crypto\Key;
97100
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
98101

99102
class EncryptedSessionProxy extends SessionHandlerProxy
100103
{
101104
private $key;
102105

103-
public function __construct(\SessionHandlerInterface $handler, $key)
106+
public function __construct(\SessionHandlerInterface $handler, Key $key)
104107
{
105108
$this->key = $key;
106109

@@ -111,12 +114,12 @@ and decrypt the session as required::
111114
{
112115
$data = parent::read($id);
113116

114-
return mcrypt_decrypt(\MCRYPT_3DES, $this->key, $data);
117+
return Crypto::decrypt($data, $this->key);
115118
}
116119

117120
public function write($id, $data)
118121
{
119-
$data = mcrypt_encrypt(\MCRYPT_3DES, $this->key, $data);
122+
$data = Crypto::encrypt($data, $this->key);
120123

121124
return parent::write($id, $data);
122125
}
@@ -155,3 +158,5 @@ can intercept the session before it is written::
155158
return parent::write($id, $data);
156159
}
157160
}
161+
162+
.. _`php-encryption`: https://github.com/defuse/php-encryption

0 commit comments

Comments
 (0)