class DynamicLocalTasks in Drupal 8
Same name in this branch
- 8 core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\content_moderation\Plugin\Derivative\DynamicLocalTasks
- 8 core/modules/media/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\media\Plugin\Derivative\DynamicLocalTasks
Same name and namespace in other branches
- 9 core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\content_moderation\Plugin\Derivative\DynamicLocalTasks
- 10 core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\content_moderation\Plugin\Derivative\DynamicLocalTasks
Generates moderation-related local tasks.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\content_moderation\Plugin\Derivative\DynamicLocalTasks implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of DynamicLocalTasks
1 string reference to 'DynamicLocalTasks'
- content_moderation.links.task.yml in core/
modules/ content_moderation/ content_moderation.links.task.yml - core/modules/content_moderation/content_moderation.links.task.yml
File
- core/
modules/ content_moderation/ src/ Plugin/ Derivative/ DynamicLocalTasks.php, line 17
Namespace
Drupal\content_moderation\Plugin\DerivativeView source
class DynamicLocalTasks 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;
/**
* The moderation information service.
*
* @var \Drupal\content_moderation\ModerationInformationInterface
*/
protected $moderationInfo;
/**
* Creates an FieldUiLocalTask object.
*
* @param string $base_plugin_id
* The base plugin ID.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The translation manager.
* @param \Drupal\content_moderation\ModerationInformationInterface $moderation_information
* The moderation information service.
*/
public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager, TranslationInterface $string_translation, ModerationInformationInterface $moderation_information) {
$this->entityTypeManager = $entity_type_manager;
$this->stringTranslation = $string_translation;
$this->basePluginId = $base_plugin_id;
$this->moderationInfo = $moderation_information;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('entity_type.manager'), $container
->get('string_translation'), $container
->get('content_moderation.moderation_information'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = [];
$latest_version_entities = array_filter($this->entityTypeManager
->getDefinitions(), function (EntityTypeInterface $type) {
return $this->moderationInfo
->canModerateEntitiesOfEntityType($type) && $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;
}
}
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:: |
|
DynamicLocalTasks:: |
protected | property | The base plugin ID. | |
DynamicLocalTasks:: |
protected | property | The entity type manager. | |
DynamicLocalTasks:: |
protected | property | The moderation information service. | |
DynamicLocalTasks:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
DynamicLocalTasks:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
DynamicLocalTasks:: |
public | function | Creates an FieldUiLocalTask object. | |
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. |