protected function ModerationSidebarController::getLocalTasks in Moderation Sidebar 8
Gathers a list of non-duplicated tasks, themed like our other buttons.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: An entity.
Return value
array A render array representing local tasks for this entity.
1 call to ModerationSidebarController::getLocalTasks()
- ModerationSidebarController::sideBar in src/
Controller/ ModerationSidebarController.php - Displays information relevant to moderating an entity in-line.
File
- src/
Controller/ ModerationSidebarController.php, line 588
Class
- ModerationSidebarController
- Endpoints for the Moderation Sidebar module.
Namespace
Drupal\moderation_sidebar\ControllerCode
protected function getLocalTasks(ContentEntityInterface $entity) {
$tasks = $this->localTaskManager
->getLocalTasks("entity.{$entity->getEntityTypeId()}.canonical", 0);
$tabs = [];
if (isset($tasks['tabs']) && !empty($tasks['tabs'])) {
foreach ($tasks['tabs'] as $name => $tab) {
// If this is a moderated node, we provide buttons for certain actions.
$duplicated_tab = preg_match('/^.*(canonical|edit_form|delete_form|latest_version_tab|entity\\.node\\.version_history|content_translation_overview)$/', $name);
if (!$this->moderationInformation
->isModeratedEntity($entity) || !$duplicated_tab) {
$attributes = [];
if (isset($tab['#link']['localized_options']['attributes'])) {
$attributes = $tab['#link']['localized_options']['attributes'];
}
$attributes['class'][] = 'moderation-sidebar-link';
$attributes['class'][] = 'button';
$tabs[$name] = [
'#title' => $tab['#link']['title'],
'#type' => 'link',
'#url' => $tab['#link']['url'],
'#attributes' => $attributes,
'#access' => isset($tab['#access']) ? $tab['#access'] : AccessResult::neutral(),
];
}
}
}
return $tabs;
}