Skip to content
Snippets Groups Projects
Commit 4706f543 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2626472 by benjy: MigrateTemplateStorage should have an interface

parent e4dcadd6
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@
/**
* Storage to access migration template configuration in enabled extensions.
*/
class MigrateTemplateStorage {
class MigrateTemplateStorage implements MigrateTemplateStorageInterface {
/**
* Extension sub-directory containing default configuration for migrations.
*/
......@@ -41,13 +41,7 @@ public function __construct(ModuleHandlerInterface $module_handler, $directory =
}
/**
* Find all migration templates with the specified tag.
*
* @param $tag
* The tag to match.
*
* @return array
* Any templates (parsed YAML config) that matched, keyed by the ID.
* {@inheritdoc}
*/
public function findTemplatesByTag($tag) {
$templates = $this->getAllTemplates();
......@@ -63,13 +57,7 @@ public function findTemplatesByTag($tag) {
}
/**
* Retrieve a template given a specific name.
*
* @param string $name
* A migration template name.
*
* @return NULL|array
* A parsed migration template, or NULL if it doesn't exist.
* {@inheritdoc}
*/
public function getTemplateByName($name) {
$templates = $this->getAllTemplates();
......@@ -77,10 +65,7 @@ public function getTemplateByName($name) {
}
/**
* Retrieves all migration templates belonging to enabled extensions.
*
* @return array
* Array of parsed templates, keyed by the fully-qualified id.
* {@inheritdoc}
*/
public function getAllTemplates() {
$templates = [];
......
<?php
/**
* @file
* Contains \Drupal\migrate\MigrateTemplateStorageInterface.
*/
namespace Drupal\migrate;
/**
* The MigrateTemplateStorageInterface interface.
*/
interface MigrateTemplateStorageInterface {
/**
* Find all migration templates with the specified tag.
*
* @param $tag
* The tag to match.
*
* @return array
* Any templates (parsed YAML config) that matched, keyed by the ID.
*/
public function findTemplatesByTag($tag);
/**
* Retrieve a template given a specific name.
*
* @param string $name
* A migration template name.
*
* @return NULL|array
* A parsed migration template, or NULL if it doesn't exist.
*/
public function getTemplateByName($name);
/**
* Retrieves all migration templates belonging to enabled extensions.
*
* @return array
* Array of parsed templates, keyed by the fully-qualified id.
*/
public function getAllTemplates();
}
......@@ -51,7 +51,7 @@ public function testTemplates() {
* Tests retrieving a template by name.
*/
public function testGetTemplateByName() {
/** @var \Drupal\migrate\MigrateTemplateStorage $template_storage */
/** @var \Drupal\migrate\MigrateTemplateStorageInterface $template_storage */
$template_storage = \Drupal::service('migrate.template_storage');
$expected_url = [
......
......@@ -11,7 +11,7 @@
use Drupal\migrate\Entity\Migration;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\MigrateTemplateStorage;
use Drupal\migrate\MigrateTemplateStorageInterface;
use Drupal\migrate\Plugin\migrate\builder\BuilderBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -36,10 +36,10 @@ class TermNode extends BuilderBase implements ContainerFactoryPluginInterface {
* The plugin ID.
* @param mixed $plugin_definition
* The plugin definition.
* @param \Drupal\migrate\MigrateTemplateStorage $template_storage
* @param \Drupal\migrate\MigrateTemplateStorageInterface $template_storage
* The migration template storage handler.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrateTemplateStorage $template_storage) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrateTemplateStorageInterface $template_storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->templateStorage = $template_storage;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment