You are here

private function ExportPluginManager::saveSynonymsFile in Search API Synonym 8

Save synonyms data to a file.

Parameters

string $data: String with the synonyms data being written to a file.

Return value

string Return path to the saved synonyms file.

1 call to ExportPluginManager::saveSynonymsFile()
ExportPluginManager::executeExport in src/Export/ExportPluginManager.php
Execute the synonym export.

File

src/Export/ExportPluginManager.php, line 217

Class

ExportPluginManager
Base class for search api synonym export plugin managers.

Namespace

Drupal\search_api_synonym\Export

Code

private function saveSynonymsFile($data) {
  if ($file = $this
    ->getExportOption('file')) {
    $filename = $file;
  }
  else {
    $filename = $this
      ->generateFileName();
  }

  // Create folder if it does not exist.
  $folder = 'public://synonyms';
  $this->fileSystem
    ->prepareDirectory($folder, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);

  // Save file and return result.
  $path = $folder . '/' . $filename;
  return $this->fileSystem
    ->saveData($data, $path, FileSystemInterface::EXISTS_REPLACE);
}