public function ScheduledTransitionsLocalActions::getDerivativeDefinitions in Scheduled Transitions 8
Same name and namespace in other branches
- 2.x src/Plugin/Derivative/ScheduledTransitionsLocalActions.php \Drupal\scheduled_transitions\Plugin\Derivative\ScheduledTransitionsLocalActions::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/ ScheduledTransitionsLocalActions.php, line 63
Class
- ScheduledTransitionsLocalActions
- Scheduled transitions actions for entities.
Namespace
Drupal\scheduled_transitions\Plugin\DerivativeCode
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = [];
$scheduledTransitionDefinition = $this->entityTypeManager
->getDefinition('scheduled_transition');
foreach ($this->entityTypeManager
->getDefinitions() as $entityType) {
if ($entityType
->hasLinkTemplate(ScheduledTransitionsRouteProvider::LINK_TEMPLATE)) {
$entityTypeId = $entityType
->id();
$this->derivatives["{$entityTypeId}.add_scheduled_transition"] = [
'route_name' => ScheduledTransitionsRouteProvider::getScheduledTransitionAddRouteName($entityType),
'appears_on' => [
ScheduledTransitionsRouteProvider::getScheduledTransitionRouteName($entityType),
],
'class' => ScheduledTransitionsLocalAction::class,
'title' => $this
->t('Add @singular', [
'@singular' => $scheduledTransitionDefinition
->getSingularLabel(),
]),
'options' => [
'attributes' => [
'class' => [
'use-ajax',
],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'width' => 900,
]),
],
],
] + $base_plugin_definition;
}
}
return $this->derivatives;
}