Making an entity repository container aware in Symfony2.1
By Iain Cuthbertson
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:
Comments
KingCrunch says: 16th February 2013 at 11:30 am
If your EntityRepository needs to know about the DIC, you made it wrong…
Wessel says: 13th June 2013 at 12:03 pm
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: 26th February 2014 at 5:20 am
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.