Issue #2917883 by quietone, TR, Jo Fitzgerald, masipila, phenaproxima: Rename 'migration_templates' directories in core modules to 'migrations'

8.5.x
xjm 2017-11-07 06:19:19 -06:00
parent 3af361c83c
commit 33818be2d8
178 changed files with 57 additions and 3 deletions

View File

@ -38,9 +38,8 @@ use Drupal\migrate\Row;
*
* @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

View File

@ -60,11 +60,22 @@ class MigrationPluginManager extends DefaultPluginManager implements MigrationPl
}
/**
* {@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());

View File

@ -0,0 +1,7 @@
name: 'Migration directory test'
type: module
package: Testing
version: VERSION
core: 8.x
dependencies:
- migrate

View File

@ -0,0 +1,8 @@
id: migration_templates_test
label: Migration templates test
source:
plugin: embedded_data
process:
id: id
destination:
plugin: null

View File

@ -0,0 +1,29 @@
<?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'));
}
}

Some files were not shown because too many files have changed in this diff Show More