function EntityBundle::getDerivativeDefinitions

Same name in other branches
  1. 10 core/lib/Drupal/Core/Entity/Plugin/Condition/Deriver/EntityBundle.php \Drupal\Core\Entity\Plugin\Condition\Deriver\EntityBundle::getDerivativeDefinitions()
  2. 11.x core/lib/Drupal/Core/Entity/Plugin/Condition/Deriver/EntityBundle.php \Drupal\Core\Entity\Plugin\Condition\Deriver\EntityBundle::getDerivativeDefinitions()

Overrides DeriverBase::getDerivativeDefinitions

File

core/lib/Drupal/Core/Entity/Plugin/Condition/Deriver/EntityBundle.php, line 45

Class

EntityBundle
Deriver that creates a condition for each entity type with bundles.

Namespace

Drupal\Core\Entity\Plugin\Condition\Deriver

Code

public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->entityTypeManager
        ->getDefinitions() as $entity_type_id => $entity_type) {
        if ($entity_type->hasKey('bundle')) {
            $this->derivatives[$entity_type_id] = $base_plugin_definition;
            $this->derivatives[$entity_type_id]['label'] = $entity_type->getBundleLabel();
            $this->derivatives[$entity_type_id]['provider'] = $entity_type->getProvider();
            $this->derivatives[$entity_type_id]['context_definitions'] = [
                $entity_type_id => EntityContextDefinition::fromEntityType($entity_type),
            ];
        }
    }
    return $this->derivatives;
}

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