function VersionHistoryController::buildRow

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Entity/Controller/VersionHistoryController.php \Drupal\Core\Entity\Controller\VersionHistoryController::buildRow()

Builds a table row for a revision.

Parameters

\Drupal\Core\Entity\RevisionableInterface $revision: An entity revision.

Return value

array A table row.

1 call to VersionHistoryController::buildRow()
VersionHistoryController::revisionOverview in core/lib/Drupal/Core/Entity/Controller/VersionHistoryController.php
Generates an overview table of revisions of an entity.

File

core/lib/Drupal/Core/Entity/Controller/VersionHistoryController.php, line 275

Class

VersionHistoryController
Provides a controller showing revision history for an entity.

Namespace

Drupal\Core\Entity\Controller

Code

protected function buildRow(RevisionableInterface $revision) : array {
    $row = [];
    $rowAttributes = [];
    $row['revision']['data'] = $this->getRevisionDescription($revision);
    $row['operations']['data'] = [];
    // Revision status.
    if ($revision->isDefaultRevision()) {
        $rowAttributes['class'][] = 'revision-current';
        $row['operations']['data']['status']['#markup'] = $this->t('<em>Current revision</em>');
    }
    // Operation links.
    $links = $this->getOperationLinks($revision);
    if (count($links) > 0) {
        $row['operations']['data']['operations'] = [
            '#type' => 'operations',
            '#links' => $links,
        ];
    }
    return [
        'data' => $row,
    ] + $rowAttributes;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.