Skip to content

Commit dd3863a

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Fix link syntax Update mercure.rst Symfony Local Web Server url * unstable_versions.rst - upgrade Update license.rst Fix method link to isCsrfTokenValid Fix link reference in Upgrading to Symfony Flex Added attribute code block examples
2 parents a9b3b9b + 5e7f3e4 commit dd3863a

File tree

5 files changed

+88
-16
lines changed

5 files changed

+88
-16
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;

setup/unstable_versions.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Creating a New Project Based on an Unstable Symfony Version
88
-----------------------------------------------------------
99

1010

11-
Suppose that the Symfony 4.0 version hasn't been released yet and you want to create
11+
Suppose that the Symfony 5.4 version hasn't been released yet and you want to create
1212
a new project to test its features. First, `install the Composer package manager`_.
1313
Then, open a command console, enter your project's directory and
1414
run the following command:
@@ -24,7 +24,7 @@ in the ``my_project/`` directory.
2424
Upgrading your Project to an Unstable Symfony Version
2525
-----------------------------------------------------
2626

27-
Suppose again that Symfony 4.0 hasn't been released yet and you want to upgrade
27+
Suppose again that Symfony 5.4 hasn't been released yet and you want to upgrade
2828
an existing application to test that your project works with it.
2929

3030
First, open the ``composer.json`` file located in the root directory of your
@@ -35,16 +35,16 @@ new version and change your ``minimum-stability`` to ``beta``:
3535
3636
{
3737
"require": {
38-
+ "symfony/framework-bundle": "^4.0",
39-
+ "symfony/finder": "^4.0",
38+
+ "symfony/framework-bundle": "^5.4",
39+
+ "symfony/finder": "^5.4",
4040
"...": "..."
4141
},
4242
+ "minimum-stability": "beta"
4343
}
4444
4545
You can also use set ``minimum-stability`` to ``dev``, or omit this line
4646
entirely, and opt into your stability on each package by using constraints
47-
like ``4.0.*@beta``.
47+
like ``5.4.*@beta``.
4848

4949
Finally, from a terminal, update your project's dependencies:
5050

0 commit comments

Comments
 (0)