You are here

public function MigrateTemplateStorage::getAllTemplates in Migrate Manifest 8

Same name and namespace in other branches
  1. 8.2 src/MigrateTemplateStorage.php \Drupal\migrate_manifest\MigrateTemplateStorage::getAllTemplates()
  2. 3.x src/MigrateTemplateStorage.php \Drupal\migrate_manifest\MigrateTemplateStorage::getAllTemplates()

Retrieves all migration templates belonging to enabled extensions.

Return value

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

Overrides MigrateTemplateStorageInterface::getAllTemplates

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

File

src/MigrateTemplateStorage.php, line 68

Class

MigrateTemplateStorage
Storage to access migration template configuration in enabled extensions.

Namespace

Drupal\migrate_manifest

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] !== '.' && preg_match('/\\.yml$/', $file)) {
          $templates[basename($file, '.yml')] = Yaml::decode(file_get_contents("{$full_directory}/{$file}"));
        }
      }
    }
  }
  return $templates;
}