Commit 33818be2 authored by xjm's avatar xjm

Issue #2917883 by quietone, TR, Jo Fitzgerald, masipila, phenaproxima: Rename...

Issue #2917883 by quietone, TR, Jo Fitzgerald, masipila, phenaproxima: Rename 'migration_templates' directories in core modules to 'migrations'
parent 3af361c8
......@@ -38,9 +38,8 @@
*
* @section sec_migrations Migration plugins
* Migration plugin definitions are stored in a module's 'migrations' directory.
* For backwards compatibility we also scan the 'migration_templates' directory.
* Examples of migration plugin definitions can be found in
* 'core/modules/action/migration_templates'. The plugin class is
* 'core/modules/action/migrations'. The plugin class is
* \Drupal\migrate\Plugin\Migration, with interface
* \Drupal\migrate\Plugin\MigrationInterface. Migration plugins are managed by
* the \Drupal\migrate\Plugin\MigrationPluginManager class. Migration plugins
......
......@@ -60,11 +60,22 @@ public function __construct(ModuleHandlerInterface $module_handler, CacheBackend
}
/**
* {@inheritdoc}
* Gets the plugin discovery.
*
* This method overrides DefaultPluginManager::getDiscovery() in order to
* search for migration configurations in the MODULENAME/migrations and
* MODULENAME/migration_templates directories. Throws a deprecation notice if
* the MODULENAME/migration_templates directory exists.
*/
protected function getDiscovery() {
if (!isset($this->discovery)) {
$directories = array_map(function ($directory) {
// Check for use of the @deprecated /migration_templates directory.
// @todo Remove use of /migration_templates in Drupal 9.0.0.
if (is_dir($directory . '/migration_templates')) {
@trigger_error('Use of the /migration_templates directory to store migration configuration files is deprecated in Drupal 8.1.0 and will be removed before Drupal 9.0.0. See https://www.drupal.org/node/2920988.', E_USER_DEPRECATED);
}
// But still accept configurations found in /migration_templates.
return [$directory . '/migration_templates', $directory . '/migrations'];
}, $this->moduleHandler->getModuleDirectories());
......
name: 'Migration directory test'
type: module
package: Testing
version: VERSION
core: 8.x
dependencies:
- migrate
id: migration_templates_test
label: Migration templates test
source:
plugin: embedded_data
process:
id: id
destination:
plugin: null
<?php
namespace Drupal\Tests\migrate\Kernel\Plugin;
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
/**
* Tests that migrations exist in the migration_templates directory.
*
* @group migrate
*/
class MigrationDirectoryTest extends MigrateDrupalTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['migration_directory_test'];
/**
* Tests that migrations in the migration_templates directory are created.
*/
public function testMigrationDirectory() {
/** @var \Drupal\migrate\Plugin\MigrationPluginManager $plugin_manager */
$plugin_manager = $this->container->get('plugin.manager.migration');
// Tests that a migration in directory 'migration_templates' is discovered.
$this->assertTrue($plugin_manager->hasDefinition('migration_templates_test'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment