Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 15 |
| RevisionLink | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 15 |
| getUrlInfo | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 5 |
|||
| renderLink | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 8 |
|||
| getDefaultLabel | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\node\Plugin\views\field\RevisionLink. | |
| */ | |
| namespace Drupal\node\Plugin\views\field; | |
| use Drupal\Core\Url; | |
| use Drupal\views\Plugin\views\field\LinkBase; | |
| use Drupal\views\ResultRow; | |
| /** | |
| * Field handler to present a link to a node revision. | |
| * | |
| * @ingroup views_field_handlers | |
| * | |
| * @ViewsField("node_revision_link") | |
| */ | |
| class RevisionLink extends LinkBase { | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| protected function getUrlInfo(ResultRow $row) { | |
| /** @var \Drupal\node\NodeInterface $node */ | |
| $node = $this->getEntity($row); | |
| // Current revision uses the node view path. | |
| return !$node->isDefaultRevision() ? | |
| Url::fromRoute('entity.node.revision', ['node' => $node->id(), 'node_revision' => $node->getRevisionId()]) : | |
| $node->urlInfo(); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| protected function renderLink(ResultRow $row) { | |
| /** @var \Drupal\node\NodeInterface $node */ | |
| $node = $this->getEntity($row); | |
| if (!$node->getRevisionid()) { | |
| return ''; | |
| } | |
| $text = parent::renderLink($row); | |
| $this->options['alter']['query'] = $this->getDestinationArray(); | |
| return $text; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| protected function getDefaultLabel() { | |
| return $this->t('View'); | |
| } | |
| } |