X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fentity%2Fsrc%2FController%2FRevisionOverviewController.php;fp=web%2Fmodules%2Fcontrib%2Fentity%2Fsrc%2FController%2FRevisionOverviewController.php;h=0000000000000000000000000000000000000000;hp=495b6a040f043fa0d3e17745304fade678584a3f;hb=059867c3f96750652c80f39e44c442a58c2549ee;hpb=f8fc16ae6b862bef59baaad5d051dd37b7ff11b2 diff --git a/web/modules/contrib/entity/src/Controller/RevisionOverviewController.php b/web/modules/contrib/entity/src/Controller/RevisionOverviewController.php deleted file mode 100644 index 495b6a040..000000000 --- a/web/modules/contrib/entity/src/Controller/RevisionOverviewController.php +++ /dev/null @@ -1,160 +0,0 @@ -dateFormatter = $date_formatter; - $this->renderer = $renderer; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static($container->get('date.formatter'), $container->get('renderer')); - } - - /** - * {@inheritdoc} - */ - protected function hasDeleteRevisionAccess(EntityInterface $entity) { - return $this->currentUser()->hasPermission("delete all {$entity->id()} revisions"); - } - - /** - * {@inheritdoc} - */ - protected function buildRevertRevisionLink(EntityInterface $entity_revision) { - if ($entity_revision->hasLinkTemplate('revision-revert-form')) { - return [ - 'title' => t('Revert'), - 'url' => $entity_revision->toUrl('revision-revert-form'), - ]; - } - } - - /** - * {@inheritdoc} - */ - protected function buildDeleteRevisionLink(EntityInterface $entity_revision) { - if ($entity_revision->hasLinkTemplate('revision-delete-form')) { - return [ - 'title' => t('Delete'), - 'url' => $entity_revision->toUrl('revision-delete-form'), - ]; - } - } - - /** - * Generates an overview table of older revisions of an entity. - * - * @param \Drupal\Core\Routing\RouteMatchInterface $route_match - * The route match. - * - * @return array - * A render array. - */ - public function revisionOverviewController(RouteMatchInterface $route_match) { - return $this->revisionOverview($route_match->getParameter($route_match->getRouteObject()->getOption('entity_type_id'))); - } - - /** - * {@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 %}

{{ message }}

{% endif %}'; - } - else { - $template = '{% trans %} {{ date }} {% endtrans %}{% if message %}

{{ message }}

{% endif %}'; - } - - $column = [ - 'data' => [ - '#type' => 'inline_template', - '#template' => $template, - '#context' => [ - 'date' => $link->toString(), - 'username' => $username, - 'message' => ['#markup' => $markup, '#allowed_tags' => Xss::getHtmlTagList()], - ], - ], - ]; - return $column; - } - - /** - * {@inheritdoc} - */ - protected function hasRevertRevisionAccess(EntityInterface $entity) { - return AccessResult::allowedIfHasPermission($this->currentUser(), "revert all {$entity->getEntityTypeId()} revisions")->orIf( - AccessResult::allowedIfHasPermission($this->currentUser(), "revert {$entity->bundle()} {$entity->getEntityTypeId()} revisions") - ); - } - -}