You are here

private function Importer::prepare in Search API Synonym 8

Prepare and validate the data.

Parameters

array $items: Raw synonyms data.

array $settings: Import settings.

Return value

array Array with prepared data.

1 call to Importer::prepare()
Importer::execute in src/Import/Importer.php
Execute the import of an array with synonyms.

File

src/Import/Importer.php, line 95

Class

Importer
Importer class.

Namespace

Drupal\search_api_synonym\Import

Code

private function prepare(array $items, array $settings) {
  $prepared = [];
  foreach ($items as $item) {

    // Decide which synonym type to use.
    if ($settings['synonym_type'] != 'mixed') {
      $type = $settings['synonym_type'];
    }
    else {
      $type = !empty($item['type']) ? $item['type'] : 'empty';
    }
    $prepared[$type][$item['word']][] = $item['synonym'];
  }
  return $prepared;
}