0

My example application has two bundles, AcmeAuthenticationBundle and AcmePhonelistbundle.

In AcmeAuthenticationBundle I created a user entity which I need for authentication (obviously) that has some user specific attributes (like surname, givename, etc.). In AcmePhonelistBundle I want to generate a phonelist based on that user entity.

For this purpose I created a service that gets the doctrine entity manager and the user class (in doctrine shorthand form) injected (defined in services.yml):

parameters:
    acme_phonelist.user.class: AcmeAuthenticationBundle:User

services:
    acme_phonelist.factory:
        class: Acme\PhonelistBundle\Factory\PhonelistFactory
        arguments:
            em: "@doctrine.orm.entity_manager"
            userClass: "%acme_phonelist.user.class%"

I couldn't come up with a different/better solution to keep those bundles decoupled. Is this a proper/sane way for this use case or did I overlook something? Any suggestions for improvement?

nietonfir
  • 4,797
  • 6
  • 31
  • 43

1 Answers1

1

Create a bundle or a service with the sole purpose of containing user-specific data, and reuse it in both the phonelist and the authenticationbundle.

tobi_p
  • 26
  • 1
  • After having implemented your proposed solution I found out that I can use doctrine repositories as services (see http://stackoverflow.com/questions/17228417/symfony-2-creating-a-service-from-a-repository). – nietonfir Aug 30 '13 at 09:50