Skip to content

Commit 51d2678

Browse files
committed
Merge branch '7.4' into 8.0
* 7.4: [Security] add `methods` argument to #[IsGranted] to restrict access by HTTP method [Mailer] Document Mailtrap's sandbox compatibility Update advanced-config.rst Add documentation for extending `IsGranted` attribute framework.rst: fixed `cookie_samesite` default value Documenting changes in the debug:router output [DomCrawler] Remove useless note about useHtml5Parser argument [Routing] allow passing multiple environments to Route `env` argument clarify that "placeholder" is an input attribute to configure
2 parents 88b3018 + 512e8a0 commit 51d2678

File tree

8 files changed

+78
-35
lines changed

8 files changed

+78
-35
lines changed

components/dom_crawler.rst

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -649,23 +649,8 @@ another given base URI::
649649
UriResolver::resolve('?a=b', 'http://localhost/bar#foo'); // http://localhost/bar?a=b
650650
UriResolver::resolve('../../', 'http://localhost/'); // http://localhost/
651651

652-
Using a HTML5 Parser
653-
~~~~~~~~~~~~~~~~~~~~
654-
655-
If you need the :class:`Symfony\\Component\\DomCrawler\\Crawler` to use an HTML5
656-
parser, set its ``useHtml5Parser`` constructor argument to ``true``::
657-
658-
use Symfony\Component\DomCrawler\Crawler;
659-
660-
$crawler = new Crawler(null, $uri, useHtml5Parser: true);
661-
662-
By doing so, the crawler will use the HTML5 parser provided by the `masterminds/html5`_
663-
library to parse the documents.
664-
665652
Learn more
666653
----------
667654

668655
* :doc:`/testing`
669656
* :doc:`/components/css_selector`
670-
671-
.. _`masterminds/html5`: https://packagist.org/packages/masterminds/html5

frontend/encore/advanced-config.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Use the following command to find the right service:
165165

166166
.. code-block:: terminal
167167
168-
$ php bin/console console debug:container entrypoint_lookup
168+
$ php bin/console debug:container entrypoint_lookup
169169
170170
# You will see a result similar to this:
171171
Select one of the following services to display its information:

mailer.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ party provider:
219219
+------------------------+-------------------------------------------------------------------------------------------+
220220
| `Mailtrap`_ | - SMTP ``mailtrap+smtp://PASSWORD@default`` |
221221
| | - HTTP n/a |
222-
| | - API ``mailtrap+api://API_TOKEN@default`` |
222+
| | - API (Live) ``mailtrap+api://API_TOKEN@default`` |
223+
| | - API (Sandbox) ``mailtrap+sandbox://API_TOKEN@default/?inboxId=INBOX_ID`` |
223224
+------------------------+-------------------------------------------------------------------------------------------+
224225
| `Microsoft Graph`_ | - SMTP n/a |
225226
| | - HTTP n/a |

page_creation.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ You should see your ``app_lucky_number`` route in the list:
125125

126126
.. code-block:: terminal
127127
128-
---------------- ------- ------- ----- --------------
129-
Name Method Scheme Host Path
130-
---------------- ------- ------- ----- --------------
131-
app_lucky_number ANY ANY ANY /lucky/number
132-
---------------- ------- ------- ----- --------------
128+
---------------- ------- --------------
129+
Name Method Path
130+
---------------- ------- --------------
131+
app_lucky_number ANY /lucky/number
132+
---------------- ------- --------------
133133
134134
You will also see debugging routes besides ``app_lucky_number`` -- more on
135135
the debugging routes in the next section.

reference/configuration/framework.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2945,7 +2945,7 @@ If not set, ``php.ini``'s `session.cookie_path`_ directive will be relied on.
29452945
cookie_samesite
29462946
...............
29472947

2948-
**type**: ``string`` or ``null`` **default**: ``null``
2948+
**type**: ``string`` or ``null`` **default**: ``'lax'``
29492949

29502950
It controls the way cookies are sent when the HTTP request did not originate
29512951
from the same domain that is associated with the cookies. Setting this option is

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ when no value is selected, you can do it like this::
1212
]);
1313

