You are here

public static function ViewsPdfBase::getAvailableTemplates in Views PDF 8

This method returns a list of current uploaded files.

1 call to ViewsPdfBase::getAvailableTemplates()
Fields::options_form in src/Plugin/views/row/Fields.php
Provide a form for setting options.

File

src/ViewsPdfBase.php, line 1052
Contains \Drupal\views_pdf\ViewsPdfTemplate.

Class

ViewsPdfBase
The main class to generate the PDF.

Namespace

Drupal\views_pdf

Code

public static function getAvailableTemplates() {
  if (self::$templateList != NULL) {
    return self::$templateList;
  }
  $files_path = drupal_realpath('public://');
  $template_dir = variable_get('views_pdf_template_path', 'views_pdf_templates');
  $dir = $files_path . '/' . $template_dir;
  $templatesFiles = file_scan_directory($dir, '/.pdf$/', [
    'nomask' => '/(\\.\\.?|CVS)$/',
  ], 1);
  $templates = [];
  foreach ($templatesFiles as $file) {
    $templates[$file->filename] = $file->name;
  }
  self::$templateList = $templates;
  return $templates;
}