Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Remove ServiceLocatorAwareInterface from table gateways. #910
2 times, most recently
Feb 8, 2017
Here's some more ServiceLocatorAwareInterface refactoring to complement #909. Once again, a few more eyes on the problem would be appreciated to make sure I haven't done anything foolish. From @EreMaijala, I'm particularly interested in whether this will break any hard-to-test features like the ExternalSessions table. So far, all commonly-tested features seem to be working as normal.
No, I think that NAMESPACE is constant to the file, even if you subclass it. If you need to build objects using a different namespace, we should either add a parameter to the function to allow a namespace override, or else you should duplicate the method in your own factory.
I also don't claim that the __callStatic() approach I'm using in the factory here is really the best way to do this -- it was just a simple approach to get everything working quickly. The most common practice these days seems to be one factory class per class. I still think the idea of having a single collection of static factory methods has some benefits, but I could certainly be persuaded to bring VuFInd in line with other projects in the future, especially if changes to the ZF 3.0 ServiceManager require a rewrite of all of the factories (which may be a possibility).
@EreMaijala, I've just revised the commit to include a better version of the factory. Now, instead of using __callStatic everywhere, I've created a getGenericTable method that supports either a relative or absolute class name. __callStatic is now a lightweight wrapper around getGenericTable (as are all of the other more explicit factories). In addition to supporting your use case, this also better isolates the messy "magic" method name munging from the cleaner process of actually building the table objects. Thanks again for the input; please let me know if you have trouble with this, or any other concerns.