You are here

protected function AbstractFieldSynonymsBehavior::uniqueItems in Synonyms 7

Filter $items only to contain unique values.

Parameters

array $items: Array of field items that should be filtered to contain only unique values

array $unique_index: Array of column names that define uniqueness for an item

Return value

array Only unique items from the provided $items array

4 calls to AbstractFieldSynonymsBehavior::uniqueItems()
CommerceProductReferenceSynonymsBehavior::mergeEntityAsSynonym in synonyms_commerce/includes/CommerceProductReferenceSynonymsBehavior.class.inc
Add an entity as a synonym into another entity.
EntityReferenceSynonymsBehavior::mergeEntityAsSynonym in synonyms_provider_field/includes/EntityReferenceSynonymsBehavior.class.inc
Add an entity as a synonym into another entity.
TaxonomySynonymsBehavior::mergeEntityAsSynonym in synonyms_provider_field/includes/TaxonomySynonymsBehavior.class.inc
Add an entity as a synonym into another entity.
TextSynonymsBehavior::mergeEntityAsSynonym in synonyms_provider_field/includes/TextSynonymsBehavior.class.inc
Add an entity as a synonym into another entity.

File

synonyms_provider_field/includes/AbstractFieldSynonymsBehavior.class.inc, line 73
Definition of AbstractFieldSynonymsBehavior class.

Class

AbstractFieldSynonymsBehavior
Abstract class for providing synonyms from fields attached to entities.

Code

protected function uniqueItems($items, $unique_index) {
  $index = array();
  foreach ($items as $item) {
    $item_index = array();
    foreach ($unique_index as $column) {
      $item_index[] = is_scalar($column) ? $column : serialize($column);
    }
    $index[serialize($item_index)] = $item;
  }
  return array_values($index);
}