class CreateForEachBundleDeriver
Generates derivatives for the create_for_each_bundle config action.
@internal This API is experimental.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements \Drupal\Component\Plugin\Derivative\DeriverInterface
- class \Drupal\Core\Config\Action\Plugin\ConfigAction\Deriver\CreateForEachBundleDeriver extends \Drupal\Component\Plugin\Derivative\DeriverBase implements \Drupal\Core\Plugin\Discovery\ContainerDeriverInterface
Expanded class hierarchy of CreateForEachBundleDeriver
1 file declares its use of CreateForEachBundleDeriver
- CreateForEachBundle.php in core/
lib/ Drupal/ Core/ Config/ Action/ Plugin/ ConfigAction/ CreateForEachBundle.php
File
-
core/
lib/ Drupal/ Core/ Config/ Action/ Plugin/ ConfigAction/ Deriver/ CreateForEachBundleDeriver.php, line 19
Namespace
Drupal\Core\Config\Action\Plugin\ConfigAction\DeriverView source
final class CreateForEachBundleDeriver extends DeriverBase implements ContainerDeriverInterface {
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) : static {
return new static($container->get(EntityTypeManagerInterface::class));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) : array {
// The action should only be available for entity types that are bundles of
// another entity type, such as node types, media types, taxonomy
// vocabularies, and so forth.
$bundle_entity_types = array_filter($this->entityTypeManager
->getDefinitions(), fn(EntityTypeInterface $entity_type) => is_string($entity_type->getBundleOf()));
$base_plugin_definition['entity_types'] = array_keys($bundle_entity_types);
$this->derivatives['createForEachIfNotExists'] = $base_plugin_definition + [
'create_action' => 'createIfNotExists',
];
$this->derivatives['createForEach'] = $base_plugin_definition + [
'create_action' => 'create',
];
return $this->derivatives;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
CreateForEachBundleDeriver::create | public static | function | Creates a new class instance. | Overrides ContainerDeriverInterface::create | |
CreateForEachBundleDeriver::getDerivativeDefinitions | public | function | Gets the definition of all derivatives of a base plugin. | Overrides DeriverBase::getDerivativeDefinitions | |
CreateForEachBundleDeriver::__construct | public | function | |||
DeriverBase::$derivatives | protected | property | List of derivative definitions. | 1 | |
DeriverBase::getDerivativeDefinition | public | function | Gets the definition of a derivative plugin. | Overrides DeriverInterface::getDerivativeDefinition |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.