You are here

public function ServiceManager::add in Backup and Migrate 5.0.x

Add a fully configured service to the service locator.

Parameters

string $type: The service type identifier.

mixed $service:

File

src/Core/Service/ServiceManager.php, line 42

Class

ServiceManager
A very simple service locator.

Namespace

Drupal\backup_migrate\Core\Service

Code

public function add($type, $service) {
  $this->services[$type] = $service;

  // Add this service as a client so it can have dependencies injected.
  $this
    ->addClient($service);

  // Update any plugins that have already had this service injected.
  if (isset($this->clients[$type])) {
    foreach ($this->clients[$type] as $client) {
      $client
        ->{'set' . $type}($service);
    }
  }
}