public function MandrillActivityLocalTasks::getDerivativeDefinitions in Mandrill 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
- modules/
mandrill_activity/ src/ Plugin/ Derivative/ MandrillActivityLocalTasks.php, line 50 - Contains \Drupal\mandrill_activity\Plugin\Derivative\MandrillActivityLocalTasks.
Class
- MandrillActivityLocalTasks
- Defines dynamic local tasks for Mandrill Activity.
Namespace
Drupal\mandrill_activity\Plugin\DerivativeCode
public function getDerivativeDefinitions($base_plugin_definition) {
$activity_ids = \Drupal::entityQuery('mandrill_activity')
->execute();
$entity_definitions = $this->entityTypeManager
->getDefinitions();
$activity_entities = MandrillActivity::loadMultiple($activity_ids);
/* @var $activity \Drupal\mandrill_activity\Entity\MandrillActivity */
foreach ($activity_entities as $activity) {
$entity = $entity_definitions[$activity->entity_type];
if (!$activity->enabled || empty($entity)) {
continue;
}
// Determine if the entity has a canonical path to add this task to.
$link_templates = $entity
->getLinkTemplates();
$has_canonical_path = isset($link_templates['canonical']);
$task = $activity->entity_type . '.mandrill_activity';
$this->derivatives[$task] = $base_plugin_definition;
$this->derivatives[$task]['title'] = 'Mandrill Activity';
$this->derivatives[$task]['route_name'] = 'entity.' . $activity->entity_type . '.mandrill_activity';
$this->derivatives[$task]['base_route'] = 'entity.' . $activity->entity_type . ($has_canonical_path ? '.canonical' : '.edit_form');
}
return $this->derivatives;
}