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

Breadcrumb

  1. Drupal Core 11.1.x

VersionHistoryLocalTasks.php

Namespace

Drupal\Core\Entity\Plugin\Derivative

File

core/lib/Drupal/Core/Entity/Plugin/Derivative/VersionHistoryLocalTasks.php

View source
<?php

namespace Drupal\Core\Entity\Plugin\Derivative;

use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Provides version history local tasks for revisionable entities.
 */
class VersionHistoryLocalTasks extends DeriverBase implements ContainerDeriverInterface {
    
    /**
     * Creates a new VersionHistoryLocalTasks instance.
     *
     * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
     *   The entity type manager.
     */
    public function __construct(EntityTypeManagerInterface $entityTypeManager) {
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, $base_plugin_id) {
        return new static($container->get('entity_type.manager'));
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDerivativeDefinitions($base_plugin_definition) {
        $this->derivatives = [];
        foreach ($this->entityTypeManager
            ->getDefinitions() as $entity_type_id => $entity_type) {
            if (!$entity_type->hasLinkTemplate('version-history')) {
                continue;
            }
            $this->derivatives["{$entity_type_id}.version_history"] = [
                'route_name' => "entity.{$entity_type_id}.version_history",
                'base_route' => "entity.{$entity_type_id}.canonical",
            ] + $base_plugin_definition;
        }
        return parent::getDerivativeDefinitions($base_plugin_definition);
    }

}

Classes

Title Deprecated Summary
VersionHistoryLocalTasks Provides version history local tasks for revisionable entities.

API Navigation

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