class EntityBundle in Drupal 9
Same name in this branch
- 9 core/lib/Drupal/Core/Entity/Plugin/Condition/EntityBundle.php \Drupal\Core\Entity\Plugin\Condition\EntityBundle
- 9 core/lib/Drupal/Core/Entity/Plugin/Condition/Deriver/EntityBundle.php \Drupal\Core\Entity\Plugin\Condition\Deriver\EntityBundle
Deriver that creates a condition for each entity type with bundles.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\Core\Entity\Plugin\Condition\Deriver\EntityBundle implements ContainerDeriverInterface
Expanded class hierarchy of EntityBundle
File
- core/
lib/ Drupal/ Core/ Entity/ Plugin/ Condition/ Deriver/ EntityBundle.php, line 14
Namespace
Drupal\Core\Entity\Plugin\Condition\DeriverView source
class EntityBundle extends DeriverBase implements ContainerDeriverInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a new EntityBundle.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@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
->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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
EntityBundle:: |
protected | property | The entity type manager. | |
EntityBundle:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
EntityBundle:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
EntityBundle:: |
public | function | Constructs a new EntityBundle. |