protected function DiffLayoutBase::buildRevisionData in Diff 8
Build the revision link for a revision.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $revision: Left revision that is compared.
Return value
array Revision data about author, creation date and log.
1 call to DiffLayoutBase::buildRevisionData()
- DiffLayoutBase::buildRevisionsData in src/
DiffLayoutBase.php - Build the revision link for the compared revisions.
File
- src/
DiffLayoutBase.php, line 167
Class
- DiffLayoutBase
- Base class for diff layout plugins.
Namespace
Drupal\diffCode
protected function buildRevisionData(ContentEntityInterface $revision) {
if ($revision instanceof RevisionLogInterface) {
$revision_log = Xss::filter($revision
->getRevisionLogMessage());
$user_id = $revision
->getRevisionUserId();
$revision_link['date'] = [
'#type' => 'link',
'#title' => $this->date
->format($revision
->getRevisionCreationTime(), 'short'),
'#url' => $revision
->toUrl('revision'),
'#prefix' => '<div class="diff-revision__item diff-revision__item-date">',
'#suffix' => '</div>',
];
$revision_link['author'] = [
'#type' => 'link',
'#title' => $revision
->getRevisionUser()
->getDisplayName(),
'#url' => Url::fromUri(\Drupal::request()
->getUriForPath('/user/' . $user_id)),
'#theme' => 'username',
'#account' => $revision
->getRevisionUser(),
'#prefix' => '<div class="diff-revision__item diff-revision__item-author">',
'#suffix' => '</div>',
];
if ($revision_log) {
$revision_link['message'] = [
'#type' => 'markup',
'#prefix' => '<div class="diff-revision__item diff-revision__item-message">',
'#suffix' => '</div>',
'#markup' => $revision_log,
];
}
}
else {
$revision_link['label'] = [
'#type' => 'link',
'#title' => $revision
->label(),
'#url' => $revision
->toUrl('revision'),
'#prefix' => '<div class="diff-revision__item diff-revision__item-date">',
'#suffix' => '</div>',
];
}
return $revision_link;
}