You are here

public function Container::createInstance in Service Container 7

Same name and namespace in other branches
  1. 7.2 src/DependencyInjection/Container.php \Drupal\service_container\DependencyInjection\Container::createInstance()

File

src/DependencyInjection/Container.php, line 24
Contains \Drupal\service_container\DependencyInjection\Container

Class

Container
Container is a DI container that provides services to users of the class.

Namespace

Drupal\service_container\DependencyInjection

Code

public function createInstance($plugin_id, $service_definition) {
  $temporary_name = 'plugin_' . $plugin_id;
  $this->serviceDefinitions[$temporary_name] = $service_definition;
  $plugin = $this
    ->get($temporary_name);
  unset($this->serviceDefinitions[$temporary_name]);
  unset($this->services[$temporary_name]);
  return $plugin;
}