From 9eb911786f09fbc3d7f4adf1835cf0acb7e8362e Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 14 Jul 2014 20:17:32 +0200 Subject: [PATCH] usage of a non-default entity manager in an entity user provider The cookbook on entity user providers for the Security component only describes how to create an entity provider using the default entity manager. This may not be sufficient enough if you have multiple entity managers and therefore be eplicit with the entity manager to use in the user provider. --- cookbook/security/entity_provider.rst | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/cookbook/security/entity_provider.rst b/cookbook/security/entity_provider.rst index 80e0b08270b..40f88eb2bae 100644 --- a/cookbook/security/entity_provider.rst +++ b/cookbook/security/entity_provider.rst @@ -358,6 +358,69 @@ entity user provider to load User entity objects from the database by using the ``username`` unique field. In other words, this tells Symfony how to fetch the user from the database before checking the password validity. +.. note:: + + By default, the entity provider uses the default entity manager to fetch + user information from the database. If you, + :doc:`use multiple entity managers `, + you can specify which manager to use with the ``manager_name`` option: + + .. configuration-block:: + + .. code-block:: yaml + + # app/config/config.yml + security: + # ... + + providers: + administrators: + entity: + class: AcmeUserBundle:User + property: username + manager_name: customer + + # ... + + .. code-block:: xml + + + + + + + + + + + + + + + + .. code-block:: php + + // app/config/config.php + $container->loadFromExtension('security', array( + // ... + 'providers' => array( + 'administrator' => array( + 'entity' => array( + 'class' => 'AcmeUserBundle:User', + 'property' => 'username', + 'manager_name' => 'customer', + ), + ), + ), + // ... + )); + Forbid inactive Users ---------------------