class ScheduledTransitionsLocalActions in Scheduled Transitions 8
Same name and namespace in other branches
- 2.x src/Plugin/Derivative/ScheduledTransitionsLocalActions.php \Drupal\scheduled_transitions\Plugin\Derivative\ScheduledTransitionsLocalActions
Scheduled transitions actions for entities.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\scheduled_transitions\Plugin\Derivative\ScheduledTransitionsLocalActions implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of ScheduledTransitionsLocalActions
1 string reference to 'ScheduledTransitionsLocalActions'
File
- src/
Plugin/ Derivative/ ScheduledTransitionsLocalActions.php, line 19
Namespace
Drupal\scheduled_transitions\Plugin\DerivativeView source
class ScheduledTransitionsLocalActions extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* The base plugin ID.
*
* @var string
*/
protected $basePluginId;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Creates a new ScheduledTransitionsLocalTask.
*
* @param string $base_plugin_id
* The base plugin ID.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* Entity type manager.
*/
public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager) {
$this->basePluginId = $base_plugin_id;
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('entity_type.manager'));
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
ScheduledTransitionsLocalActions:: |
protected | property | The base plugin ID. | |
ScheduledTransitionsLocalActions:: |
protected | property | The entity type manager. | |
ScheduledTransitionsLocalActions:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
ScheduledTransitionsLocalActions:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
ScheduledTransitionsLocalActions:: |
public | function | Creates a new ScheduledTransitionsLocalTask. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |