You are here

protected function FlagIndexer::getFieldsDefinition in Flag Search API 8

Helper function for defining our custom fields.

2 calls to FlagIndexer::getFieldsDefinition()
FlagIndexer::getPropertyDefinitions in src/Plugin/search_api/processor/FlagIndexer.php
Retrieves the properties this processor defines for the given datasource.
FlagIndexer::preIndexSave in src/Plugin/search_api/processor/FlagIndexer.php
Preprocesses the search index entity before it is saved.

File

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

Class

FlagIndexer
Search API Processor for indexing flags.

Namespace

Drupal\flag_search_api\Plugin\search_api\processor

Code

protected function getFieldsDefinition() {
  $config = $this->configuration['flag_index'];
  $fields = [];
  foreach ($config as $flag) {
    $label = $this->flagService
      ->getFlagById($flag)
      ->get('label');
    $fields['flag_' . $flag] = array(
      'label' => $label,
      'description' => $label,
      'type' => 'integer',
      'processor_id' => $this
        ->getPluginId(),
    );
  }
  return $fields;
}