You are here

public function MigrateTemplateStorage::getAllTemplates in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate/src/MigrateTemplateStorage.php \Drupal\migrate\MigrateTemplateStorage::getAllTemplates()

Retrieves all migration templates belonging to enabled extensions.

Return value

array Array of parsed templates, keyed by the fully-qualified id.

2 calls to MigrateTemplateStorage::getAllTemplates()
MigrateTemplateStorage::findTemplatesByTag in core/modules/migrate/src/MigrateTemplateStorage.php
Find all migration templates with the specified tag.
MigrateTemplateStorage::getTemplateByName in core/modules/migrate/src/MigrateTemplateStorage.php
Retrieve a template given a specific name.

File

core/modules/migrate/src/MigrateTemplateStorage.php, line 85
Contains \Drupal\migrate\MigrateTemplateStorage.

Class

MigrateTemplateStorage
Storage to access migration template configuration in enabled extensions.

Namespace

Drupal\migrate

Code

public function getAllTemplates() {
  $templates = [];
  foreach ($this->moduleHandler
    ->getModuleDirectories() as $directory) {
    $full_directory = $directory . '/' . $this->directory;
    if (file_exists($full_directory)) {
      $files = scandir($full_directory);
      foreach ($files as $file) {
        if ($file[0] !== '.' && fnmatch('*.yml', $file)) {
          $templates[basename($file, '.yml')] = Yaml::decode(file_get_contents("{$full_directory}/{$file}"));
        }
      }
    }
  }
  return $templates;
}