You are here

public function ServiceManager::add in Backup and Migrate 8.4

Add a fully configured service to the service locator.

Parameters

string $type: The service type identifier.

mixed $service:

Return value

null

File

lib/backup_migrate_core/src/Service/ServiceManager.php, line 44

Class

ServiceManager
A very simple service locator. Does not handle dependency injection but could be replaced by a more complex application specific version which does.

Namespace

BackupMigrate\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);
    }
  }
}