protected function ScheduledTransitionRevisionLinkField::getUrlInfo in Scheduled Transitions 8
Returns the URI elements of the link.
Parameters
\Drupal\views\ResultRow $row: A view result row.
Return value
\Drupal\Core\Url The URI elements of the link.
Overrides LinkBase::getUrlInfo
File
- src/
Plugin/ views/ field/ ScheduledTransitionRevisionLinkField.php, line 78
Class
- ScheduledTransitionRevisionLinkField
- Link to the scheduled revision.
Namespace
Drupal\scheduled_transitions\Plugin\views\fieldCode
protected function getUrlInfo(ResultRow $row) {
/** @var \Drupal\scheduled_transitions\Entity\ScheduledTransitionInterface $scheduledTransition */
$scheduledTransition = $this
->getEntity($row);
$entity = $scheduledTransition
->getEntity();
$entityRevisionId = $scheduledTransition
->getEntityRevisionId();
$entityRevision = $this->entityTypeManager
->getStorage($entity
->getEntityTypeId())
->loadRevision($entityRevisionId);
if (!$entityRevision) {
// Use the original entity if this revision cannot be loaded.
$entityRevision = $entity;
}
$language = $scheduledTransition
->getEntityRevisionLanguage();
if ($language && $entityRevision instanceof TranslatableInterface && $entityRevision
->hasTranslation($language)) {
$entityRevision = $entityRevision
->getTranslation($language);
}
$toUrlArgs = [];
if ($entityRevision
->hasLinkTemplate('revision')) {
$toUrlArgs[] = 'revision';
}
return $entityRevision
->toUrl(...$toUrlArgs);
}