Skip to content

Commit d8faa39

Browse files
greg0irejaviereguiluz
authored andcommitted
Use the shorthand notation when applicable
1 parent 945dbc6 commit d8faa39

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

+80
-234
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
@@ -94,9 +94,7 @@ makes them easier to re-use later.
9494

9595
Since Symfony 2.3, you can add buttons as fields on your form. This is a nice
9696
way to simplify the template that renders your form. But if you add the buttons
97-
directly in your form class, this would effectively limit the scope of that form:
98-
99-
.. code-block:: php
97+
directly in your form class, this would effectively limit the scope of that form::
10098

10199
class PostType extends AbstractType
102100
{
@@ -178,9 +176,7 @@ can control *how* the form renders at a global level using form theming.
178176
Handling Form Submits
179177
---------------------
180178

181-
Handling a form submit usually follows a similar template:
182-
183-
.. code-block:: php
179+
Handling a form submit usually follows a similar template::
184180

185181
public function newAction(Request $request)
186182
{

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

@@ -313,9 +303,7 @@ To enable the security voter in the application, define a new service:
313303
tags:
314304
- { name: security.voter }
315305
316-
Now, you can use the voter with the ``@Security`` annotation:
317-
318-
.. code-block:: php
306+
Now, you can use the voter with the ``@Security`` annotation::
319307

320308
/**
321309
* @Route("/{id}/edit", name="admin_post_edit")
@@ -327,9 +315,7 @@ Now, you can use the voter with the ``@Security`` annotation:
327315
}
328316

329317
You can also use this directly with the ``security.authorization_checker`` service or
330-
via the even easier shortcut in a controller:
331-
332-
.. code-block:: php
318+
via the even easier shortcut in a controller::
333319

334320
/**
335321
* @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
@@ -417,9 +417,7 @@ Documenting the Option
417417

418418
All options can be documented using the
419419
:method:`Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::info`
420-
method.
421-
422-
.. code-block:: php
420+
method::
423421

424422
$rootNode
425423
->children()

components/dom_crawler.rst

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

261261
As the Crawler's implementation is based on the DOM extension, it is also able
262262
to interact with native :phpclass:`DOMDocument`, :phpclass:`DOMNodeList`
263-
and :phpclass:`DOMNode` objects:
264-
265-
.. code-block:: php
263+
and :phpclass:`DOMNode` objects::
266264

267265
$document = new \DOMDocument();
268266
$document->loadXml('<root><node /><node /></root>');

components/expression_language/extending.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ This interface requires one method:
6868
:method:`Symfony\\Component\\ExpressionLanguage\\ExpressionFunctionProviderInterface::getFunctions`,
6969
which returns an array of expression functions (instances of
7070
:class:`Symfony\\Component\\ExpressionLanguage\\ExpressionFunction`) to
71-
register.
72-
73-
.. code-block:: php
71+
register::
7472

7573
use Symfony\Component\ExpressionLanguage\ExpressionFunction;
7674
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;

0 commit comments

Comments
 (0)