Skip to content

Commit 0b45a08

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: Minor change to use DateTimeImmutable instead of DateTime [Twig] Add missing space [Validator] Mention doctrine-bridge in the UniqueEntity constraint remove unsupported trusted header config values [Routing] Add PHP Attribute route example to the controller [Form] Add PHP Attributes example to forms
2 parents 862be12 + f245120 commit 0b45a08

File tree

7 files changed

+58
-12
lines changed

7 files changed

+58
-12
lines changed

controller/service.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ a service like: ``App\Controller\HelloController::index``:
4141
}
4242
}
4343
44+
.. code-block:: php-attributes
45+
46+
// src/Controller/HelloController.php
47+
namespace App\Controller;
48+
49+
use Symfony\Component\Routing\Annotation\Route;
50+
51+
class HelloController
52+
{
53+
#[Route('/hello', name: 'hello', methods: ['GET'])]
54+
public function index()
55+
{
56+
// ...
57+
}
58+
}
59+
4460
.. code-block:: yaml
4561
4662
# config/routes.yaml
@@ -105,6 +121,23 @@ which is a common practice when following the `ADR pattern`_
105121
}
106122
}
107123
124+
.. code-block:: php-attributes
125+
126+
// src/Controller/Hello.php
127+
namespace App\Controller;
128+
129+
use Symfony\Component\HttpFoundation\Response;
130+
use Symfony\Component\Routing\Annotation\Route;
131+
132+
#[Route('/hello/{name}', name: 'hello')]
133+
class Hello
134+
{
135+
public function __invoke($name = 'World')
136+
{
137+
return new Response(sprintf('Hello %s!', $name));
138+
}
139+
}
140+
108141
.. code-block:: yaml
109142
110143
# config/routes.yaml

deployment/proxies.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ and what headers your reverse proxy uses to send information:
3737
trusted_headers: ['x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port']
3838
// or, if your proxy instead uses the "Forwarded" header
3939
trusted_headers: ['forwarded']
40-
// or, if you're using a wellknown proxy
41-
trusted_headers: [!php/const Symfony\\Component\\HttpFoundation\\Request::HEADER_X_FORWARDED_AWS_ELB]
42-
trusted_headers: [!php/const Symfony\\Component\\HttpFoundation\\Request::HEADER_X_FORWARDED_TRAEFIK]
4340
4441
.. code-block:: xml
4542
@@ -80,9 +77,6 @@ and what headers your reverse proxy uses to send information:
8077
'trusted_headers' => ['x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port'],
8178
// or, if your proxy instead uses the "Forwarded" header
8279
'trusted_headers' => ['forwarded'],
83-
// or, if you're using a wellknown proxy
84-
'trusted_headers' => [Request::HEADER_X_FORWARDED_AWS_ELB],
85-
'trusted_headers' => [Request::HEADER_X_FORWARDED_TRAEFIK],
8680
]);
8781
8882
.. deprecated:: 5.2
@@ -135,9 +129,6 @@ In this case, you'll need to - *very carefully* - trust *all* proxies.
135129
// run time by $_SERVER['REMOTE_ADDR'])
136130
trusted_proxies: '127.0.0.1,REMOTE_ADDR'
137131
138-
// if you're using ELB, otherwise use another Request::HEADER-* constant
139-
trusted_headers: [!php/const Symfony\\Component\\HttpFoundation\\Request::HEADER_X_FORWARDED_AWS_ELB, '!x-forwarded-host', '!x-forwarded-prefix']
140-
141132
That's it! It's critical that you prevent traffic from all non-trusted sources.
142133
If you allow outside traffic, they could "spoof" their true IP address and
143134
other information.

doctrine/events.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ define a callback for the ``prePersist`` Doctrine event:
7676
*/
7777
public function setCreatedAtValue(): void
7878
{
79-
$this->createdAt = new \DateTime();
79+
$this->createdAt = new \DateTimeImmutable();
8080
}
8181
}
8282

forms.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,23 @@ object.
507507
protected $dueDate;
508508
}
509509
510+
.. code-block:: php-attributes
511+
512+
// src/Entity/Task.php
513+
namespace App\Entity;
514+
515+
use Symfony\Component\Validator\Constraints as Assert;
516+
517+
class Task
518+
{
519+
#[Assert\NotBlank]
520+
public $task;
521+
522+
#[Assert\NotBlank]
523+
#[Assert\Type(\DateTime::class)]
524+
protected $dueDate;
525+
}
526+
510527
.. code-block:: yaml
511528
512529
# config/validator/validation.yaml

performance.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ You can also profile your template code with the :ref:`stopwatch Twig tag <refer
279279
.. code-block:: twig
280280
281281
{% stopwatch 'render-blog-posts' %}
282-
{% for post in blog_posts%}
282+
{% for post in blog_posts %}
283283
{# ... #}
284284
{% endfor %}
285285
{% endstopwatch %}

reference/constraints/UniqueEntity.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ using an email address that already exists in the system.
1010
If you want to validate that all the elements of the collection are unique
1111
use the :doc:`Unique constraint </reference/constraints/Unique>`.
1212

13+
.. note::
14+
15+
In order to use this constraint, you should have installed the
16+
symfony/doctrine-bridge with Composer.
17+
1318
========== ===================================================================
1419
Applies to :ref:`class <validation-class-target>`
1520
Options - `em`_

reference/constraints/UserPassword.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ password, but needs to enter their old password for security.
1212

1313
.. note::
1414

15-
In order to use this constraints, you should have installed the
15+
In order to use this constraint, you should have installed the
1616
symfony/security-core component with Composer.
1717

1818
========== ===================================================================

0 commit comments

Comments
 (0)