You are here

public function SearchApiFederatedSolrRemap::alterItems in Search API Federated Solr 7

Same name and namespace in other branches
  1. 7.3 src/SearchApiFederatedSolrRemap.php \SearchApiFederatedSolrRemap::alterItems()
  2. 7.2 src/SearchApiFederatedSolrRemap.php \SearchApiFederatedSolrRemap::alterItems()

Alter items before indexing.

Items which are removed from the array won't be indexed, but will be marked as clean for future indexing. This could for instance be used to implement some sort of access filter for security purposes (e.g., don't index unpublished nodes or comments).

Parameters

array $items: An array of items to be altered, keyed by item IDs.

Overrides SearchApiAlterCallbackInterface::alterItems

File

src/SearchApiFederatedSolrRemap.php, line 28

Class

SearchApiFederatedSolrRemap
Class SearchApiFederatedSolrRemap Provides a Search API index data alteration that remaps property names for indexed items.

Code

public function alterItems(array &$items) {
  foreach ($items as &$item) {
    foreach ($this->options['remap'] as $destination => $source) {
      if ($source && isset($item->{$source})) {
        $item->{$destination} = $item->{$source};
      }
    }
  }
}