public function Solr::getFormattedSynonyms in Search API Synonym 8
Get synonyms in the export format. *
Parameters
array $synonyms: An array containing synonym objects.
Return value
string The formatted synonyms as a string ready to be saved to an export file.
Overrides ExportPluginInterface::getFormattedSynonyms
File
- src/
Plugin/ search_api_synonym/ export/ Solr.php, line 22
Class
- Solr
- Provides a synonym export plugin for Apache Solr..
Namespace
Drupal\search_api_synonym\Plugin\search_api_synonym\exportCode
public function getFormattedSynonyms(array $synonyms) {
$lines = [];
$lines[] = "#";
$lines[] = "# Synonyms file for Apache Solr generated by Search API Synonym.";
$lines[] = "# See file https://www.drupal.org/project/search_api_synonym.";
$lines[] = "#";
$lines[] = "";
// Generate a line for each synonym.
foreach ($synonyms as $synonym) {
$lines[] = $this
->generateLine($synonym->word, $synonym->synonyms, $synonym->type);
}
return implode("\n", $lines);
}