Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update urls processor to use domain conditionally #51

Merged
merged 1 commit into from
Sep 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
}

}