Services
From semantic-mediawiki.org
Services contain object definitions that with the help of a builder will handle the object build process and provides instance reuse, if necessary.
$smwgServicesFileDir describes the location of the services directory.
Services factory
Object instances are generally accessed using the ServicesFactory locator and its public methods.
Service files and containers
Files
importer.phpprovides services for the Importermediawiki.phpisolates MediaWiki specific functions and servicesevents.phpisolates event services
Containers
SharedServicesContainer.phpcontains common and shared object definitions used throughout the Semantic MediaWiki code base and are accessible viaServicesFactoryServicesContainertemporary container to be used to inject services into a object instance
Service specific factories
DataValueServiceFactoryprovides service and factory functions forDataValueobjects that are specified indatavalues.phpImporterServiceFactory
Services registration
$containerBuilder = new CallbackContainerFactory();
$containerBuilder = $callbackContainerFactory->newCallbackContainerBuilder();
$containerBuilder->registerCallbackContainer( new SharedServicesContainer() );
$containerBuilder->registerFromFile(
$GLOBALS['smwgServicesFileDir'] . '/' . 'mediawiki.php'
);
Example for a service[edit]
- Extraneous language − provides "extraneous" language functions independent of MediaWiki required by Semantic MediaWiki and its registration system.