Skip to content

Commit 3a753d3

Browse files
committed
Merge remote-tracking branch 'upstream/7.0' into 7.0
* upstream/7.0: Fix table length - - Rename Service name Remove obsolete versionadded directive [Form] Document using TranslatableMessage in form Fields [#19122] Reword - - [Workflow] feature symfony#50604 metadata dumping [Bundle] add tip for marking internal services as hidden [DependencyInjection] Mention `exclude_self` minor Update serverVersion for MariaDB Update console.rst Fix custom form type docs. [Security] Migrate to ConfigBuilder format for 6.3+ [SecurityBundle] Improve support for authenticators that don't need a user provider
2 parents b04a833 + 103241d commit 3a753d3

File tree

13 files changed

+179
-49
lines changed

13 files changed

+179
-49
lines changed
Loading

bundles/best_practices.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,13 @@ can be used for autowiring.
476476
Services should not use autowiring or autoconfiguration. Instead, all services should
477477
be defined explicitly.
478478

479+
.. tip::
480+
481+
If there is no intention for the service id to be used by the end user, you can
482+
mark it as *hidden* by prefixing it with a dot (e.g. ``.acme_blog.logger``).
483+
This prevents the service from being listed in the default ``debug:container``
484+
command output.
485+
479486
.. seealso::
480487

481488
You can learn much more about service loading in bundles reading this article:

console.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@ console::
489489
{
490490
public function testExecute(): void
491491
{
492-
$kernel = self::bootKernel();
493-
$application = new Application($kernel);
492+
self::bootKernel();
493+
$application = new Application(self::$kernel);
494494

495495
$command = $application->find('app:create-user');
496496
$commandTester = new CommandTester($command);

doctrine.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ The database connection information is stored as an environment variable called
4444
DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7"
4545
4646
# to use mariadb:
47-
DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=mariadb-10.5.8"
47+
# Before doctrine/dbal < 3.7
48+
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=mariadb-10.5.8"
49+
# Since doctrine/dbal 3.7
50+
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=10.5.8-MariaDB"
4851
4952
# to use sqlite:
5053
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db"

form/create_custom_field_type.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,8 @@ fragments used to render the types:
363363
364364
{# ... here you will add the Twig code ... #}
365365
366-
Then, update the :ref:`form_themes option <reference-twig-tag-form-theme>` to
367-
add this new template at the beginning of the list (the first one overrides the
368-
rest of files):
366+
Then, update the :ref:`form_themes option <config-twig-form-themes>` to
367+
add this new template at the end of the list (each theme overrides all the previous ones):
369368

370369
.. configuration-block::
371370

@@ -374,8 +373,8 @@ rest of files):
374373
# config/packages/twig.yaml
375374
twig:
376375
form_themes:
377-
- 'form/custom_types.html.twig'
378376
- '...'
377+
- 'form/custom_types.html.twig'
379378
380379
.. code-block:: xml
381380
@@ -390,8 +389,8 @@ rest of files):
390389
https://symfony.com/schema/dic/twig/twig-1.0.xsd">
391390
392391
<twig:config>
393-
<twig:form-theme>form/custom_types.html.twig</twig:form-theme>
394392
<twig:form-theme>...</twig:form-theme>
393+
<twig:form-theme>form/custom_types.html.twig</twig:form-theme>
395394
</twig:config>
396395
</container>
397396
@@ -402,8 +401,8 @@ rest of files):
402401
403402
return static function (TwigConfig $twig): void {
404403
$twig->formThemes([
405-
'form/custom_types.html.twig',
406404
'...',
405+
'form/custom_types.html.twig',
407406
]);
408407
};
409408

mailer.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,17 @@ Using a 3rd Party Transport
9999
Instead of using your own SMTP server or sendmail binary, you can send emails
100100
via a third-party provider:
101101

102-
===================== ==============================================
102+
===================== ===============================================
103103
Service Install with
104-
===================== ==============================================
104+
===================== ===============================================
105105
`Amazon SES`_ ``composer require symfony/amazon-mailer``
106106
`Brevo`_ ``composer require symfony/brevo-mailer``
107107
`Infobip`_ ``composer require symfony/infobip-mailer``
108-
`Mailchimp Mandrill`_ ``composer require symfony/mailchimp-mailer``
109108
`Mailgun`_ ``composer require symfony/mailgun-mailer``
110109
`Mailjet`_ ``composer require symfony/mailjet-mailer``
111110
`MailPace`_ ``composer require symfony/mail-pace-mailer``
112111
`MailerSend`_ ``composer require symfony/mailer-send-mailer``
112+
`Mandrill`_ ``composer require symfony/mailchimp-mailer``
113113
`Postmark`_ ``composer require symfony/postmark-mailer``
114114
`Scaleway`_ ``composer require symfony/scaleway-mailer``
115115
`SendGrid`_ ``composer require symfony/sendgrid-mailer``
@@ -1826,8 +1826,8 @@ the :class:`Symfony\\Bundle\\FrameworkBundle\\Test\\MailerAssertionsTrait`::
18261826
.. _`Inky`: https://get.foundation/emails/docs/inky.html
18271827
.. _`league/html-to-markdown`: https://github.com/thephpleague/html-to-markdown
18281828
.. _`load balancing`: https://en.wikipedia.org/wiki/Load_balancing_(computing)
1829-
.. _`Mailchimp Mandrill`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Mailer/Bridge/Mailchimp/README.md
18301829
.. _`MailerSend`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Mailer/Bridge/MailerSend/README.md
1830+
.. _`Mandrill`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Mailer/Bridge/Mailchimp/README.md
18311831
.. _`Mailgun`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Mailer/Bridge/Mailgun/README.md
18321832
.. _`Mailjet`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Mailer/Bridge/Mailjet/README.md
18331833
.. _`Markdown syntax`: https://commonmark.org/

rate_limiter.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ the :class:`Symfony\\Component\\RateLimiter\\Reservation` object returned by the
348348
$limit = $limiter->consume();
349349
$headers = [
350350
'X-RateLimit-Remaining' => $limit->getRemainingTokens(),
351-
'X-RateLimit-Retry-After' => $limit->calculateTimeForTokens(1, 1),
351+
'X-RateLimit-Retry-After' => $limit->getRetryAfter()->getTimestamp() - time(),
352352
'X-RateLimit-Limit' => $limit->getLimit(),
353353
];
354354

reference/configuration/security.rst

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -479,25 +479,21 @@ user logs out::
479479
.. code-block:: php
480480
481481
// config/packages/security.php
482-
$container->loadFromExtension('security', [
482+
483+
// ...
484+
485+
return static function (SecurityConfig $securityConfig): void {
483486
// ...
484-
'firewalls' => [
485-
'main' => [
486-
'logout' => [
487-
'delete_cookies' => [
488-
'cookie1-name' => null,
489-
'cookie2-name' => [
490-
'path' => '/',
491-
],
492-
'cookie3-name' => [
493-
'path' => null,
494-
'domain' => 'example.com',
495-
],
496-
],
497-
],
498-
],
499-
],
500-
]);
487+
488+
$securityConfig->firewall('main')
489+
->logout()
490+
->deleteCookie('cookie1-name')
491+
->deleteCookie('cookie2-name')
492+
->path('/')
493+
->deleteCookie('cookie3-name')
494+
->path(null)
495+
->domain('example.com');
496+
};
501497
502498
503499
clear_site_data
@@ -554,19 +550,16 @@ It's also possible to use ``*`` as a wildcard for all directives:
554550
.. code-block:: php
555551
556552
// config/packages/security.php
557-
$container->loadFromExtension('security', [
553+
554+
// ...
555+
556+
return static function (SecurityConfig $securityConfig): void {
558557
// ...
559-
'firewalls' => [
560-
'main' => [
561-
'logout' => [
562-
'clear-site-data' => [
563-
'cookies',
564-
'storage',
565-
],
566-
],
567-
],
568-
],
569-
]);
558+
559+
$securityConfig->firewall('main')
560+
->logout()
561+
->clearSiteData(['cookies', 'storage']);
562+
};
570563
571564
invalidate_session
572565
..................
@@ -1020,6 +1013,8 @@ multiple firewalls, the "context" could actually be shared:
10201013
ignored and you won't be able to authenticate on multiple firewalls at the
10211014
same time.
10221015

1016+
.. _reference-security-stateless:
1017+
10231018
stateless
10241019
~~~~~~~~~
10251020

reference/forms/types/options/button_label.rst.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
``label``
22
~~~~~~~~~
33

4-
**type**: ``string`` **default**: The label is "guessed" from the field name
4+
**type**: ``string`` or ``TranslatableMessage`` **default**: The label is "guessed" from the field name
55

66
Sets the label that will be displayed on the button. The label can also
77
be directly set inside the template:

reference/forms/types/options/placeholder.rst.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
``placeholder``
22
~~~~~~~~~~~~~~~
33

4-
**type**: ``string`` or ``boolean``
4+
**type**: ``string`` or ``TranslatableMessage`` or ``boolean``
55

66
This option determines whether or not a special "empty" option (e.g. "Choose
77
an option") will appear at the top of a select widget. This option only
@@ -14,6 +14,9 @@ applies if the ``multiple`` option is set to false.
1414

1515
$builder->add('states', ChoiceType::class, [
1616
'placeholder' => 'Choose an option',
17+
18+
// or if you want to translate the text
19+
'placeholder' => new TranslatableMessage('form.placeholder.select_option', [], 'form'),
1720
]);
1821

1922
* Guarantee that no "empty" value option is displayed::

security/access_token.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,36 @@ create your own User from the claims, you must
697697
}
698698
}
699699

700+
Creating Users from Token
701+
-------------------------
702+
703+
Some types of tokens (for instance OIDC) contain all information required
704+
to create a user entity (e.g. username and roles). In this case, you don't
705+
need a user provider to create a user from the database::
706+
707+
// src/Security/AccessTokenHandler.php
708+
namespace App\Security;
709+
710+
// ...
711+
class AccessTokenHandler implements AccessTokenHandlerInterface
712+
{
713+
// ...
714+
715+
public function getUserBadgeFrom(string $accessToken): UserBadge
716+
{
717+
// get the data from the token
718+
$payload = ...;
719+
720+
return new UserBadge(
721+
$payload->getUserId(),
722+
fn (string $userIdentifier) => new User($userIdentifier, $payload->getRoles())
723+
);
724+
}
725+
}
726+
727+
When using this strategy, you can omit the ``user_provider`` configuration
728+
for :ref:`stateless firewalls <reference-security-stateless>`.
729+
700730
.. _`JSON Web Tokens (JWT)`: https://datatracker.ietf.org/doc/html/rfc7519
701731
.. _`SAML2 (XML structures)`: https://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-tech-overview-2.0.html
702732
.. _`RFC6750`: https://datatracker.ietf.org/doc/html/rfc6750

service_container/tags.rst

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -838,10 +838,88 @@ iterator, add the ``exclude`` option:
838838
;
839839
};
840840
841-
.. note::
841+
In the case the referencing service is itself tagged with the tag being used in the tagged
842+
iterator, it is automatically excluded from the injected iterable. This behavior can be
843+
disabled by setting the ``exclude_self`` option to ``false``:
844+
845+
.. configuration-block::
846+
847+
.. code-block:: php-attributes
848+
849+
// src/HandlerCollection.php
850+
namespace App;
851+
852+
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
853+
854+
class HandlerCollection
855+
{
856+
public function __construct(
857+
#[TaggedIterator('app.handler', exclude: ['App\Handler\Three'], excludeSelf: false)]
858+
iterable $handlers
859+
) {
860+
}
861+
}
862+
863+
.. code-block:: yaml
864+
865+
# config/services.yaml
866+
services:
867+
# ...
842868
843-
In the case the referencing service is itself tagged with the tag being used in the tagged
844-
iterator, it is automatically excluded from the injected iterable.
869+
# This is the service we want to exclude, even if the 'app.handler' tag is attached
870+
App\Handler\Three:
871+
tags: ['app.handler']
872+
873+
App\HandlerCollection:
874+
arguments:
875+
- !tagged_iterator { tag: app.handler, exclude: ['App\Handler\Three'], exclude_self: false }
876+
877+
.. code-block:: xml
878+
879+
<!-- config/services.xml -->
880+
<?xml version="1.0" encoding="UTF-8" ?>
881+
<container xmlns="http://symfony.com/schema/dic/services"
882+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
883+
xsi:schemaLocation="http://symfony.com/schema/dic/services
884+
https://symfony.com/schema/dic/services/services-1.0.xsd">
885+
886+
<services>
887+
<!-- ... -->
888+
889+
<!-- This is the service we want to exclude, even if the 'app.handler' tag is attached -->
890+
<service id="App\Handler\Three">
891+
<tag name="app.handler"/>
892+
</service>
893+
894+
<service id="App\HandlerCollection">
895+
<!-- inject all services tagged with app.handler as first argument -->
896+
<argument type="tagged_iterator" tag="app.handler" exclude-self="false">
897+
<exclude>App\Handler\Three</exclude>
898+
</argument>
899+
</service>
900+
</services>
901+
</container>
902+
903+
.. code-block:: php
904+
905+
// config/services.php
906+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
907+
908+
return function(ContainerConfigurator $containerConfigurator) {
909+
$services = $containerConfigurator->services();
910+
911+
// ...
912+
913+
// This is the service we want to exclude, even if the 'app.handler' tag is attached
914+
$services->set(App\Handler\Three::class)
915+
->tag('app.handler')
916+
;
917+
918+
$services->set(App\HandlerCollection::class)
919+
// inject all services tagged with app.handler as first argument
920+
->args([tagged_iterator('app.handler', exclude: [App\Handler\Three::class], excludeSelf: false)])
921+
;
922+
};
845923
846924
.. seealso::
847925

workflow/dumping-workflows.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@ files and ``PlantUmlDumper`` to create the PlantUML files::
6565
Styling
6666
-------
6767

68+
You can use ``--with-metadata`` option in the ``workflow:dump`` command to include places, transitions and
69+
workflow's metadata.
70+
71+
The DOT image will look like this :
72+
73+
.. image:: /_images/components/workflow/blogpost_metadata.png
74+
75+
.. note::
76+
77+
The ``--with-metadata`` option only works for the DOT dumper for now.
78+
79+
.. note::
80+
81+
The ``label`` metadata is not included in the dumped metadata, because it is used as a place's title.
82+
6883
You can use ``metadata`` with the following keys to style the workflow:
6984

7085
* for places:

0 commit comments

Comments
 (0)