public function DomainAccessManager::getContentUrls in Domain Access 8
Get all possible URLs pointing to an entity.
Parameters
\Drupal\Core\Entity\FieldableEntityInterface $entity: The entity to retrieve field data from.
Return value
array An array of absolute URLs keyed by domain_id, with an known canonical id as the first element of the array.
Overrides DomainAccessManagerInterface::getContentUrls
File
- domain_access/
src/ DomainAccessManager.php, line 173
Class
- DomainAccessManager
- Checks the access status of entities based on domain settings.
Namespace
Drupal\domain_accessCode
public function getContentUrls(FieldableEntityInterface $entity) {
$list = [];
$processed = FALSE;
$domains = $this
->getAccessValues($entity);
if ($this->moduleHandler
->moduleExists('domain_source')) {
$source = domain_source_get($entity);
if (isset($domains[$source])) {
unset($domains['source']);
}
if (!empty($source)) {
$list[] = $source;
}
$processed = TRUE;
}
$list = array_merge($list, array_keys($domains));
$domains = $this->domainStorage
->loadMultiple($list);
$urls = [];
foreach ($domains as $domain) {
$options['domain_target_id'] = $domain
->id();
$url = $entity
->toUrl('canonical', $options);
if ($processed) {
$urls[$domain
->id()] = $url
->toString();
}
else {
$urls[$domain
->id()] = $domain
->buildUrl($url
->toString());
}
}
return $urls;
}