You are here

class GenericDeriver in Drupal 7 to 8/9 Module Upgrader 8

Builds derivative definitions for the generic rewriter, based on the drupalmoduleupgrader.rewriters configuration object.

Hierarchy

Expanded class hierarchy of GenericDeriver

File

src/Plugin/DMU/Rewriter/GenericDeriver.php, line 12

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Rewriter
View source
class GenericDeriver implements ContainerDeriverInterface {

  /**
   * @var array
   */
  protected $config;
  public function __construct(array $config) {
    $this->config = $config;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container
      ->get('config.factory')
      ->get('drupalmoduleupgrader.rewriters')
      ->get('definitions'));
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinition($derivative_id, $base_definition) {
    $derivatives = $this
      ->getDerivativeDefinitions($base_definition);
    if (isset($derivatives[$derivative_id])) {
      return $derivatives[$derivative_id];
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_definition) {
    $derivatives = [];
    foreach ($this->config as $data_type => $definition) {
      $derivatives[$data_type] = $definition + $base_definition;
    }
    return $derivatives;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GenericDeriver::$config protected property
GenericDeriver::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
GenericDeriver::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
GenericDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverInterface::getDerivativeDefinitions
GenericDeriver::__construct public function