Skip to content

Commit 0a5af6d

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: fix(doc): typo Tweaks [Validator] Advanced Validation Group Provider Minor formating Reword Renaming W3C to HTML5... Minor tweak Tweaks Add note about indexing config classes [DI] Add note about testing service locators tip to not follow redirects when testing mailer link symfony default style on coloring documentation
2 parents c3a8aac + d94690a commit 0a5af6d

File tree

7 files changed

+122
-8
lines changed

7 files changed

+122
-8
lines changed

configuration.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,12 @@ namespace ``Symfony\Config``::
12831283
Nested configs (e.g. ``\Symfony\Config\Framework\CacheConfig``) are regular
12841284
PHP objects which aren't autowired when using them as an argument type.
12851285

1286+
.. note::
1287+
1288+
In order to get ConfigBuilders autocompletion in your IDE/editor, make sure
1289+
to not exclude the directory where these classes are generated (by default,
1290+
in ``var/cache/dev/Symfony/Config/``).
1291+
12861292
Keep Going!
12871293
-----------
12881294

console/coloring.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
How to Color and Style the Console Output
22
=========================================
33

4-
By using colors in the command output, you can distinguish different types of
5-
output (e.g. important messages, titles, comments, etc.).
4+
Symfony provides an optional :doc:`console style </console/style>` to render the
5+
input and output of commands in a consistent way. If you prefer to apply your
6+
own style, use the utilities explained in this article to show colors in the command
7+
output (e.g. to differentiate between important messages, titles, comments, etc.).
68

79
.. note::
810

frontend/asset_mapper.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The AssetMapper component has two main features:
1717
* :ref:`Importmaps <importmaps-javascript>`: A native browser feature that makes it easier
1818
to use the JavaScript ``import`` statement (e.g. ``import { Modal } from 'bootstrap'``)
1919
without a build system. It's supported in all browsers (thanks to a shim)
20-
and is a `W3C standard <https://html.spec.whatwg.org/multipage/webappapis.html#import-maps>`_.
20+
and is part of the `HTML5 standard <https://html.spec.whatwg.org/multipage/webappapis.html#import-maps>`_.
2121

2222
Installation
2323
------------
@@ -80,15 +80,16 @@ the file, the version part of the URL will change automatically!
8080
Serving Assets in dev vs prod
8181
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8282

83-
In the ``dev`` environment, the URL - ``/assets/images/duck-3c16d9220694c0e56d8648f25e6035e9.png``
84-
is handled and returned by your Symfony app. For the ``prod`` environment, before
85-
deploy, you should run:
83+
In the ``dev`` environment, the URL ``/assets/images/duck-3c16d9220694c0e56d8648f25e6035e9.png``
84+
is handled and returned by your Symfony app.
85+
86+
For the ``prod`` environment, before deploy, you should run:
8687

8788
.. code-block:: terminal
8889
8990
$ php bin/console asset-map:compile
9091
91-
This will physically copy all the files from your mapped directories into
92+
This will physically copy all the files from your mapped directories to
9293
``public/assets/`` so that they're served directly by your web server.
9394
See :ref:`Deployment <asset-mapper-deployment>` for more details.
9495

mailer.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,13 @@ the :class:`Symfony\\Bundle\\FrameworkBundle\\Test\\MailerAssertionsTrait`::
18071807
}
18081808
}
18091809

1810+
.. tip::
1811+
1812+
If your controller returns a redirect response after sending the email, make
1813+
sure to have your client *not* follow redirects. The kernel is rebooted after
1814+
following the redirection and the message will be lost from the mailer event
1815+
handler.
1816+
18101817
.. _`Amazon SES`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Mailer/Bridge/Amazon/README.md
18111818
.. _`App Password`: https://support.google.com/accounts/answer/185833
18121819
.. _`Brevo`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Mailer/Bridge/Brevo/README.md

security/remember_me.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ present:
235235
.. image:: /_images/security/profiler-badges.png
236236
:alt: The Security page of the Symfony profiler, with the "Authenticators" tab showing the remember me badge in the passport object.
237237

