You are here

class TaxonomyHierarchySelectionDeriver in Workbench Access 8

Defines a deriver for taxonomy hierarchy selection plugins.

Hierarchy

Expanded class hierarchy of TaxonomyHierarchySelectionDeriver

File

src/Plugin/Deriver/TaxonomyHierarchySelectionDeriver.php, line 13

Namespace

Drupal\workbench_access\Plugin\Deriver
View source
class TaxonomyHierarchySelectionDeriver extends DeriverBase implements ContainerDeriverInterface {

  /**
   * Label.
   *
   * @var string
   */
  protected $label = 'Restricted Taxonomy Term selection: @name';

  /**
   * Entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a new SectionViewsPluginDeriver object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   Entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entityTypeManager) {
    $this->entityTypeManager = $entityTypeManager;
  }

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

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->entityTypeManager
      ->getStorage('access_scheme')
      ->loadMultiple() as $id => $scheme) {
      $this->derivatives[$id] = [
        'scheme' => $id,
        'label' => $scheme
          ->label(),
      ] + $base_plugin_definition;
    }
    return $this->derivatives;
  }

}

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
TaxonomyHierarchySelectionDeriver::$entityTypeManager protected property Entity type manager.
TaxonomyHierarchySelectionDeriver::$label protected property Label. 1
TaxonomyHierarchySelectionDeriver::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
TaxonomyHierarchySelectionDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
TaxonomyHierarchySelectionDeriver::__construct public function Constructs a new SectionViewsPluginDeriver object.