You are here

protected function Dropdown::getList in Image Effects 8

Same name in this branch
  1. 8 src/Plugin/image_effects/FontSelector/Dropdown.php \Drupal\image_effects\Plugin\image_effects\FontSelector\Dropdown::getList()
  2. 8 src/Plugin/image_effects/ImageSelector/Dropdown.php \Drupal\image_effects\Plugin\image_effects\ImageSelector\Dropdown::getList()
Same name and namespace in other branches
  1. 8.3 src/Plugin/image_effects/FontSelector/Dropdown.php \Drupal\image_effects\Plugin\image_effects\FontSelector\Dropdown::getList()
  2. 8.2 src/Plugin/image_effects/FontSelector/Dropdown.php \Drupal\image_effects\Plugin\image_effects\FontSelector\Dropdown::getList()

Return an array of fonts.

Scans through files available in the directory specified through configuration.

Return value

array Array of font names.

1 call to Dropdown::getList()
Dropdown::selectionElement in src/Plugin/image_effects/FontSelector/Dropdown.php
Return a form element to select the plugin content.

File

src/Plugin/image_effects/FontSelector/Dropdown.php, line 106

Class

Dropdown
Dropdown font selector plugin.

Namespace

Drupal\image_effects\Plugin\image_effects\FontSelector

Code

protected function getList() {
  $filelist = [];
  if (is_dir($this->configuration['path']) && ($handle = opendir($this->configuration['path']))) {
    while ($file_name = readdir($handle)) {
      if (preg_match("/\\.[ot]tf\$/i", $file_name) == 1) {
        $filelist[$file_name] = trim(substr($file_name, 0, -4));
        $font = $this
          ->getData($this->configuration['path'] . '/' . $file_name);
        if (!empty($font['name'])) {
          $filelist[$file_name] = $font['name'];
        }
      }
    }
    closedir($handle);
  }
  asort($filelist);
  return $filelist;
}