You are here

protected function ScheduledTransitionRevisionLinkField::renderLink in Scheduled Transitions 8

Prepares the link to view a entity.

Parameters

\Drupal\views\ResultRow $row: A view result row.

Return value

string Returns a string for the link text.

Overrides LinkBase::renderLink

File

src/Plugin/views/field/ScheduledTransitionRevisionLinkField.php, line 108

Class

ScheduledTransitionRevisionLinkField
Link to the scheduled revision.

Namespace

Drupal\scheduled_transitions\Plugin\views\field

Code

protected function renderLink(ResultRow $row) {

  /** @var \Drupal\scheduled_transitions\Entity\ScheduledTransitionInterface $scheduledTransition */
  $scheduledTransition = $this
    ->getEntity($row);
  $entity = $scheduledTransition
    ->getEntity();
  if (!$entity) {
    return '';
  }
  $entityRevisionId = $scheduledTransition
    ->getEntityRevisionId();
  $entityRevision = $this->entityTypeManager
    ->getStorage($entity
    ->getEntityTypeId())
    ->loadRevision($entityRevisionId);
  if (!$entityRevision) {
    $options = $scheduledTransition
      ->getOptions();
    return isset($options[ScheduledTransition::OPTION_LATEST_REVISION]) ? $this
      ->t('Latest revision') : $this
      ->t('Dynamic');
  }
  $text = parent::renderLink($row);
  $this->options['alter']['query'] = $this
    ->getDestinationArray();
  return $text;
}