Dependency and service injection

Semantic MediaWiki uses a minimalistic dependency and service injection mechanism to ensure that recurring class invocations are managed in a central place to avoid complex interface maintenance and support for advanced service factoring.

hosts the definitions (internally managed by ) and is made available through the   as a so called.

Direct wp:dependency injection is always preferred but sometimes it is unavoidable to rely on an indirect service access therefore some guidelines should be considered when deciding for or against using a service definition:


 * When a service is expected to be used more than once and/or requested in different places
 * When an interface is not easily extensible and testing is paramount, providing access via  (  to override an instance during testing)

Furthermore, for a complex service, using a dedicated factory method (which can involve a service locator) is preferred over a simple.