diff --git a/src/SearchApiFederatedSolrUrls.php b/src/SearchApiFederatedSolrUrls.php index 344545ee6..5f43b8411 100644 --- a/src/SearchApiFederatedSolrUrls.php +++ b/src/SearchApiFederatedSolrUrls.php @@ -36,6 +36,27 @@ public function propertyInfo() { */ public function alterItems(array &$items) { + if ($this->useDomainAccess()) { + $this->addDomainUrls($items); + } + else { + $this->addUrl($items); + } + + } + + protected function addUrl(array &$items) { + foreach ($items as &$item) { + $url = $this->index->datasource()->getItemUrl($item); + if (!$url) { + $item->search_api_urls = NULL; + continue; + } + $item->search_api_urls = [url($url['path'], array('absolute' => TRUE) + $url['options'])]; + } + } + + protected function addDomainUrls(array &$items) { $entity_type = $this->index->getEntityType(); $entity_info = entity_get_info($entity_type); @@ -55,4 +76,13 @@ public function alterItems(array &$items) { } + /** + * Whether to use the site name from Domain Access. + * + * @return bool + */ + protected function useDomainAccess() { + return function_exists('domain_get_content_urls'); + } + }