10000 Merge branch '5.3' into 5.4 · symfony/symfony-docs@83db063 · GitHub
[go: up one dir, main page]

Skip to content

Commit 83db063

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: Fix link syntax Update mercure.rst Symfony Local Web Server url Update license.rst Fix method link to isCsrfTokenValid Fix link reference in Upgrading to Symfony Flex Added attribute code block examples
2 parents 9feec56 + 4fd2b23 commit 83db063

File tree

4 files changed

+83
-11
lines changed

4 files changed

+83
-11
lines changed

contributing/code/license.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Symfony Code License
55

66
Symfony code is released under `the MIT license`_:
77

8-
Copyright (c) 2004-2020 Fabien Potencier
8+
Copyright (c) 2004-2021 Fabien Potencier
99

1010
Permission is hereby granted, free of charge, to any person obtaining a copy
1111
of this software and associated documentation files (the "Software"), to deal

doctrine/associations.rst

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,32 @@ the ``Product`` entity (and getter & setter methods):
171171
}
172172
}
173173
174+
.. code-block:: php-attributes
175+
176+
// src/Entity/Product.php
177+
namespace App\Entity;
178+
179+
// ...
180+
class Product
181+
{
182+
// ...
183+
184+
#[ORM\ManyToOne(targetEntity: Category::class, inversedBy: "products")]
185+
private $category;
186+
187+
public function getCategory(): ?Category
188+
{
189+
return $this->category;
190+
}
191+
192+
public function setCategory(?Category $category): self
193+
{
194+
$this->category = $category;
195+
196+
return $this;
197+
}
198+
}
199+
174200
.. code-block:: yaml
175201
176202
# src/Resources/config/doctrine/Product.orm.yml
@@ -248,6 +274,38 @@ class that will hold these objects:
248274
// addProduct() and removeProduct() were also added
249275
}
250276
277+
.. code-block:: php-attributes
278+
279+
// src/Entity/Category.php
280+
namespace App\Entity;
281+
282+
// ...
283+
use Doctrine\Common\Collections\ArrayCollection;
284+
use Doctrine\Common\Collections\Collection;
285+
286+
class Category
287+
{
288+
// ...
289+
290+
#[ORM\OneToMany(targetEntity: Product::class, mappedBy: "category")]
291+
private $products;
292+
293+
public function __construct()
294+
{
295+
$this->products = new ArrayCollection();
296+
}
297+
298+
/**
299+
* @return Collection|Product[]
300+
*/
301+
public function getProducts(): Collection
302+
{
303+
return $this->products;
304+
}
305+
306+
// addProduct() and removeProduct() were also added
307+
}
308+
251309
.. code-block:: yaml
252310
253311
# src/Resources/config/doctrine/Category.orm.yml
@@ -589,16 +647,30 @@ on that ``Product`` will be set to ``null`` in the database.
589647

590648
But, instead of setting the ``category_id`` to null, what if you want the ``Product``
591649
to be *deleted* if it becomes "orphaned" (i.e. without a ``Category``)? To choose
592-
that behavior, use the `orphanRemoval`_ option inside ``Category``::
650+
that behavior, use the `orphanRemoval`_ option inside ``Category``:
593651

594-
// src/Entity/Category.php
652+
.. configuration-block::
595653

596-
// ...
654+
.. code-block:: php-annotations
655+
656+
// src/Entity/Category.php
657+
658+
// ...
659+
660+
/**
661+
* @ORM\OneToMany(targetEntity="App\Entity\Product", mappedBy="category", orphanRemoval=true)
662+
*/
663+
private $products;
664+
665+
.. code-block:: php-attributes
666+
667+
// src/Entity/Category.php
668+
669+
// ...
670+
671+
#[ORM\OneToMany(targetEntity: Product::class, mappedBy: "category", orphanRemoval=true)]
672+
private $products;
597673
598-
/**
599-
* @ORM\OneToMany(targetEntity="App\Entity\Product", mappedBy="category", orphanRemoval=true)
600-
*/
601-
private $products;
602674
603675
Thanks to this, if the ``Product`` is removed from the ``Category``, it will be
604676
removed from the database entirely.

mercure.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ clients.
6666

6767
.. image:: /_images/mercure/schema.png
6868

69-
If you use the `Symfony Local Web Server </setup/symfony_server>`_ or `Symfony Docker`_,
69+
If you use the :doc:`Symfony Local Web Server </setup/symfony_server>` or `Symfony Docker`_,
7070
a Mercure Hub is automatically available.
7171

7272
For production usage, an official and open source (AGPL) Hub based on the Caddy web server

security/csrf.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ generate a CSRF token in the template and store it as a hidden form field:
150150
</form>
151151

152152
Then, get the value of the CSRF token in the controller action and use the
153-
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController::isCsrfTokenValid`
154-
to check its validity::
153+
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerTrait::isCsrfTokenValid`
154+
method to check its validity::
155155

156156
use Symfony\Component\HttpFoundation\Request;
157157
use Symfony\Component\HttpFoundation\Response;

0 commit comments

Comments
 (0)
0