You are here

function xautoload in X Autoload 7.5

Same name and namespace in other branches
  1. 7.2 xautoload.module \xautoload()
  2. 7.3 xautoload.early.inc \xautoload()
  3. 7.4 xautoload.early.lib.inc \xautoload()

Get a service object from the registry. Services are lazy-created first time you need them.

Parameters

string $key: Identifier of the service within the registry. The xautoload_ServiceFactory should have a method with the same name. The recommended way (esp if you ask your IDE) is to omit this parameter and use xautoload()->$key instead.

Return value

Main|object

15 string references to 'xautoload'
AbstractDrupalBootTest::prepareAllEnabled in tests/src/DrupalBootTest/AbstractDrupalBootTest.php
Start with all available modules enabled.
AbstractDrupalBootTest::prepareInitialModules in tests/src/DrupalBootTest/AbstractDrupalBootTest.php
AbstractExampleModules::getExtensionFilename in tests/src/Example/AbstractExampleModules.php
DrupalBootTest::initialModulesVariations in tests/src/DrupalBootTest/DrupalBootTest.php
DrupalPhaseControl::checkNewExtensions in src/Phases/DrupalPhaseControl.php
Checks if new extensions have been enabled, and registers them.

... See full list

File

./xautoload.early.lib.inc, line 45

Code

function xautoload($key = 'main') {
  static $service_registry;
  static $main;
  if (!isset($service_registry)) {
    $service_factory = new ServiceFactory();
    $service_registry = new ServiceContainer($service_factory);
    $main = $service_registry->main;
  }
  switch ($key) {
    case 'main':
      return $main;
    default:

      // Legacy..
      return $service_registry
        ->get($key);
  }
}