public function DynamicLocalTasks::getDerivativeDefinitions in Workbench Moderation 8
Same name and namespace in other branches
- 8.2 src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\workbench_moderation\Plugin\Derivative\DynamicLocalTasks::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
- src/
Plugin/ Derivative/ DynamicLocalTasks.php, line 66
Class
- DynamicLocalTasks
- Generates moderation-related local tasks.
Namespace
Drupal\workbench_moderation\Plugin\DerivativeCode
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = [];
foreach ($this
->moderatableEntityTypeDefinitions() as $entity_type_id => $entity_type) {
$this->derivatives["{$entity_type_id}.moderation_tab"] = [
'route_name' => "entity.{$entity_type_id}.moderation",
'title' => $this
->t('Manage moderation'),
// @todo - are we sure they all have an edit_form?
'base_route' => "entity.{$entity_type_id}.edit_form",
'weight' => 30,
] + $base_plugin_definition;
}
$latest_version_entities = array_filter($this
->moderatableEntityDefinitions(), function (EntityTypeInterface $type) {
return $type
->hasLinkTemplate('latest-version');
});
foreach ($latest_version_entities as $entity_type_id => $entity_type) {
$this->derivatives["{$entity_type_id}.latest_version_tab"] = [
'route_name' => "entity.{$entity_type_id}.latest_version",
'title' => $this
->t('Latest version'),
'base_route' => "entity.{$entity_type_id}.canonical",
'weight' => 1,
] + $base_plugin_definition;
}
return $this->derivatives;
}