Skip to content

Commit 9111bd2

Browse files
committed
Merge branch '4.0'
* 4.0: Use escaped backslashes Don't mention the UserInterface type-hinting Change symfony-public-dir to public-dir Update web/ directory to public/ on bundle page Fix wrong import path Add information about default value for decoration_priority Adding the missing attr option to the ChoiceType Update choice.rst Minor fixes in the bundles article Fixed the link to the bin/console script Update profiler.rst
2 parents b655166 + b762d37 commit 9111bd2

File tree

10 files changed

+42
-28
lines changed

10 files changed

+42
-28
lines changed

bundles.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ file::
4444
Creating a Bundle
4545
-----------------
4646

47-
This section creates and enables a new bundle to show how simple is to do it.
47+
This section creates and enables a new bundle to show how simple it is to do it.
4848
The new bundle is called AcmeTestBundle, where the ``Acme`` portion is just a
4949
dummy name that should be replaced by some "vendor" name that represents you or
5050
your organization (e.g. ABCTestBundle for some company named ``ABC``).
@@ -104,7 +104,7 @@ of the most common elements of a bundle:
104104

105105
``Resources/public/``
106106
Contains web assets (images, stylesheets, etc) and is copied or symbolically
107-
linked into the project ``web/`` directory via the ``assets:install`` console
107+
linked into the project ``public/`` directory via the ``assets:install`` console
108108
command.
109109

110110
``Tests/``

configuration/override_dir_structure.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ those files::
143143

144144
require_once __DIR__.'/../path/to/vendor/autoload.php';
145145

146-
You also need to change the ``extra.symfony-public-dir`` option in the
146+
You also need to change the ``extra.public-dir`` option in the
147147
``composer.json`` file:
148148

149149
.. code-block:: json
@@ -152,7 +152,7 @@ You also need to change the ``extra.symfony-public-dir`` option in the
152152
"...": "...",
153153
"extra": {
154154
"...": "...",
155-
"symfony-public-dir": "my_new_public_dir"
155+
"public-dir": "my_new_public_dir"
156156
}
157157
}
158158

controller.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ Managing Errors and 404 Pages
300300
When things are not found, you should return a 404 response. To do this, throw a
301301
special type of exception::
302302

303-
use Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException;
303+
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
304304

305305
// ...
306306
public function indexAction()

profiler.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ install the profiler before using it:
1212

1313
.. code-block:: terminal
1414
15-
$ composer require profiler
15+
$ composer require profiler --dev
1616
1717
.. toctree::
1818
:maxdepth: 1

quick_tour/the_architecture.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ great tools for this: the web debug toolbar displays at the bottom of the page,
207207
are big, beautiful & explicit, and any configuration cache is automatically rebuilt
208208
whenever needed.
209209

210-
But what about when you deploy to production? We will need to hide those tool and
210+
But what about when you deploy to production? We will need to hide those tools and
211211
optimize for speed!
212212

213213
This is solved by Symfony's *environment* system and there are three: ``dev``, ``prod``
@@ -266,7 +266,7 @@ Platform as a Service (PaaS) deployment systems as well as Docker.
266266
But setting environment variables while developing can be a pain. That's why your
267267
app automatically loads a ``.env`` file, if the ``APP_ENV`` environment variable
268268
isn't set in the environment. The keys in this file then become environment variables
269-
are and read by your app:
269+
and are read by your app:
270270

271271
.. code-block:: bash
272272
@@ -278,7 +278,7 @@ are and read by your app:
278278
279279
At first, the file doesn't contain much. But as your app grows, you'll add more
280280
configuration as you need it. But, actually, it gets much more interesting! Suppose
281-
your app needs database ORM. Let's install the Doctrine ORM:
281+
your app needs a database ORM. Let's install the Doctrine ORM:
282282

283283
.. code-block:: terminal
284284

reference/forms/types/choice.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op
2929
| options | - `empty_data`_ |
3030
| | - `error_bubbling`_ |
3131
+-------------+------------------------------------------------------------------------------+
32-
| Inherited | - `by_reference`_ |
33-
| options | - `data`_ |
32+
| Inherited | - `attr`_ |
33+
| options | - `by_reference`_ |
34+
| | - `data`_ |
3435
| | - `disabled`_ |
3536
| | - `error_mapping`_ |
3637
| | - `inherit_data`_ |
@@ -98,6 +99,7 @@ method::
9899
'choice_attr' => function($category, $key, $index) {
99100
return ['class' => 'category_'.strtolower($category->getName())];
100101
},
102+
101103
'group_by' => function($category, $key, $index) {
102104
// randomly assign things into 2 groups
103105
return rand(0, 1) == 1 ? 'Group A' : 'Group B';
@@ -252,6 +254,8 @@ Inherited Options
252254

253255
These options inherit from the :doc:`FormType </reference/forms/types/form>`:
254256

257+
.. include:: /reference/forms/types/options/attr.rst.inc
258+
255259
.. include:: /reference/forms/types/options/by_reference.rst.inc
256260

257261
.. include:: /reference/forms/types/options/data.rst.inc

routing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ Troubleshooting
616616

617617
Here are some common errors you might see while working with routing:
618618

619-
Controller "App\Controller\BlogController::show()" requires that you
619+
Controller "App\\Controller\\BlogController::show()" requires that you
620620
provide a value for the "$slug" argument.
621621

622622
This happens when your controller method has an argument (e.g. ``$slug``)::

security.rst

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,16 +1007,14 @@ If you still prefer to use traditional ACLs, refer to the `Symfony ACL bundle`_.
10071007
-----------------------------
10081008

10091009
After authentication, the ``User`` object of the current user can be accessed
1010-
via the ``security.token_storage`` service. From inside a controller, this will
1011-
look like::
1010+
via the ``getUser()`` shortcut (which uses the ``security.token_storage``
1011+
service). From inside a controller, this will look like::
10121012

10131013
public function index()
10141014
{
10151015
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
10161016

10171017
$user = $this->getUser();
1018-
// or you can also type-hint a method argument with this class:
1019-
// Symfony\Component\Security\Core\User\UserInterface (e.g. "UserInterface $user")
10201018
}
10211019

10221020
.. tip::
@@ -1044,14 +1042,7 @@ It's important to check if the user is authenticated first. If they're not,
10441042
``$user`` will either be ``null`` or the string ``anon.``. Wait, what? Yes,
10451043
this is a quirk. If you're not logged in, the user is technically the string
10461044
``anon.``, though the ``getUser()`` controller shortcut converts this to
1047-
``null`` for convenience. When type-hinting the
1048-
:class:`Symfony\\Component\\Security\\Core\\User\\UserInterface\\UserInterface`
1049-
and being logged-in is optional, you can allow a null value for the argument::
1050-
1051-
public function index(UserInterface $user = null)
1052-
{
1053-
// $user is null when not logged-in or anon.
1054-
}
1045+
``null`` for convenience.
10551046

10561047
The point is this: always check to see if the user is logged in before using
10571048
the User object, and use the ``isGranted()`` method (or
@@ -1065,6 +1056,25 @@ the User object, and use the ``isGranted()`` method (or
10651056
// ...
10661057
}
10671058

1059+
.. note::
1060+
1061+
An alternative way to get the current user in a controller is to type-hint
1062+
the controller argument with
1063+
:class:`Symfony\\Component\\Security\\Core\\User\\UserInterface\\UserInterface`
1064+
(and default it to ``null`` if being logged-in is optional)::
1065+
1066+
use Symfony\Component\Security\Core\User\UserInterface\UserInterface;
1067+
1068+
public function indexAction(UserInterface $user = null)
1069+
{
1070+
// $user is null when not logged-in or anon.
1071+
}
1072+
1073+
This is only recommended for experienced developers who don't extend from the
1074+
:ref:`Symfony base controller <the-base-controller-class-services>` and
1075+
don't use the :class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerTrait`
1076+
either. Otherwise, it's recommended to keep using the ``getUser()`` shortcut.
1077+
10681078
Retrieving the User in a Template
10691079
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10701080

service_container/service_decoration.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ replaces the ``app.mailer`` service. The old ``app.mailer`` service is renamed t
179179
Decoration Priority
180180
-------------------
181181

182-
If you want to apply more than one decorator to a service, you can control their
183-
order by configuring the priority of decoration, this can be any integer number
184-
(decorators with higher priorities will be applied first).
182+
When applying multiple decorators to a service, you can control their order with
183+
the ``decoration_priority`` option. Its value is an integer that defaults to
184+
``0`` and higher priorities mean that decorators will be applied earlier.
185185

186186
.. configuration-block::
187187

setup/flex.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,4 @@ manual steps:
254254
.. _`default services.yaml file`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/config/services.yaml
255255
.. _`shown in this example`: https://github.com/symfony/skeleton/blob/8e33fe617629f283a12bbe0a6578bd6e6af417af/composer.json#L24-L33
256256
.. _`copying Symfony's index.php source`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/public/index.php
257-
.. _`copying Symfony's bin/console source`: https://github.com/symfony/recipes/tree/master/symfony/console/3.3
257+
.. _`copying Symfony's bin/console source`: https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console

0 commit comments

Comments
 (0)