You are here

public function RevisionsController::revisions in Workspace 8

Prints the revision tree of the current entity.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: A RouteMatch object.

Return value

array Array of page elements to render.

File

src/Controller/RevisionsController.php, line 20

Class

RevisionsController

Namespace

Drupal\workspace\Controller

Code

public function revisions(RouteMatchInterface $route_match) {
  $output = [];
  $parameter_name = $route_match
    ->getRouteObject()
    ->getOption('_entity_type_id');
  $entity = $route_match
    ->getParameter($parameter_name);
  if ($entity && $entity instanceof ContentEntityInterface) {
    $tree = \Drupal::service('multiversion.entity_index.rev.tree')
      ->getTree($entity
      ->uuid());
    $output = [
      '#theme' => 'item_list',
      '#attributes' => [
        'class' => [
          'workspace',
        ],
      ],
      '#attached' => [
        'library' => [
          'workspace/drupal.workspace.admin',
        ],
      ],
      '#items' => $tree,
      '#list_type' => 'ul',
    ];
  }
  return $output;
}