Skip to content

Commit 90f42c1

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: Use the shorthand notation when applicable
2 parents 02da88e + dc7271a commit 90f42c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+79
-231
lines changed

best_practices/business-logic.rst

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ The blog application needs a utility that can transform a post title (e.g.
5757
part of the post URL.
5858

5959
Let's create a new ``Slugger`` class inside ``src/AppBundle/Utils/`` and
60-
add the following ``slugify()`` method:
61-
62-
.. code-block:: php
60+
add the following ``slugify()`` method::
6361

6462
// src/AppBundle/Utils/Slugger.php
6563
namespace AppBundle\Utils;
@@ -96,9 +94,7 @@ your code will be easier to read and use.
9694
you ever need to.
9795

9896
Now you can use the custom slugger in any controller class, such as the
99-
``AdminController``:
100-
101-
.. code-block:: php
97+
``AdminController``::
10298

10399
public function createAction(Request $request)
104100
{
@@ -203,9 +199,7 @@ PHP and annotations.
203199
Use annotations to define the mapping information of the Doctrine entities.
204200

205201
Annotations are by far the most convenient and agile way of setting up and
206-
looking for mapping information:
207-
208-
.. code-block:: php
202+
looking for mapping information::
209203

210204
namespace AppBundle\Entity;
211205

@@ -284,9 +278,7 @@ the following command to install the Doctrine fixtures bundle:
284278
$ composer require "doctrine/doctrine-fixtures-bundle"
285279
286280
Then, enable the bundle in ``AppKernel.php``, but only for the ``dev`` and
287-
``test`` environments:
288-
289-
.. code-block:: php
281+
``test`` environments::
290282

291283
use Symfony\Component\HttpKernel\Kernel;
292284

best_practices/configuration.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ Constants can be used for example in your Twig templates thanks to the
133133
</p>
134134

135135
And Doctrine entities and repositories can now easily access these values,
136-
whereas they cannot access the container parameters:
137-
138-
.. code-block:: php
136+
whereas they cannot access the container parameters::
139137

140138
namespace AppBundle\Repository;
141139

best_practices/controllers.rst

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ What does the Controller look like
8989
----------------------------------
9090

9191
Considering all this, here is an example of what the controller should look like
92-
for the homepage of our app:
93-
94-
.. code-block:: php
92+
for the homepage of our app::
9593

9694
namespace AppBundle\Controller;
9795

@@ -129,9 +127,7 @@ to automatically query for an entity and pass it as an argument to your controll
129127
Use the ParamConverter trick to automatically query for Doctrine entities
130128
when it's simple and convenient.
131129

132-
For example:
133-
134-
.. code-block:: php
130+
For example::
135131

136132
use AppBundle\Entity\Post;
137133
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
@@ -161,9 +157,7 @@ When Things Get More Advanced
161157
The above example works without any configuration because the wildcard name ``{id}`` matches
162158
the name of the property on the entity. If this isn't true, or if you have
163159
even more complex logic, the easiest thing to do is just query for the entity
164-
manually. In our application, we have this situation in ``CommentController``:
165-
166-
.. code-block:: php
160+
manually. In our application, we have this situation in ``CommentController``::
167161

168162
/**
169163
* @Route("/comment/{postSlug}/new", name="comment_new")
@@ -182,9 +176,7 @@ manually. In our application, we have this situation in ``CommentController``:
182176
}
183177

184178
You can also use the ``@ParamConverter`` configuration, which is infinitely
185-
flexible:
186-
187-
.. code-block:: php
179+
flexible::
188180

189181
use AppBundle\Entity\Post;
190182
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

best_practices/forms.rst

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ makes them easier to re-use later.
8787

8888
Since Symfony 2.3, you can add buttons as fields on your form. This is a nice
8989
way to simplify the template that renders your form. But if you add the buttons
90-
directly in your form class, this would effectively limit the scope of that form:
91-
92-
.. code-block:: php
90+
directly in your form class, this would effectively limit the scope of that form::
9391

9492
class PostType extends AbstractType
9593
{
@@ -172,9 +170,7 @@ can control *how* the form renders at a global level using form theming.
172170
Handling Form Submits
173171
---------------------
174172

175-
Handling a form submit usually follows a similar template:
176-
177-
.. code-block:: php
173+
Handling a form submit usually follows a similar template::
178174

179175
public function newAction(Request $request)
180176
{

best_practices/security.rst

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ Using Expressions for Complex Security Restrictions
130130
If your security logic is a little bit more complex, you can use an :doc:`expression </components/expression_language>`
131131
inside ``@Security``. In the following example, a user can only access the
132132
controller if their email matches the value returned by the ``getAuthorEmail()``
133-
method on the ``Post`` object:
134-
135-
.. code-block:: php
133+
method on the ``Post`` object::
136134

137135
use AppBundle\Entity\Post;
138136
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
@@ -163,9 +161,7 @@ need to repeat the expression code using Twig syntax:
163161
{% endif %}
164162

165163
The easiest solution - if your logic is simple enough - is to add a new method
166-
to the ``Post`` entity that checks if a given user is its author:
167-
168-
.. code-block:: php
164+
to the ``Post`` entity that checks if a given user is its author::
169165

170166
// src/AppBundle/Entity/Post.php
171167
// ...
@@ -185,9 +181,7 @@ to the ``Post`` entity that checks if a given user is its author:
185181
}
186182
}
187183

188-
Now you can reuse this method both in the template and in the security expression:
189-
190-
.. code-block:: php
184+
Now you can reuse this method both in the template and in the security expression::
191185

192186
use AppBundle\Entity\Post;
193187
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
@@ -217,9 +211,7 @@ Checking Permissions without @Security
217211
The above example with ``@Security`` only works because we're using the
218212
:ref:`ParamConverter <best-practices-paramconverter>`, which gives the expression
219213
access to the ``post`` variable. If you don't use this, or have some other
220-
more advanced use-case, you can always do the same security check in PHP:
221-
222-
.. code-block:: php
214+
more advanced use-case, you can always do the same security check in PHP::
223215

224216
/**
225217
* @Route("/{id}/edit", name="admin_post_edit")
@@ -257,9 +249,7 @@ of magnitude easier than :doc:`ACLs </security/acl>` and will give
257249
you the flexibility you need in almost all cases.
258250

259251
First, create a voter class. The following example shows a voter that implements
260-
the same ``getAuthorEmail()`` logic you used above:
261-
262-
.. code-block:: php
252+
the same ``getAuthorEmail()`` logic you used above::
263253

264254
namespace AppBundle\Security;
265255

@@ -343,9 +333,7 @@ To enable the security voter in the application, define a new service:
343333
tags:
344334
- { name: security.voter }
345335
346-
Now, you can use the voter with the ``@Security`` annotation:
347-
348-
.. code-block:: php
336+
Now, you can use the voter with the ``@Security`` annotation::
349337

350338
/**
351339
* @Route("/{id}/edit", name="admin_post_edit")
@@ -357,9 +345,7 @@ Now, you can use the voter with the ``@Security`` annotation:
357345
}
358346

359347
You can also use this directly with the ``security.authorization_checker`` service or
360-
via the even easier shortcut in a controller:
361-
362-
.. code-block:: php
348+
via the even easier shortcut in a controller::
363349

364350
/**
365351
* @Route("/{id}/edit", name="admin_post_edit")

best_practices/templates.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ Markdown content into HTML::
115115

116116
Next, create a new Twig extension and define a new filter called ``md2html``
117117
using the ``Twig_SimpleFilter`` class. Inject the newly defined ``markdown``
118-
service in the constructor of the Twig extension:
119-
120-
.. code-block:: php
118+
service in the constructor of the Twig extension::
121119

122120
namespace AppBundle\Twig;
123121

best_practices/tests.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,7 @@ generator service:
8080
generator.
8181

8282
Consider the following functional test that uses the ``router`` service to
83-
generate the URL of the tested page:
84-
85-
.. code-block:: php
83+
generate the URL of the tested page::
8684

8785
public function testBlogArchives()
8886
{

components/config/definition.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,7 @@ Documenting the Option
420420

421421
All options can be documented using the
422422
:method:`Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::info`
423-
method.
424-
425-
.. code-block:: php
423+
method::
426424

427425
$rootNode
428426
->children()

components/dom_crawler.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,7 @@ The crawler supports multiple ways of adding the content::
247247

248248
As the Crawler's implementation is based on the DOM extension, it is also able
249249
to interact with native :phpclass:`DOMDocument`, :phpclass:`DOMNodeList`
250-
and :phpclass:`DOMNode` objects:
251-
252-
.. code-block:: php
250+
and :phpclass:`DOMNode` objects::
253251

254252
$domDocument = new \DOMDocument();
255253
$domDocument->loadXml('<root><node /><node /></root>');

components/expression_language/extending.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ This interface requires one method:
6565
:method:`Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface::getFunctions`,
6666
which returns an array of expression functions (instances of
6767
:class:`Symfony\\Component\\ExpressionLanguage\\ExpressionFunction`) to
68-
register.
69-
70-
.. code-block:: php
68+
register::
7169

7270
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
7371
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;

0 commit comments

Comments
 (0)