0

Somehow I need to use aux connection / entity manager...

security.yml:

security:
    providers:
        administrators:
            entity: { class: Hoax\PartnerBundle\Entity\Partner, property: username }

config.yml:

doctrine:
    dbal:
        default_connection:   default
        connections:
            default:
                driver:   %database1_driver%
                host:     %database1_host%
                port:     %database1_port%
                dbname:   %database1_name%
                user:     %database1_user%
                password: %database1_password%
                charset:  UTF8
                mapping_types:
                    enum: string
            aux:
                driver:   %database2_driver%
                host:     %database2_host%
                port:     %database2_port%
                dbname:   %database2_name%
                user:     %database2_user%
                password: %database2_password%
                charset:  UTF8
                mapping_types:
                    enum: string

orm:
    auto_generate_proxy_classes: %kernel.debug%
    default_entity_manager:   default
    entity_managers:
        default:
            connection:       default
            mappings:
                HoaxNotificationsBundle: ~
                HoaxPartnerBundle: ~
        vpnserver:
            connection:       aux
            mappings:
                HoaxPartnerBundle: ~
        vpnpayment:
            connection:       payment
            mappings:
                HoaxPartnerBundle: ~

Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php:

class EntityUserProvider implements UserProviderInterface
{
    private $class;
    private $repository;
    private $property;
    private $metadata;

    public function __construct(ManagerRegistry $registry, $class, $property = null, $managerName = null)

I tried setting it like this: { class: Hoax\PartnerBundle\Entity\Partner, property: username, managerName: aux }

But having error: InvalidConfigurationException: Unrecognized options "managerName" under "security.providers.administrators.entity"

Roman Newaza
  • 11,405
  • 11
  • 58
  • 89
  • Read a little bit further: http://symfony.com/doc/current/cookbook/doctrine/multiple_entity_managers.html. If you still have trouble then update your question with the orm section of doctrine. – Cerad Mar 20 '14 at 16:06
  • I see you updated your question. You also need to add the entity manager name to the provider section of the security file: http://symfony.com/doc/current/reference/configuration/security.html – Cerad Mar 20 '14 at 16:10
  • I have added orm section to my question. – Roman Newaza Mar 20 '14 at 16:10
  • 2
    Ok. Now add an entity manager names aux under entity managers and have it use the aux connection. – Cerad Mar 20 '14 at 16:12
  • Thank you! Yes, actually it should be `manager_name` instead of `managerName`. Can you make it as an answer so I accept it. – Roman Newaza Mar 20 '14 at 16:14

1 Answers1

2
  1. Read a little bit further: symfony.com/doc/current/cookbook/doctrine/…. If you still have trouble then update your question with the orm section of doctrine.

  2. You also need to add the entity manager name to the provider section of the security file: symfony.com/doc/current/reference/configuration/security.html

  3. Make sure you use manager_name and not managerName

Cerad
  • 48,157
  • 8
  • 90
  • 92