function PermissionsPerBundleDeriver::getDerivativeDefinitions

Same name 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::getDerivativeDefinitions()

Overrides DeriverBase::getDerivativeDefinitions

File

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

Class

PermissionsPerBundleDeriver
@internal This API is experimental.

Namespace

Drupal\Core\Config\Action\Plugin\ConfigAction\Deriver

Code

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);
}

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