Skip to content

Commit

Permalink
Update urls processor to use domain conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarmichael21 committed Sep 25, 2018
1 parent a13be7d commit ccc1bd9
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 ccc1bd9

Please sign in to comment.