jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/398654 )
Change subject: Change BlueSpice\Services to be decorator
......................................................................
Change BlueSpice\Services to be decorator
... of MediaWikiServices
Change-Id: I1d4b1eb462e9942a2f63b53087c38ba188e93ee1
---
M src/Services.php
A src/ServicesDecorator.php
2 files changed, 406 insertions(+), 9 deletions(-)
Approvals:
Robert Vogel: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/Services.php b/src/Services.php
index 5f8f51d..5ce168e 100644
--- a/src/Services.php
+++ b/src/Services.php
@@ -4,14 +4,14 @@
use MediaWiki\MediaWikiServices;
-class Services extends MediaWikiServices {
+class Services extends ServicesDecorator {
/**
*
* @return ExtensionRegistry
*/
public function getBSExtensionRegistry() {
- return $this->getService( 'BSExtensionRegistry' );
+ return $this->decoratedServices->getService(
'BSExtensionRegistry' );
}
/**
@@ -19,7 +19,7 @@
* @return ExtensionFactory
*/
public function getBSExtensionFactory() {
- return $this->getService( 'BSExtensionFactory' );
+ return $this->decoratedServices->getService(
'BSExtensionFactory' );
}
/**
@@ -27,7 +27,7 @@
* @return ConfigDefinitionFactory
*/
public function getBSConfigDefinitionFactory() {
- return $this->getService( 'BSConfigDefinitionFactory' );
+ return $this->decoratedServices->getService(
'BSConfigDefinitionFactory' );
}
/**
@@ -35,7 +35,7 @@
* @return DynamicFileDispatcher\Factory
*/
public function getBSDynamicFileDispatcherFactory() {
- return $this->getService( 'BSDynamicFileDispatcherFactory' );
+ return $this->decoratedServices->getService(
'BSDynamicFileDispatcherFactory' );
}
/**
@@ -43,7 +43,7 @@
* @return DynamicFileDispatcher\UrlBuilder
*/
public function getBSDynamicFileDispatcherUrlBuilder() {
- return $this->getService( 'BSDynamicFileDispatcherUrlBuilder' );
+ return $this->decoratedServices->getService(
'BSDynamicFileDispatcherUrlBuilder' );
}
/**
@@ -51,7 +51,7 @@
* @return EntityRegistry
*/
public function getBSEntityRegistry() {
- return $this->getService( 'BSEntityRegistry' );
+ return $this->decoratedServices->getService( 'BSEntityRegistry'
);
}
/**
@@ -59,7 +59,7 @@
* @return EntityConfigFactory
*/
public function getBSEntityConfigFactory() {
- return $this->getService( 'BSEntityConfigFactory' );
+ return $this->decoratedServices->getService(
'BSEntityConfigFactory' );
}
/**
@@ -67,6 +67,6 @@
* @return EntityFactory
*/
public function getBSEntityFactory() {
- return $this->getService( 'BSEntityFactory' );
+ return $this->decoratedServices->getService( 'BSEntityFactory'
);
}
}
\ No newline at end of file
diff --git a/src/ServicesDecorator.php b/src/ServicesDecorator.php
new file mode 100644
index 0000000..07a4008
--- /dev/null
+++ b/src/ServicesDecorator.php
@@ -0,0 +1,397 @@
+<?php
+
+namespace BlueSpice;
+
+use MediaWiki\MediaWikiServices;
+use MediaWiki\Services\ServiceContainer;
+
+class ServicesDecorator extends ServiceContainer {
+
+ /**
+ * @var Services|null
+ */
+ protected static $instance = null;
+
+ /**
+ * Returns the global default instance of the top level service locator.
+ *
+ * @since 1.27
+ *
+ * The default instance is initialized using the service instantiator
functions
+ * defined in ServiceWiring.php.
+ *
+ * @note This should only be called by static functions! The instance
returned here
+ * should not be passed around! Objects that need access to a service
should have
+ * that service injected into the constructor, never a service locator!
+ *
+ * @return Services
+ */
+ public static function getInstance() {
+ if ( static::$instance === null ) {
+ static::$instance = static::newInstance(
MediaWikiServices::getInstance() );
+ }
+
+ return static::$instance;
+ }
+
+ /**
+ *
+ * @var MediaWikiServices
+ */
+ protected $decoratedServices = null;
+
+ public function __construct( $services ) {
+ $this->decoratedServices = $services;
+ }
+
+ /**
+ * @params MediaWikiServices
+ * @return Services
+ * @throws MWException
+ * @throws \FatalError
+ */
+ private static function newInstance( $services ) {
+ $instance = new static( $services );
+
+ \Hooks::run( 'BlueSpiceServices', [ $instance ] );
+
+ return $instance;
+ }
+
+ /**
+ * Returns a service object of the kind associated with $name.
+ * Services instances are instantiated lazily, on demand.
+ * This method may or may not return the same service instance
+ * when called multiple times with the same $name.
+ *
+ * @note Rather than calling this method directly, it is recommended to
provide
+ * getters with more meaningful names and more specific return types,
using
+ * a subclass or wrapper.
+ *
+ * @see redefineService().
+ *
+ * @param string $name The service name
+ *
+ * @throws NoSuchServiceException if $name is not a known service.
+ * @throws ContainerDisabledException if this container has already
been destroyed.
+ * @throws ServiceDisabledException if the requested service has been
disabled.
+ *
+ * @return object The service instance
+ */
+ public function getService( $name ) {
+ return $this->decoratedServices->getService( $name );
+ }
+
+ /**
+ * Returns the Config object containing the bootstrap configuration.
+ * Bootstrap configuration would typically include database credentials
+ * and other information that may be needed before the ConfigFactory
+ * service can be instantiated.
+ *
+ * @note This should only be used during bootstrapping, in particular
+ * when creating the MainConfig service. Application logic should
+ * use getMainConfig() to get a Config instances.
+ *
+ * @since 1.27
+ * @return Config
+ */
+ public function getBootstrapConfig() {
+ return $this->decoratedServices->getService( 'BootstrapConfig'
);
+ }
+
+ /**
+ * @since 1.27
+ * @return ConfigFactory
+ */
+ public function getConfigFactory() {
+ return $this->decoratedServices->getService( 'ConfigFactory' );
+ }
+
+ /**
+ * Returns the Config object that provides configuration for MediaWiki
core.
+ * This may or may not be the same object that is returned by
getBootstrapConfig().
+ *
+ * @since 1.27
+ * @return Config
+ */
+ public function getMainConfig() {
+ return $this->decoratedServices->getService( 'MainConfig' );
+ }
+
+ /**
+ * @since 1.27
+ * @return SiteLookup
+ */
+ public function getSiteLookup() {
+ return $this->decoratedServices->getService( 'SiteLookup' );
+ }
+
+ /**
+ * @since 1.27
+ * @return SiteStore
+ */
+ public function getSiteStore() {
+ return $this->decoratedServices->getService( 'SiteStore' );
+ }
+
+ /**
+ * @since 1.28
+ * @return InterwikiLookup
+ */
+ public function getInterwikiLookup() {
+ return $this->decoratedServices->getService( 'InterwikiLookup'
);
+ }
+
+ /**
+ * @since 1.27
+ * @return IBufferingStatsdDataFactory
+ */
+ public function getStatsdDataFactory() {
+ return $this->decoratedServices->getService(
'StatsdDataFactory' );
+ }
+
+ /**
+ * @since 1.27
+ * @return EventRelayerGroup
+ */
+ public function getEventRelayerGroup() {
+ return $this->decoratedServices->getService(
'EventRelayerGroup' );
+ }
+
+ /**
+ * @since 1.27
+ * @return SearchEngine
+ */
+ public function newSearchEngine() {
+ // New engine object every time, since they keep state
+ return $this->decoratedServices->getService(
'SearchEngineFactory' )->create();
+ }
+
+ /**
+ * @since 1.27
+ * @return SearchEngineFactory
+ */
+ public function getSearchEngineFactory() {
+ return $this->decoratedServices->getService(
'SearchEngineFactory' );
+ }
+
+ /**
+ * @since 1.27
+ * @return SearchEngineConfig
+ */
+ public function getSearchEngineConfig() {
+ return $this->decoratedServices->getService(
'SearchEngineConfig' );
+ }
+
+ /**
+ * @since 1.27
+ * @return SkinFactory
+ */
+ public function getSkinFactory() {
+ return $this->decoratedServices->getService( 'SkinFactory' );
+ }
+
+ /**
+ * @since 1.28
+ * @return LBFactory
+ */
+ public function getDBLoadBalancerFactory() {
+ return $this->decoratedServices->getService(
'DBLoadBalancerFactory' );
+ }
+
+ /**
+ * @since 1.28
+ * @return LoadBalancer The main DB load balancer for the local wiki.
+ */
+ public function getDBLoadBalancer() {
+ return $this->decoratedServices->getService( 'DBLoadBalancer' );
+ }
+
+ /**
+ * @since 1.28
+ * @return WatchedItemStoreInterface
+ */
+ public function getWatchedItemStore() {
+ return $this->decoratedServices->getService( 'WatchedItemStore'
);
+ }
+
+ /**
+ * @since 1.28
+ * @return WatchedItemQueryService
+ */
+ public function getWatchedItemQueryService() {
+ return $this->decoratedServices->getService(
'WatchedItemQueryService' );
+ }
+
+ /**
+ * @since 1.28
+ * @return CryptRand
+ */
+ public function getCryptRand() {
+ return $this->decoratedServices->getService( 'CryptRand' );
+ }
+
+ /**
+ * @since 1.28
+ * @return CryptHKDF
+ */
+ public function getCryptHKDF() {
+ return $this->decoratedServices->getService( 'CryptHKDF' );
+ }
+
+ /**
+ * @since 1.28
+ * @return MediaHandlerFactory
+ */
+ public function getMediaHandlerFactory() {
+ return $this->decoratedServices->getService(
'MediaHandlerFactory' );
+ }
+
+ /**
+ * @since 1.28
+ * @return MimeAnalyzer
+ */
+ public function getMimeAnalyzer() {
+ return $this->decoratedServices->getService( 'MimeAnalyzer' );
+ }
+
+ /**
+ * @since 1.28
+ * @return ProxyLookup
+ */
+ public function getProxyLookup() {
+ return $this->decoratedServices->getService( 'ProxyLookup' );
+ }
+
+ /**
+ * @since 1.29
+ * @return Parser
+ */
+ public function getParser() {
+ return $this->decoratedServices->getService( 'Parser' );
+ }
+
+ /**
+ * @since 1.30
+ * @return ParserCache
+ */
+ public function getParserCache() {
+ return $this->decoratedServices->getService( 'ParserCache' );
+ }
+
+ /**
+ * @since 1.28
+ * @return GenderCache
+ */
+ public function getGenderCache() {
+ return $this->decoratedServices->getService( 'GenderCache' );
+ }
+
+ /**
+ * @since 1.28
+ * @return LinkCache
+ */
+ public function getLinkCache() {
+ return $this->decoratedServices->getService( 'LinkCache' );
+ }
+
+ /**
+ * @since 1.28
+ * @return LinkRendererFactory
+ */
+ public function getLinkRendererFactory() {
+ return $this->decoratedServices->getService(
'LinkRendererFactory' );
+ }
+
+ /**
+ * LinkRenderer instance that can be used
+ * if no custom options are needed
+ *
+ * @since 1.28
+ * @return LinkRenderer
+ */
+ public function getLinkRenderer() {
+ return $this->decoratedServices->getService( 'LinkRenderer' );
+ }
+
+ /**
+ * @since 1.28
+ * @return TitleFormatter
+ */
+ public function getTitleFormatter() {
+ return $this->decoratedServices->getService( 'TitleFormatter' );
+ }
+
+ /**
+ * @since 1.28
+ * @return TitleParser
+ */
+ public function getTitleParser() {
+ return $this->decoratedServices->getService( 'TitleParser' );
+ }
+
+ /**
+ * @since 1.28
+ * @return \BagOStuff
+ */
+ public function getMainObjectStash() {
+ return $this->decoratedServices->getService( 'MainObjectStash'
);
+ }
+
+ /**
+ * @since 1.28
+ * @return \WANObjectCache
+ */
+ public function getMainWANObjectCache() {
+ return $this->decoratedServices->getService(
'MainWANObjectCache' );
+ }
+
+ /**
+ * @since 1.28
+ * @return \BagOStuff
+ */
+ public function getLocalServerObjectCache() {
+ return $this->decoratedServices->getService(
'LocalServerObjectCache' );
+ }
+
+ /**
+ * @since 1.28
+ * @return VirtualRESTServiceClient
+ */
+ public function getVirtualRESTServiceClient() {
+ return $this->decoratedServices->getService(
'VirtualRESTServiceClient' );
+ }
+
+ /**
+ * @since 1.29
+ * @return \ConfiguredReadOnlyMode
+ */
+ public function getConfiguredReadOnlyMode() {
+ return $this->decoratedServices->getService(
'ConfiguredReadOnlyMode' );
+ }
+
+ /**
+ * @since 1.29
+ * @return \ReadOnlyMode
+ */
+ public function getReadOnlyMode() {
+ return $this->decoratedServices->getService( 'ReadOnlyMode' );
+ }
+
+ /**
+ * @since 1.30
+ * @return CommandFactory
+ */
+ public function getShellCommandFactory() {
+ return $this->decoratedServices->getService(
'ShellCommandFactory' );
+ }
+
+ /**
+ * @since 1.31
+ * @return \ExternalStoreFactory
+ */
+ public function getExternalStoreFactory() {
+ return $this->decoratedServices->getService(
'ExternalStoreFactory' );
+ }
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/398654
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1d4b1eb462e9942a2f63b53087c38ba188e93ee1
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>
Gerrit-Reviewer: Ljonka <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: Robert Vogel <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits