@@ -137,9 +137,7 @@ Using Expressions for Complex Security Restrictions
137137If your security logic is a little bit more complex, you can use an :doc: `expression </components/expression_language >`
138138inside ``@Security ``. In the following example, a user can only access the
139139controller if their email matches the value returned by the ``getAuthorEmail() ``
140- method on the ``Post `` object:
141-
142- .. code-block :: php
140+ method on the ``Post `` object::
143141
144142 use AppBundle\Entity\Post;
145143 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
@@ -170,9 +168,7 @@ need to repeat the expression code using Twig syntax:
170168 {% endif %}
171169
172170The easiest solution - if your logic is simple enough - is to add a new method
173- to the ``Post `` entity that checks if a given user is its author:
174-
175- .. code-block :: php
171+ to the ``Post `` entity that checks if a given user is its author::
176172
177173 // src/AppBundle/Entity/Post.php
178174 // ...
@@ -192,9 +188,7 @@ to the ``Post`` entity that checks if a given user is its author:
192188 }
193189 }
194190
195- Now you can reuse this method both in the template and in the security expression:
196-
197- .. code-block :: php
191+ Now you can reuse this method both in the template and in the security expression::
198192
199193 use AppBundle\Entity\Post;
200194 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
@@ -225,9 +219,7 @@ Checking Permissions without @Security
225219The above example with ``@Security `` only works because we're using the
226220:ref: `ParamConverter <best-practices-paramconverter >`, which gives the expression
227221access to the ``post `` variable. If you don't use this, or have some other
228- more advanced use-case, you can always do the same security check in PHP:
229-
230- .. code-block :: php
222+ more advanced use-case, you can always do the same security check in PHP::
231223
232224 /**
233225 * @Route("/{id}/edit", name="admin_post_edit")
@@ -266,9 +258,7 @@ of magnitude easier than :doc:`ACLs </security/acl>` and will give
266258you the flexibility you need in almost all cases.
267259
268260First, create a voter class. The following example shows a voter that implements
269- the same ``getAuthorEmail() `` logic you used above:
270-
271- .. code-block :: php
261+ the same ``getAuthorEmail() `` logic you used above::
272262
273263 namespace AppBundle\Security;
274264
@@ -342,9 +332,7 @@ your application will :ref:`autoconfigure <services-autoconfigure>` your securit
342332voter and inject an ``AccessDecisionManagerInterface `` instance into it thanks to
343333:doc: `autowiring </service_container/autowiring >`.
344334
345- Now, you can use the voter with the ``@Security `` annotation:
346-
347- .. code-block :: php
335+ Now, you can use the voter with the ``@Security `` annotation::
348336
349337 /**
350338 * @Route("/{id}/edit", name="admin_post_edit")
@@ -356,9 +344,7 @@ Now, you can use the voter with the ``@Security`` annotation:
356344 }
357345
358346You can also use this directly with the ``security.authorization_checker `` service or
359- via the even easier shortcut in a controller:
360-
361- .. code-block :: php
347+ via the even easier shortcut in a controller::
362348
363349 /**
364350 * @Route("/{id}/edit", name="admin_post_edit")
0 commit comments