Skip to content

Commit 14cd4c4

Browse files
committed
feature #7893 Rework more controllers (GuilhemN)
This PR was squashed before being merged into the master branch (closes #7893). Discussion ---------- Rework more controllers Commits ------- 3b75147 update 1f6edd4 Rework more controllers
2 parents e437d9d + 3b75147 commit 14cd4c4

File tree

3 files changed

+131
-97
lines changed

3 files changed

+131
-97
lines changed

best_practices/security.rst

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -328,18 +328,9 @@ the same ``getAuthorEmail()`` logic you used above:
328328
}
329329
}
330330
331-
To enable the security voter in the application, define a new service:
332-
333-
.. code-block:: yaml
334-
335-
# app/config/services.yml
336-
services:
337-
# ...
338-
app.post_voter:
339-
class: AppBundle\Security\PostVoter
340-
arguments: ['@security.access.decision_manager']
341-
public: false
342-
tags: [security.voter]
331+
Your application will :ref:`autoconfigure <services-autoconfigure>` your security
332+
voter and inject a ``AccessDecisionManagerInterface`` instance in it thanks to
333+
:doc:`autowiring </service_container/autowiring>`.
343334

344335
Now, you can use the voter with the ``@Security`` annotation:
345336

form/form_dependencies.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ configuration from inside of your form class. To do this, you have 2 options:
88
----------------------------
99

1010
The simplest way to pass services or configuration to your form is via form *options*.
11-
Suppose you need to access the ``doctrine.orm.entity_manager`` service so that you
12-
can make a query. First, allow (in fact, require) a new ``entity_manager`` option
13-
to be passed to your form::
11+
Suppose you need to access the Doctrine entity manager so that you can make a
12+
query. First, allow (in fact, require) a new ``entity_manager`` option to be
13+
passed to your form::
1414

1515
// src/AppBundle/Form/TaskType.php
1616
// ...
@@ -32,13 +32,17 @@ create your form::
3232

3333
// src/AppBundle/Controller/DefaultController.php
3434
use AppBundle\Form\TaskType;
35+
use Doctrine\ORM\EntityManagerInterface;
3536

3637
// ...
37-
public function newAction()
38+
public function newAction(EntityManagerInterface $em)
3839
{
40+
// or fetch the em via the container
41+
// $em = $this->get('doctrine')->getManager();
42+
3943
$task = ...;
4044
$form = $this->createForm(TaskType::class, $task, array(
41-
'entity_manager' => $this->get('doctrine.orm.entity_manager')
45+
'entity_manager' => $em,
4246
));
4347

4448
// ...

0 commit comments

Comments
 (0)