public function EntityAliasTypeDeriver::getDerivativeDefinitions in Pathauto 8
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
- src/
Plugin/ Deriver/ EntityAliasTypeDeriver.php, line 74
Class
- EntityAliasTypeDeriver
- Deriver that exposes content entities as alias type plugins.
Namespace
Drupal\pathauto\Plugin\DeriverCode
public function getDerivativeDefinitions($base_plugin_definition) {
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
// An entity type must have a canonical link template and support fields.
if ($entity_type
->hasLinkTemplate('canonical') && is_subclass_of($entity_type
->getClass(), FieldableEntityInterface::class)) {
$base_fields = $this->entityFieldManager
->getBaseFieldDefinitions($entity_type_id);
if (!isset($base_fields['path'])) {
// The entity type does not have a path field and is therefore not
// supported.
continue;
}
$this->derivatives[$entity_type_id] = $base_plugin_definition;
$this->derivatives[$entity_type_id]['label'] = $entity_type
->getLabel();
$this->derivatives[$entity_type_id]['types'] = [
$this->tokenEntityMapper
->getTokenTypeForEntityType($entity_type_id),
];
$this->derivatives[$entity_type_id]['provider'] = $entity_type
->getProvider();
$this->derivatives[$entity_type_id]['context_definitions'] = [
$entity_type_id => new EntityContextDefinition("entity:{$entity_type_id}", $this
->t('@label being aliased', [
'@label' => $entity_type
->getLabel(),
])),
];
}
}
return $this->derivatives;
}