Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DynamicLocalTasks.php

function DynamicLocalTasks::getDerivativeDefinitions

Same name in this branch
  1. 11.1.x core/modules/media/src/Plugin/Derivative/DynamicLocalTasks.php \Drupal\media\Plugin\Derivative\DynamicLocalTasks::getDerivativeDefinitions()

Overrides DeriverBase::getDerivativeDefinitions

File

core/modules/content_moderation/src/Plugin/Derivative/DynamicLocalTasks.php, line 88

Class

DynamicLocalTasks
Generates moderation-related local tasks.

Namespace

Drupal\content_moderation\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
    $this->derivatives = [];
    // Add the moderated content task if the route exists.
    if ($this->router
        ->getRouteCollection()
        ->get('content_moderation.admin_moderated_content') !== NULL) {
        $this->derivatives['content_moderation.moderated_content'] = [
            'route_name' => 'content_moderation.admin_moderated_content',
            'title' => $this->t('Moderated content'),
            'parent_id' => 'system.admin_content',
            'weight' => 1,
        ];
    }
    // Add the latest version tab to entities.
    $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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal