Returns the Uri for this job item.
\Drupal\tmgmt\JobItemInterface $job_item: The job item entity.
\Drupal\Core\Url|null The URL object for the source object.
Overrides SourcePluginBase::getUrl
public function getUrl(JobItemInterface $job_item) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$langcode = $job_item
->getJob() ? $job_item
->getJob()
->getSourceLangcode() : NULL;
if ($entity = static::load($job_item
->getItemType(), $job_item
->getItemId(), $langcode)) {
if ($entity
->hasLinkTemplate('canonical')) {
$anonymous = new AnonymousUserSession();
$url = $entity
->toUrl();
$anonymous_access = \Drupal::config('tmgmt.settings')
->get('anonymous_access');
if ($url && $anonymous_access && !$entity
->access('view', $anonymous)) {
$url
->setOption('query', [
'key' => \Drupal::service('tmgmt_content.key_access')
->getKey($job_item),
]);
}
return $url;
}
}
return NULL;
}