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
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.
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.
:+1: for DI!
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.
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)