Making an entity repository container aware in Symfony2.1

I had a need to add ACL rules to entities at the repository level.

My biggest struggle was getting dependancy injection working.

This is what I finally came up with after a fresh mind and an instant coffee:

You can leave a response, or trackback from your own site.

3 Responses to “Making an entity repository container aware in Symfony2.1”

  1. KingCrunch says:

    If your EntityRepository needs to know about the DIC, you made it wrong…

  2. Wessel says:

    Mmm nice trick.
    I do get the idea of separation, however suppose I have a helper class with a lof of common string manipulations I have to do from and to the database in every entityRepository.
    Pulling it out of the Container sounds a lot cleaner than duplicate the code?
    Anyone have a proper idea how this would be handled correctly?

    Thanks!

    • Kevin says:

      Why would you not want to use a trait to implement the string manipulation functions? Then each class that needs those functions can use the trait.

Leave a Reply