You are here

private function SettingsForm::getConfigurationAsCsvString in File Upload Secure Validator 8

Returns a CSV representation of the configuration stored in the database.

1 call to SettingsForm::getConfigurationAsCsvString()
SettingsForm::buildForm in src/Form/SettingsForm.php
Form constructor.

File

src/Form/SettingsForm.php, line 101

Class

SettingsForm
A configuration settings form.

Namespace

Drupal\file_upload_secure_validator\Form

Code

private function getConfigurationAsCsvString() {
  $configuration = $this
    ->config('file_upload_secure_validator.settings')
    ->get('mime_types_equivalence_groups');

  // Provides backward compatibility.
  $options = [
    CsvEncoder::DELIMITER_KEY => ',',
  ];
  if (defined('CsvEncoder::NO_HEADERS_KEY')) {
    $options[CsvEncoder::NO_HEADERS_KEY] = TRUE;
  }
  $csvString = (new CsvEncoder())
    ->encode($configuration, CsvEncoder::FORMAT, $options);
  return preg_replace('#' . self::CSV_DELIMITER . '+$#m', '', $csvString);
}