You are here

trait DependencyCollectorTrait in Drupal 7 to 8/9 Module Upgrader 8

Provides a default implementation of ContainerFactoryPluginInterface which will pull any dependencies declared in the plugin definition out of the container.

Hierarchy

File

src/DependencyCollectorTrait.php, line 12

Namespace

Drupal\drupalmoduleupgrader
View source
trait DependencyCollectorTrait {

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    $arguments = array_slice(func_get_args(), 1);
    $arguments += array_map([
      $container,
      'get',
    ], @($plugin_definition['dependencies'] ?: []));
    return (new \ReflectionClass(get_called_class()))
      ->newInstanceArgs($arguments);
  }

}

Members