public function WorkbenchAccessControlDeriver::getDerivativeDefinitions in Entity Reference Hierarchy 3.x
Same name and namespace in other branches
- 8.2 modules/entity_hierarchy_workbench_access/src/Plugin/Derivative/WorkbenchAccessControlDeriver.php \Drupal\entity_hierarchy_workbench_access\Plugin\Derivative\WorkbenchAccessControlDeriver::getDerivativeDefinitions()
Gets the definition of all derivatives of a base plugin.
Parameters
array $base_plugin_definition: The definition array of the base plugin.
Return value
array An array of full derivative definitions keyed on derivative id.
Overrides DeriverBase::getDerivativeDefinitions
See also
getDerivativeDefinition()
File
- modules/
entity_hierarchy_workbench_access/ src/ Plugin/ Derivative/ WorkbenchAccessControlDeriver.php, line 73
Class
- WorkbenchAccessControlDeriver
- Defines a class for deriving workbench access plugins for hierarchies.
Namespace
Drupal\entity_hierarchy_workbench_access\Plugin\DerivativeCode
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = [];
foreach ($this->entityFieldManager
->getFieldMapByFieldType('entity_reference_hierarchy') as $entity_type_id => $fields) {
/** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
$entity_type = $this->entityTypeManager
->getDefinition($entity_type_id);
foreach ($fields as $field_name => $bundles) {
$this->derivatives["{$entity_type_id}__{$field_name}"] = [
'label' => $this
->t('@entity_type (@field)', [
'@entity_type' => $entity_type
->getLabel(),
'@field' => $field_name,
]),
'base_entity' => $entity_type
->getBundleEntityType() ?: $entity_type_id,
'entity' => $entity_type_id,
'field_name' => $field_name,
] + $base_plugin_definition;
}
}
return $this->derivatives;
}