Skip to content

Rework more controllers #7893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions best_practices/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,9 @@ the same ``getAuthorEmail()`` logic you used above:
}
}

To enable the security voter in the application, define a new service:

.. code-block:: yaml

# app/config/services.yml
services:
# ...
app.post_voter:
class: AppBundle\Security\PostVoter
arguments: ['@security.access.decision_manager']
public: false
tags: [security.voter]
Your application will :ref:`autoconfigure <services-autoconfigure>` your security
voter and inject a ``AccessDecisionManagerInterface`` instance in it thanks to
:doc:`autowiring </service_container/autowiring>`.

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

Expand Down
14 changes: 9 additions & 5 deletions form/form_dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ configuration from inside of your form class. To do this, you have 2 options:
----------------------------

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

// src/AppBundle/Form/TaskType.php
// ...
Expand All @@ -32,13 +32,17 @@ create your form::

// src/AppBundle/Controller/DefaultController.php
use AppBundle\Form\TaskType;
use Doctrine\ORM\EntityManagerInterface;

// ...
public function newAction()
public function newAction(EntityManagerInterface $em)
{
// or fetch the em via the container
// $em = $this->get('doctrine')->getManager();

$task = ...;
$form = $this->createForm(TaskType::class, $task, array(
'entity_manager' => $this->get('doctrine.orm.entity_manager')
'entity_manager' => $em,
));

// ...
Expand Down
Loading