You are here

public function FillPdfAdminFormHelper::schemeOptions in FillPDF 8.4

Same name and namespace in other branches
  1. 5.0.x src/Service/FillPdfAdminFormHelper.php \Drupal\fillpdf\Service\FillPdfAdminFormHelper::schemeOptions()

Returns available file storage options for use with FAPI radio buttons.

Any visible, writeable wrapper can potentially be used.

Parameters

array $label_templates: (optional) Associative array of label templates keyed by scheme name.

Return value

array Stream wrapper descriptions, keyed by scheme.

Overrides FillPdfAdminFormHelperInterface::schemeOptions

1 call to FillPdfAdminFormHelper::schemeOptions()
fillpdf_update_8101 in ./fillpdf.install
Add scheme field to FillPdfForm.

File

src/Service/FillPdfAdminFormHelper.php, line 80

Class

FillPdfAdminFormHelper
Various helper methods used in FillPDF administrative forms.

Namespace

Drupal\fillpdf\Service

Code

public function schemeOptions(array $label_templates = []) {
  $stream_wrapper_manager = $this->streamWrapperManager;
  $options = [];
  foreach (array_keys($stream_wrapper_manager
    ->getWrappers(StreamWrapperInterface::WRITE_VISIBLE)) as $scheme) {
    $label_template = array_key_exists($scheme, $label_templates) ? $label_templates[$scheme] : '@scheme';
    $options[$scheme] = new FormattableMarkup($label_template, [
      '@scheme' => new FormattableMarkup("<strong>@label</strong>", [
        '@label' => $stream_wrapper_manager
          ->getViaScheme($scheme)
          ->getName(),
      ]),
    ]) . ': ' . $stream_wrapper_manager
      ->getViaScheme($scheme)
      ->getDescription();
  }
  return $options;
}