diff --git a/core/modules/migrate/src/MigrateTemplateStorage.php b/core/modules/migrate/src/MigrateTemplateStorage.php index 97640d7..d32bc42 100644 --- a/core/modules/migrate/src/MigrateTemplateStorage.php +++ b/core/modules/migrate/src/MigrateTemplateStorage.php @@ -15,13 +15,29 @@ */ class MigrateTemplateStorage { + /** + * Extension sub-directory containing default configuration for migrations. + */ + const MIGRATION_TEMPLATE_DIRECTORY = 'migration_templates'; + + /** + * Template subdirectory. + * + * @var string + */ + protected $directory; + + /** + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ protected $moduleHandler; /** * {@inheritdoc} */ - public function __construct(ModuleHandlerInterface $module_handler) { + public function __construct(ModuleHandlerInterface $module_handler, $directory = self::MIGRATION_TEMPLATE_DIRECTORY) { $this->moduleHandler = $module_handler; + $this->directory = $directory; } /** @@ -55,12 +71,11 @@ public function findTemplatesByTag($tag) { public function getAllTemplates() { $templates = []; - $yaml_parser = new Yaml(); foreach ($this->moduleHandler->getModuleDirectories() as $directory) { - if (file_exists($directory . '/migration_templates')) { - $files = new \GlobIterator($directory . '/migration_templates/*.yml'); + if (file_exists($directory . '/' . $this->directory)) { + $files = new \GlobIterator($directory . '/' . $this->directory . '/*.yml'); foreach ($files as $file) { - $templates[$file->getBasename('.yml')] = $yaml_parser->decode(file_get_contents($file)); + $templates[$file->getBasename('.yml')] = Yaml::decode(file_get_contents($file)); } } }