You are here

public function FlagIndexer::preIndexSave in Flag Search API 8

Preprocesses the search index entity before it is saved.

This can, for example, be used to make sure fields needed by this processor are enabled on the index.

Overrides ProcessorPluginBase::preIndexSave

File

src/Plugin/search_api/processor/FlagIndexer.php, line 182

Class

FlagIndexer
Search API Processor for indexing flags.

Namespace

Drupal\flag_search_api\Plugin\search_api\processor

Code

public function preIndexSave() {
  foreach ($this
    ->getFieldsDefinition() as $field_id => $field_definition) {
    try {
      $this
        ->ensureField(NULL, $field_id, $field_definition['type']);
    } catch (SearchApiException $exception) {
      $this->logger
        ->error($exception
        ->getMessage());
    }
  }
}