Introduce top level service locator.
authordaniel <daniel.kinzler@wikimedia.de>
Mon, 12 Oct 2015 08:05:45 +0000 (10:05 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Sat, 2 Apr 2016 15:07:28 +0000 (18:07 +0300)
commiteb46307b001ad116426b866b506ef49fb21f1e3d
tree411531f1ab8029dc2b719171a49a9b7428678455
parent6906de45c1d5edc38a14e9cbbed6337960b1ff0d
Introduce top level service locator.

The service locator, MediaWikiServices, is intended to facilitate
"manual" dependency injection in static entry points.

See also the Dependency Injection RFC T384 and Service Locator
RFC T124792 for details.
The following key points were implemented according the
discussion surrounding these RFCs:

* a configurable DI container that allows extensions to add and replace services.
* no auto-wiring, since it's prone to add confusion in large and complex applications.
* no 3rd party framework, since they typically do too much.

The following services in MediaWiki core are made accessible via the service locator
mechanism to showcase the bootstrapping mechanism:

* ConfigFactory and MainConfig
* SiteLookup and SiteStore

However, the implementation of these services was not yet converted to using proper DI
throughout the code.

Bug: T124792
Change-Id: I3c25c0ac17300d3dd13e1cf5100558a605eee15f
22 files changed:
autoload.php
docs/hooks.txt
docs/injection.txt [new file with mode: 0644]
includes/DefaultSettings.php
includes/MediaWikiServices.php [new file with mode: 0644]
includes/ServiceWiring.php [new file with mode: 0644]
includes/Services/ServiceContainer.php [new file with mode: 0644]
includes/WikiMap.php
includes/config/ConfigFactory.php
includes/site/DBSiteStore.php
includes/site/SiteSQLStore.php
maintenance/exportSites.php
maintenance/importSites.php
maintenance/rebuildSitesCache.php
tests/phpunit/includes/MediaWikiServicesTest.php [new file with mode: 0644]
tests/phpunit/includes/Services/ServiceContainerTest.php [new file with mode: 0644]
tests/phpunit/includes/Services/TestWiring1.php [new file with mode: 0644]
tests/phpunit/includes/Services/TestWiring2.php [new file with mode: 0644]
tests/phpunit/includes/config/ConfigFactoryTest.php
tests/phpunit/includes/site/DBSiteStoreTest.php
tests/phpunit/includes/site/SiteSQLStoreTest.php [deleted file]
tests/phpunit/includes/site/TestSites.php