Skip to content

Commit

Permalink
Merge pull request #51 from palantirnet/HOTFIX-umus-21-search-api-url…
Browse files Browse the repository at this point in the history
…s-to-urls

Update urls processor to use domain conditionally
  • Loading branch information
Kbentham authored Sep 26, 2018
2 parents e8c23ab + ccc1bd9 commit 10c9bca
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/SearchApiFederatedSolrUrls.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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');
}

}

0 comments on commit 10c9bca

Please sign in to comment.