@mnapoli opened this issue on March 10th 2015

This introduces the ability to use dependency injection in API classes.

This also registers API classes in the container (so these classes can be injected), though they are still singletons. The problem is that the singleton pattern in Piwik also offers unsetInstance() and setSingletonInstance() and I think this would mess up with the container, but since those should only be used in tests (right?) we should be fine and be able to fix it easily.

@diosmosis commented on March 11th 2015

Re: unsetInstance()/setSingletonInstance(), we could mark them as deprecated. I don't think anyone's supposed to use them anyway, and eventually we'll be able to remove them entirely.

@diosmosis commented on March 11th 2015

:+1: for DI!

@mnapoli commented on March 11th 2015

Good point! They are only used in tests except in the LanguagesManager to "clear the cache" basically so this could be replaced by something better.

I've added the deprecations.

@mattab commented on March 12th 2015

Looks good to me!

+1 to deprecate unsetInstance/ setSingletonInstance and remove it in couple months.

(I noticed there are protected constructors in InterSites and CustomAlerts maybe those can be changed after PR is merged)

This issue was closed on March 17th 2015
Powered by GitHub Issue Mirror