You are here

protected function ContentTaxonomyAutocompleteModeratedTermsSearchAPIProcessor::processTaxonomyField in Content Taxonomy 7

Processes a single field on a single item and does the actual filtering.

As such a field can be nested, recursions are used until we reach the top level.

1 call to ContentTaxonomyAutocompleteModeratedTermsSearchAPIProcessor::processTaxonomyField()
ContentTaxonomyAutocompleteModeratedTermsSearchAPIProcessor::preprocessIndexItems in includes/content_taxonomy_autocomplete_moderated_terms.inc
Postprocess items while indexing and filter out the moderated terms.

File

includes/content_taxonomy_autocomplete_moderated_terms.inc, line 39

Class

ContentTaxonomyAutocompleteModeratedTermsSearchAPIProcessor
Search API Processor that filters out terms from moderated vocabularies.

Code

protected function processTaxonomyField(&$value, &$type, $field) {
  if (!isset($value) || $value === '') {
    return;
  }
  if (substr($type, 0, 10) == 'list<list<') {
    $inner_type = $t1 = substr($type, 5, -1);
    foreach ($value as &$v) {
      $t1 = $inner_type;
      $this
        ->processTaxonomyField($v, $t1, $field);
    }
    return;
  }
  if (is_array($value)) {
    foreach ($value as $key => $v) {
      if ($this
        ->fieldValueIsModerated($v, $field)) {
        unset($value[$key]);
      }
    }
  }
  elseif ($this
    ->fieldValueIsModerated($value, $field)) {
    $value = NULL;
  }
}