You are here

class PluginCollectionItemDeriver in Plugin 8.2

Derives plugin collection field items.

Hierarchy

Expanded class hierarchy of PluginCollectionItemDeriver

1 file declares its use of PluginCollectionItemDeriver
PluginCollectionItemDeriverTest.php in tests/src/Unit/Plugin/Field/FieldType/PluginCollectionItemDeriverTest.php

File

src/Plugin/Field/FieldType/PluginCollectionItemDeriver.php, line 13

Namespace

Drupal\plugin\Plugin\Field\FieldType
View source
class PluginCollectionItemDeriver extends DeriverBase implements ContainerDeriverInterface {

  /**
   * The plugin type manager.
   *
   * @var \Drupal\plugin\PluginType\PluginTypeManagerInterface
   */
  protected $pluginTypeManager;

  /**
   * Constructs a new class instance.
   *
   * @param \Drupal\plugin\PluginTypeManagerInterface
   *   The plugin type manager.
   */
  public function __construct(PluginTypeManagerInterface $plugin_type_manager) {
    $this->pluginTypeManager = $plugin_type_manager;
  }

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

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->pluginTypeManager
      ->getPluginTypes() as $plugin_type) {
      if ($plugin_type
        ->isFieldType()) {
        $this->derivatives[$plugin_type
          ->getId()] = [
          'description' => $plugin_type
            ->getDescription(),
          'label' => $plugin_type
            ->getLabel(),
          'plugin_type_id' => $plugin_type
            ->getId(),
        ] + $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
PluginCollectionItemDeriver::$pluginTypeManager protected property The plugin type manager.
PluginCollectionItemDeriver::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
PluginCollectionItemDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
PluginCollectionItemDeriver::__construct public function Constructs a new class instance.