You are here

protected function SearchApiFederatedSolrUrls::addUrl in Search API Federated Solr 7.2

Same name and namespace in other branches
  1. 7.3 src/SearchApiFederatedSolrUrls.php \SearchApiFederatedSolrUrls::addUrl()
  2. 7 src/SearchApiFederatedSolrUrls.php \SearchApiFederatedSolrUrls::addUrl()
2 calls to SearchApiFederatedSolrUrls::addUrl()
SearchApiFederatedSolrUrls::addDomainUrls in src/SearchApiFederatedSolrUrls.php
SearchApiFederatedSolrUrls::alterItems in src/SearchApiFederatedSolrUrls.php
Alter items before indexing.

File

src/SearchApiFederatedSolrUrls.php, line 48

Class

SearchApiFederatedSolrUrls
Class SearchApiFederatedSolrUrls Provides a Search API index data alteration that adds the sites that the content is available on to each indexed item.

Code

protected function addUrl(array &$items) {
  foreach ($items as &$item) {
    $url = $this->index
      ->datasource()
      ->getItemUrl($item);
    if (!$url) {
      $item->urls = NULL;
      continue;
    }
    $item->urls = [
      url($url['path'], array(
        'absolute' => TRUE,
      ) + $url['options']),
    ];
  }
}