238-
Without this badge, remember me will be not be activated (regardless of all
238+
Without this badge, remember me will not be activated (regardless of all
239239
other settings).
240240

241241
Add Remember Me Support to Custom Authenticators

service_container/service_subscribers_locators.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,15 @@ To unit test a service subscriber, you can create a fake container::
10041004
$serviceSubscriber = new MyService($container);
10051005
// ...
10061006

1007+
.. note::
1008+
1009+
When defining the service locator like this, beware that the
1010+
:method:`Symfony\\Contracts\\Service\\ServiceLocatorTrait::getProvidedServices`
1011+
of your container will use the return type of the closures as the values of the
1012+
returned array. If no return type is defined, the value will be ``?``. If you
1013+
want the values to reflect the classes of your services, the return type has
1014+
to be set on your closures.
1015+
10071016
Another alternative is to mock it using ``PHPUnit``::
10081017

10091018
use Psr\Container\ContainerInterface;

validation/sequence_provider.rst

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,95 @@ provides a sequence of groups to be validated:
344344
}
345345
}
346346
347+
Advanced Validation Group Provider
348+
----------------------------------
349+
350+
In the previous section, you learned how to change the sequence of groups
351+
dynamically based on the state of your entity. However, in more advanced cases
352+
you might need to use some external configuration or service to define that
353+
sequence of groups.
354+
355+
Managing the entity initialization and manually setting its dependencies can
356+
be cumbersome, and the implementation might not align with the entity
357+
responsibilities. To solve this, you can configure the implementation of the
358+
:class:`Symfony\\Component\\Validator\\GroupProviderInterface` outside of the
359+
entity, and even register the group provider as a service.
360+
361+
Here's how you can achieve this:
362+
363+
1) **Define a Separate Group Provider Class:** create a class that implements
364+
the :class:`Symfony\\Component\\Validator\\GroupProviderInterface`
365+
and handles the dynamic group sequence logic;
366+
2) **Configure the User with the Provider:** use the ``provider`` option within
367+
the :class:`Symfony\\Component\\Validator\\Constraints\\GroupSequenceProvider`
368+
attribute to link the entity with the provider class;
369+
3) **Autowiring or Manual Tagging:** if :doc:` autowiring </service_container/autowiring>`
370+
is enabled, your custom provider will be automatically linked. Otherwise, you must
371+
:doc:`tag your service </service_container/tags>` manually with the ``validator.group_provider`` tag.
372+
373+
.. configuration-block::
374+
375+
.. code-block:: php-attributes
376+
377+
// src/Entity/User.php
378+
namespace App\Entity;
379+
380+
// ...
381+
use App\Validator\UserGroupProvider;
382+
383+
#[Assert\GroupSequenceProvider(provider: UserGroupProvider::class)]
384+
class User
385+
{
386+
// ...
387+
}
388+
389+
.. code-block:: yaml
390+
391+
# config/validator/validation.yaml
392+
App\Entity\User:
393+
group_sequence_provider: App\Validator\UserGroupProvider
394+
395+
.. code-block:: xml
396+
397+
<!-- config/validator/validation.xml -->
398+
<?xml version="1.0" encoding="UTF-8" ?>
399+
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
400+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
401+
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
402+
https://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">
403+
404+
<class name="App\Entity\User">
405+
<group-sequence-provider>
406+
<value>App\Validator\UserGroupProvider</value>
407+
</group-sequence-provider>
408+
<!-- ... -->
409+
</class>
410+
</constraint-mapping>
411+
412+
.. code-block:: php
413+
414+
// src/Entity/User.php
415+
namespace App\Entity;
416+
417+
// ...
418+
use App\Validator\UserGroupProvider;
419+
use Symfony\Component\Validator\Mapping\ClassMetadata;
420+
421+
class User
422+
{
423+
// ...
424+
425+
public static function loadValidatorMetadata(ClassMetadata $metadata): void
426+
{
427+
$metadata->setGroupProvider(UserGroupProvider::class);
428+
$metadata->setGroupSequenceProvider(true);
429+
// ...
430+
}
431+
}
432+
433+
With this approach, you can maintain a clean separation between the entity
434+
structure and the group sequence logic, allowing for more advanced use cases.
435+
347436
How to Sequentially Apply Constraints on a Single Property
348437
----------------------------------------------------------
349438

0 commit comments

Comments
 (0)