class PermissionsPerBundleDeriver

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/Deriver/PermissionsPerBundleDeriver.php \Drupal\Core\Config\Action\Plugin\ConfigAction\Deriver\PermissionsPerBundleDeriver

@internal This API is experimental.

Hierarchy

Expanded class hierarchy of PermissionsPerBundleDeriver

1 file declares its use of PermissionsPerBundleDeriver
PermissionsPerBundle.php in core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/PermissionsPerBundle.php

File

core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/Deriver/PermissionsPerBundleDeriver.php, line 17

Namespace

Drupal\Core\Config\Action\Plugin\ConfigAction\Deriver
View source
final class PermissionsPerBundleDeriver extends DeriverBase implements ContainerDeriverInterface {
  public function __construct(private readonly EntityTypeManagerInterface $entityTypeManager) {
  }
  
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, $base_plugin_id) {
    return new static($container->get(EntityTypeManagerInterface::class));
  }
  
  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->entityTypeManager
      ->getDefinitions() as $id => $entity_type) {
      if ($entity_type->getPermissionGranularity() === 'bundle' && ($bundle_entity_type = $entity_type->getBundleEntityType()) !== NULL) {
        // Convert unique plugin IDs, like `taxonomy_vocabulary`, into strings
        // like `TaxonomyVocabulary`.
        $suffix = Container::camelize($bundle_entity_type);
        $this->derivatives["grantPermissionsForEach{$suffix}"] = [
          'target_entity_type' => $id,
        ] + $base_plugin_definition;
      }
    }
    return parent::getDerivativeDefinitions($base_plugin_definition);
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
DeriverBase::$derivatives protected property List of derivative definitions. 1
DeriverBase::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
PermissionsPerBundleDeriver::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
PermissionsPerBundleDeriver::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverBase::getDerivativeDefinitions
PermissionsPerBundleDeriver::__construct public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.