You are here

class PluginSelectorDeriver in Plugin 8.2

Derives plugin selector field widgets.

Hierarchy

Expanded class hierarchy of PluginSelectorDeriver

1 file declares its use of PluginSelectorDeriver
PluginSelectorDeriverTest.php in tests/src/Unit/Plugin/Field/FieldWidget/PluginSelectorDeriverTest.php

File

src/Plugin/Field/FieldWidget/PluginSelectorDeriver.php, line 13

Namespace

Drupal\plugin\Plugin\Field\FieldWidget
View source
class PluginSelectorDeriver extends DeriverBase implements ContainerDeriverInterface {

  /**
   * The plugin selector manager.
   *
   * @var \Drupal\plugin\Plugin\Plugin\PluginSelector\PluginSelectorManagerInterface
   */
  protected $pluginSelectorManager;

  /**
   * Constructs a new class instance.
   */
  public function __construct(PluginSelectorManagerInterface $plugin_selector_manager) {
    $this->pluginSelectorManager = $plugin_selector_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container
      ->get('plugin.manager.plugin.plugin_selector'));
  }

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->pluginSelectorManager
      ->getDefinitions() as $plugin_id => $plugin_definition) {
      $this->derivatives[$plugin_id] = [
        'description' => isset($plugin_definition['description']) ? $plugin_definition['description'] : NULL,
        'label' => $plugin_definition['label'],
        'plugin_selector_id' => $plugin_id,
      ] + $base_plugin_definition;
    }
    return parent::getDerivativeDefinitions($base_plugin_definition);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
PluginSelectorDeriver::$pluginSelectorManager protected property The plugin selector manager.
PluginSelectorDeriver::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
PluginSelectorDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
PluginSelectorDeriver::__construct public function Constructs a new class instance.