Skip to content

Commit 6d25dbb

Browse files
committed
Merge branch '2.8' into 3.3
* 2.8: (25 commits) [#8231] fix reStructuredText syntax Specified import order of config files [#7981] revert some changes Update upload_file.rst Added a missing redirection Update validation_group_service_resolver.rst Update redirection_map Update button_based_validation.rst Delete group_service_resolver.rst Create validation_group_service_resolver.rst [#8290] fix minor typo Update the setfacl description. Update events.rst Fixed a minor syntax issue Update phpunit_bridge.rst First parameter to uniqid must be a string fix #8321 minor changes in Serializer Component Update filesystem.rst Update associations.rst Update proxy_examples.rst ...
2 parents 9c13143 + 45f25a9 commit 6d25dbb

18 files changed

+63
-50
lines changed

_build/redirection_map

+6-5
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
/cookbook/upgrade/minor_version /setup/upgrade_major
263263
/cookbook/upgrade/patch_version /upgrade/bundles
264264
/cookbook/validation/custom_constraint /validation/custom_constraint
265-
/cookbook/validation/group_service_resolver /validation/group_service_resolver
265+
/cookbook/validation/group_service_resolver /form/validation_group_service_resolver
266266
/cookbook/validation/index /validation
267267
/cookbook/validation/severity /validation/severity
268268
/cookbook/web_server/built_in /setup/built_in_web_server
@@ -287,6 +287,7 @@
287287
/components/debug/introduction /components/debug
288288
/components/debug/index /components/debug
289289
/components/dependency_injection/advanced /service_container/alias_private
290+
/components/dependency_injection/autowiring /service_container/autowiring
290291
/components/dependency_injection/definitions /service_container/definitions
291292
/components/dependency_injection/introduction /components/dependency_injection
292293
/components/dependency_injection/index /components/dependency_injection
@@ -310,6 +311,7 @@
310311
/components/form/type_guesser /form/type_guesser
311312
/components/http_foundation/index /components/http_foundation
312313
/components/http_foundation/introduction /components/http_foundation
314+
/components/http_foundation/trusting_proxies /request/load_balancer_reverse_proxy
313315
/components/http_kernel/introduction /components/http_kernel
314316
/components/http_kernel/index /components/http_kernel
315317
/components/property_access/introduction /components/property_access
@@ -331,12 +333,11 @@
331333
/components/yaml/index /components/yaml
332334
/deployment/tools /deployment
333335
/install/bundles /setup/bundles
336+
/event_dispatcher/class_extension /event_dispatcher
334337
/form /forms
335338
/form/use_virtual_forms /form/inherit_data_option
336-
/testing/simulating_authentication /testing/http_authentication
337-
/components/dependency_injection/autowiring /service_container/autowiring
338-
/event_dispatcher/class_extension /event_dispatcher
339339
/security/target_path /security
340340
/service_container/third_party /service_container
341341
/templating/templating_service /templates
342-
/components/http_foundation/trusting_proxies /request/load_balancer_reverse_proxy
342+
/testing/simulating_authentication /testing/http_authentication
343+
/validation/group_service_resolver /form/validation_group_service_resolver

components/filesystem.rst

+8
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ On POSIX filesystems, directories are created with a default mode value
6464

6565
This function ignores already existing directories.
6666

67+
.. note::
68+
69+
The directory permissions are affected by the current `umask`_.
70+
Set the umask for your webserver, use PHP's :phpfunction:`umask`
71+
function or use the :phpfunction:`chmod` function after the
72+
directory has been created.
73+
6774
exists
6875
~~~~~~
6976

@@ -320,3 +327,4 @@ Learn More
320327
filesystem/*
321328

322329
.. _`Packagist`: https://packagist.org/packages/symfony/filesystem
330+
.. _`umask`: https://en.wikipedia.org/wiki/Umask

components/phpunit_bridge.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,14 @@ If you have this kind of time-related tests::
224224
sleep(10);
225225
$duration = $stopwatch->stop('event_name')->getDuration();
226226

227-
$this->assertEquals(10, $duration);
227+
$this->assertEquals(10000, $duration);
228228
}
229229
}
230230

231231
You used the :doc:`Symfony Stopwatch Component </components/stopwatch>` to
232232
calculate the duration time of your process, here 10 seconds. However, depending
233233
on the load of the server or the processes running on your local machine, the
234-
``$duration`` could for example be `10.000023s` instead of `10s`.
234+
``$duration`` could for example be ``10.000023s`` instead of ``10s``.
235235

236236
This kind of tests are called transient tests: they are failing randomly
237237
depending on spurious and external circumstances. They are often cause trouble

components/serializer.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,9 @@ and :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`::
418418
$obj->name = 'Acme Inc.';
419419
$obj->address = '123 Main Street, Big City';
420420

421-
$json = $serializer->serialize($obj);
421+
$json = $serializer->serialize($obj, 'json');
422422
// {"org_name": "Acme Inc.", "org_address": "123 Main Street, Big City"}
423-
$objCopy = $serializer->deserialize($json);
423+
$objCopy = $serializer->deserialize($json, Company::class, 'json');
424424
// Same data as $obj
425425

426426
.. _using-camelized-method-names-for-underscored-attributes:

controller/upload_file.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ automatically upload the file when persisting the entity::
329329
class BrochureUploadListener
330330
{
331331
private $uploader;
332+
private $fileName;
332333

333334
public function __construct(FileUploader $uploader)
334335
{
@@ -359,11 +360,10 @@ automatically upload the file when persisting the entity::
359360
$file = $entity->getBrochure();
360361

361362
// only upload new files
362-
if (!$file instanceof UploadedFile) {
363-
return;
363+
if ($file instanceof UploadedFile) {
364+
$fileName = $this->uploader->upload($file);
364365
}
365366

366-
$fileName = $this->uploader->upload($file);
367367
$entity->setBrochure($fileName);
368368
}
369369
}

deployment/platformsh.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,14 @@ following file (it's your role to add this file to your code base)::
126126
# Store session into /tmp.
127127
ini_set('session.save_path', '/tmp/sessions');
128128

129-
Make sure this file is listed in your *imports*:
129+
Make sure this file is listed in your *imports* (after the default ``parameters.yml``
130+
file):
130131

131132
.. code-block:: yaml
132133
133134
# app/config/config.yml
134135
imports:
136+
- { resource: parameters.yml }
135137
- { resource: parameters_platform.php }
136138
137139
Deploy your Application

doctrine/associations.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ When you need to fetch associated objects, your workflow looks just like it
273273
did before. First, fetch a ``$product`` object and then access its related
274274
``Category`` object::
275275

276-
use AppBundle\Entity\Post;
276+
use AppBundle\Entity\Product;
277277
// ...
278278

279279
public function showAction($productId)

form/button_based_validation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ large or whether you tried to submit text in a number field.
3636
.. seealso::
3737

3838
To see how to use a service to resolve ``validation_groups`` dynamically
39-
read the :doc:`/validation/group_service_resolver` article.
39+
read the :doc:`/form/validation_group_service_resolver` article.

form/create_custom_field_type.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ Using the Field Type
251251
You can now use your custom field type immediately, simply by creating a
252252
new instance of the type in one of your forms::
253253

254-
// src/AppBundle/Form/Type/AuthorType.php
254+
// src/AppBundle/Form/Type/OrderType.php
255255
namespace AppBundle\Form\Type;
256256

257257
use Symfony\Component\Form\AbstractType;

form/data_transformers.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Simple Example: Transforming String Tags from User Input to an Array
2323

2424
Suppose you have a Task form with a tags ``text`` type::
2525

26-
// src/AppBundle/Form/TaskType.php
26+
// src/AppBundle/Form/Type/TaskType.php
2727
namespace AppBundle\Form\Type;
2828

2929
use AppBundle\Entity\Task;
@@ -56,7 +56,7 @@ This is a *perfect* time to attach a custom data transformer to the ``tags``
5656
field. The easiest way to do this is with the :class:`Symfony\\Component\\Form\\CallbackTransformer`
5757
class::
5858

59-
// src/AppBundle/Form/TaskType.php
59+
// src/AppBundle/Form/Type/TaskType.php
6060
namespace AppBundle\Form\Type;
6161

6262
use Symfony\Component\Form\CallbackTransformer;
@@ -120,7 +120,7 @@ issue number.
120120

121121
Start by setting up the text field like normal::
122122

123-
// src/AppBundle/Form/TaskType.php
123+
// src/AppBundle/Form/Type/TaskType.php
124124
namespace AppBundle\Form\Type;
125125

126126
use AppBundle\Entity\Task;
@@ -250,7 +250,7 @@ Next, you need to use the ``IssueToNumberTransformer`` object inside if ``TaskTy
250250
and add it to the ``issue`` field. No problem! Just add a ``__construct()`` method
251251
and type-hint the new class::
252252

253-
// src/AppBundle/Form/TaskType.php
253+
// src/AppBundle/Form/Type/TaskType.php
254254
namespace AppBundle\Form\Type;
255255

256256
use AppBundle\Form\DataTransformer\IssueToNumberTransformer;
@@ -374,7 +374,7 @@ have the data transformer *and* a nice default value for the ``invalid_message``
374374
As long as you're using :ref:`autowire <services-autowire>` and
375375
:ref:`autoconfigure <services-autoconfigure>`, you can start using the form immediately::
376376

377-
// src/AppBundle/Form/TaskType.php
377+
// src/AppBundle/Form/Type/TaskType.php
378378
namespace AppBundle\Form\Type;
379379

380380
use AppBundle\Form\DataTransformer\IssueToNumberTransformer;

form/dynamic_form_modification.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Customizing the Form Type
260260
Now that you have all the basics in place you can take advantage of the ``TokenStorageInterface``
261261
and fill in the listener logic::
262262

263-
// src/AppBundle/FormType/FriendMessageFormType.php
263+
// src/AppBundle/Form/Type/FriendMessageFormType.php
264264

265265
use AppBundle\Entity\User;
266266
use Doctrine\ORM\EntityRepository;

form/events.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ callback for better readability::
304304

305305
use Symfony\Component\Form\Extension\Core\Type\TextType;
306306
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
307+
use Symfony\Component\Form\FormEvent;
307308
use Symfony\Component\Form\FormEvents;
308309

309310
// ...
@@ -391,9 +392,9 @@ Event subscribers have different uses:
391392
392393
To register the event subscriber, use the ``addEventSubscriber()`` method::
393394

395+
use AppBundle\Form\EventListener\AddEmailFieldListener;
394396
use Symfony\Component\Form\Extension\Core\Type\TextType;
395397
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
396-
use AppBundle\Form\EventListener\AddEmailFieldListener;
397398

398399
// ...
399400

validation/group_service_resolver.rst renamed to form/validation_group_service_resolver.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
How to Dynamically Configure Validation Groups
2-
==============================================
1+
How to Dynamically Configure Form Validation Groups
2+
===================================================
33

44
Sometimes you need advanced logic to determine the validation groups. If they
55
can't be determined by a simple callback, you can use a service. Create a
@@ -47,7 +47,7 @@ Then in your form, inject the resolver and set it as the ``validation_groups``.
4747
namespace AppBundle\Form;
4848
4949
use AppBundle\Validator\ValidationGroupResolver;
50-
use Symfony\Component\Form\AbstractType;
50+
use Symfony\Component\Form\AbstractType
5151
use Symfony\Component\OptionsResolver\OptionsResolver;
5252
5353
class MyClassType extends AbstractType

logging/processors.rst

+19-19
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ using a processor.
1818

1919
.. code-block:: php
2020
21-
namespace AppBundle;
21+
namespace AppBundle\Logger;
2222
2323
use Symfony\Component\HttpFoundation\Session\SessionInterface;
2424
2525
class SessionRequestProcessor
2626
{
2727
private $session;
28-
private $token;
28+
private $sessionId;
2929
3030
public function __construct(SessionInterface $session)
3131
{
@@ -34,15 +34,15 @@ using a processor.
3434
3535
public function processRecord(array $record)
3636
{
37-
if (null === $this->token) {
38-
try {
39-
$this->token = substr($this->session->getId(), 0, 8);
40-
} catch (\RuntimeException $e) {
41-
$this->token = '????????';
42-
}
43-
$this->token .= '-' . substr(uniqid(), -8);
37+
if (!$this->session->isStarted()) {
38+
return $record;
4439
}
45-
$record['extra']['token'] = $this->token;
40+
41+
if (!$this->sessionId) {
42+
$this->sessionId = substr($this->session->getId(), 0, 8) ?: '????????';
43+
}
44+
45+
$record['extra']['token'] = $this->sessionId.'-'.substr(uniqid('', true), -8);
4646
4747
return $record;
4848
}
@@ -62,7 +62,7 @@ information:
6262
arguments:
6363
- "[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%\n"
6464
65-
AppBundle\SessionRequestProcessor:
65+
AppBundle\Logger\SessionRequestProcessor:
6666
autowire: true
6767
tags:
6868
- { name: monolog.processor, method: processRecord }
@@ -86,7 +86,7 @@ information:
8686
<argument>[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%&#xA;</argument>
8787
</service>
8888
89-
<service id="AppBundle\SessionRequestProcessor" autowire="true">
89+
<service id="AppBundle\Logger\SessionRequestProcessor" autowire="true">
9090
<tag name="monolog.processor" method="processRecord" />
9191
</service>
9292
</services>
@@ -95,7 +95,7 @@ information:
9595
.. code-block:: php
9696
9797
// app/config/services.php
98-
use AppBundle\SessionRequestProcessor;
98+
use AppBundle\Logger\SessionRequestProcessor;
9999
use Monolog\Formatter\LineFormatter;
100100
101101
$container
@@ -139,7 +139,7 @@ Finally, set the formatter to be used on whatever handler you want:
139139
type="stream"
140140
path="%kernel.logs_dir%/%kernel.environment%.log"
141141
level="debug"
142-
formatter="monolog.formatter.session_request"
142+
formatter="app.logger.session_request_processor"
143143
/>
144144
</monolog:config>
145145
</container>
@@ -153,7 +153,7 @@ Finally, set the formatter to be used on whatever handler you want:
153153
'type' => 'stream',
154154
'path' => '%kernel.logs_dir%/%kernel.environment%.log',
155155
'level' => 'debug',
156-
'formatter' => 'monolog.formatter.session_request',
156+
'formatter' => 'app.logger.session_request_processor',
157157
),
158158
),
159159
));
@@ -174,7 +174,7 @@ the ``monolog.processor`` tag:
174174
175175
# app/config/config.yml
176176
services:
177-
AppBundle\SessionRequestProcessor:
177+
AppBundle\Logger\SessionRequestProcessor:
178178
autowire: true
179179
tags:
180180
- { name: monolog.processor, method: processRecord, handler: main }
@@ -192,7 +192,7 @@ the ``monolog.processor`` tag:
192192
http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
193193
194194
<services>
195-
<service id="AppBundle\SessionRequestProcessor" autowire="true">
195+
<service id="AppBundle\Logger\SessionRequestProcessor" autowire="true">
196196
<tag name="monolog.processor" method="processRecord" handler="main" />
197197
</service>
198198
</services>
@@ -219,7 +219,7 @@ the ``monolog.processor`` tag:
219219
220220
# app/config/config.yml
221221
services:
222-
AppBundle\SessionRequestProcessor:
222+
AppBundle\Logger\SessionRequestProcessor:
223223
autowire: true
224224
tags:
225225
- { name: monolog.processor, method: processRecord, channel: main }
@@ -237,7 +237,7 @@ the ``monolog.processor`` tag:
237237
http://symfony.com/schema/dic/monolog/monolog-1.0.xsd">
238238
239239
<services>
240-
<service id="AppBundle\SessionRequestProcessor" autowire="true">
240+
<service id="AppBundle\Logger\SessionRequestProcessor" autowire="true">
241241
<tag name="monolog.processor" method="processRecord" channel="main" />
242242
</service>
243243
</services>

security/entity_provider.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ For this entry, suppose that you already have a ``User`` entity inside an
8383
{
8484
$this->isActive = true;
8585
// may not be needed, see section on salt below
86-
// $this->salt = md5(uniqid(null, true));
86+
// $this->salt = md5(uniqid('', true));
8787
}
8888

8989
public function getUsername()

security/impersonating_user.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ to show a link to exit impersonation:
101101
</a>
102102
<?php endif ?>
103103

104-
In some cases you may need to get the object that represents the impersonating
104+
In some cases you may need to get the object that represents the impersonator
105105
user rather than the impersonated user. Use the following snippet to iterate
106106
over the user's roles until you find one that a ``SwitchUserRole`` object::
107107

@@ -113,7 +113,7 @@ over the user's roles until you find one that a ``SwitchUserRole`` object::
113113
if ($authChecker->isGranted('ROLE_PREVIOUS_ADMIN')) {
114114
foreach ($tokenStorage->getToken()->getRoles() as $role) {
115115
if ($role instanceof SwitchUserRole) {
116-
$impersonatingUser = $role->getSource()->getUser();
116+
$impersonatorUser = $role->getSource()->getUser();
117117
break;
118118
}
119119
}

session/proxy_examples.rst

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Symfony to use your session handler instead of the default one:
3333
<?xml version="1.0" encoding="UTF-8" ?>
3434
<container xmlns="http://symfony.com/schema/dic/services"
3535
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
36+
xmlns:framework="http://symfony.com/schema/dic/symfony"
3637
xsi:schemaLocation="http://symfony.com/schema/dic/services
3738
http://symfony.com/schema/dic/services/services-1.0.xsd">
3839

0 commit comments

Comments
 (0)