本文整理汇总了PHP中Drupal\Core\Entity\ContentEntityInterface::getRevisionUser方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentEntityInterface::getRevisionUser方法的具体用法?PHP ContentEntityInterface::getRevisionUser怎么用?PHP ContentEntityInterface::getRevisionUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\ContentEntityInterface
的用法示例。
在下文中一共展示了ContentEntityInterface::getRevisionUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRevisionDescription
/**
* {@inheritdoc}
*/
protected function getRevisionDescription(ContentEntityInterface $revision, $is_default = FALSE)
{
/** @var \Drupal\Core\Entity\ContentEntityInterface|\Drupal\user\EntityOwnerInterface|\Drupal\Core\Entity\RevisionLogInterface $revision */
if ($revision instanceof RevisionLogInterface) {
// Use revision link to link to revisions that are not active.
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
$link = $revision->toLink($date, 'revision');
// @todo: Simplify this when https://www.drupal.org/node/2334319 lands.
$username = ['#theme' => 'username', '#account' => $revision->getRevisionUser()];
$username = $this->renderer->render($username);
} else {
$link = $revision->toLink($revision->label(), 'revision');
$username = '';
}
$markup = '';
if ($revision instanceof RevisionLogInterface) {
$markup = $revision->getRevisionLogMessage();
}
if ($username) {
$template = '{% trans %}{{ date }} by {{ username }}{% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}';
} else {
$template = '{% trans %} {{ date }} {% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}';
}
$column = ['data' => ['#type' => 'inline_template', '#template' => $template, '#context' => ['date' => $link->toString(), 'username' => $username, 'message' => ['#markup' => $markup, '#allowed_tags' => Xss::getHtmlTagList()]]]];
return $column;
}