1414
This will still render an empty text box, but upon submission the ``John Doe``
15-
value will be set. Use the ``data`` or ``placeholder`` options to show this
16-
initial value in the rendered form.
15+
value will be set. Use the ``data`` option or the ``placeholder`` key of the
16+
``attr`` option to show this initial value in the rendered form.
1717

1818
.. note::
1919

routing.rst

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ given value:
274274
{
275275
// ...
276276
}
277+
278+
// You can also pass an array of environments
279+
#[Route('/tools', name: 'tools', env: ['dev', 'test'])]
280+
public function developerTools(): Response
281+
{
282+
// ...
283+
}
277284
}
278285
279286
.. code-block:: yaml
@@ -312,6 +319,10 @@ given value:
312319
}
313320
};
314321
322+
.. versionadded:: 7.4
323+
324+
The ability to pass an array of environments to the ``env`` argument was introduced in Symfony 7.4.
325+
315326
.. _routing-matching-expressions:
316327

317328
Matching Expressions
@@ -487,20 +498,23 @@ evaluates them:
487498
488499
$ php bin/console debug:router
489500
490-
---------------- ------- ------- ----- --------------------------------------------
491-
Name Method Scheme Host Path
492-
---------------- ------- ------- ----- --------------------------------------------
493-
homepage ANY ANY ANY /
494-
contact GET ANY ANY /contact
495-
contact_process POST ANY ANY /contact
496-
article_show ANY ANY ANY /articles/{_locale}/{year}/{title}.{_format}
497-
blog ANY ANY ANY /blog/{page}
498-
blog_show ANY ANY ANY /blog/{slug}
499-
---------------- ------- ------- ----- --------------------------------------------
501+
---------------- ------- --------------------------------------------
502+
Name Method Path
503+
---------------- ------- --------------------------------------------
504+
homepage ANY /
505+
contact GET /contact
506+
contact_process POST /contact
507+
article_show ANY /articles/{_locale}/{year}/{title}.{_format}
508+
blog ANY /blog/{page}
509+
blog_show ANY /blog/{slug}
510+
---------------- ------- --------------------------------------------
500511
501512
# pass this option to also display all the defined route aliases
502513
$ php bin/console debug:router --show-aliases
503514
515+
# pass this option to also display the associated controllers with the routes
516+
$ php bin/console debug:router --show-controllers
517+
504518
# pass this option to only display routes that match the given HTTP method
505519
# (you can use the special value ANY to see routes that match any method)
506520
$ php bin/console debug:router --method=GET

security.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,6 +2517,49 @@ that is thrown with the ``exceptionCode`` argument::
25172517
// ...
25182518
}
25192519

2520+
You can also extend the ``IsGranted`` attribute to create meaningful shortcuts::
2521+
2522+
// src/Security/Attribute/IsAdmin.php
2523+
// ...
2524+
2525+
use Symfony\Component\Security\Http\Attribute\IsGranted;
2526+
2527+
class IsAdmin extends IsGranted
2528+
{
2529+
public function __construct()
2530+
{
2531+
return parent::__construct('ROLE_ADMIN');
2532+
}
2533+
}
2534+
2535+
.. versionadded:: 7.4
2536+
2537+
The :class:`Symfony\\Component\\Security\\Http\\Attribute\\IsGranted`
2538+
attribute is extendable since Symfony 7.4.
2539+
2540+
You can restrict access validation to specific HTTP methods
2541+
by using the ``methods`` argument::
2542+
2543+
// src/Controller/AdminController.php
2544+
// ...
2545+
2546+
use Symfony\Component\Security\Http\Attribute\IsGranted;
2547+
2548+
#[IsGranted('ROLE_ADMIN', methods: 'POST')]
2549+
class AdminController extends AbstractController
2550+
{
2551+
// You can also specify an array of methods
2552+
#[IsGranted('ROLE_SUPER_ADMIN', methods: ['GET', 'PUT'])]
2553+
public function adminDashboard(): Response
2554+
{
2555+
// ...
2556+
}
2557+
}
2558+
2559+
.. versionadded:: 7.4
2560+
2561+
The ``methods`` argument was introduced in Symfony 7.4.
2562+
25202563
.. _security-template:
25212564

25222565
Access Control in Templates

0 commit comments

Comments
 (0)