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:

3 thoughts on “Making an entity repository container aware in Symfony2.1”

  1. 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!

    1. 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

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.