Issue #2917883 by quietone, TR, Jo Fitzgerald, masipila, phenaproxima: Rename 'migration_templates' directories in core modules to 'migrations'
parent
3af361c83c
commit
33818be2d8
|
@ -38,9 +38,8 @@ use Drupal\migrate\Row;
|
||||||
*
|
*
|
||||||
* @section sec_migrations Migration plugins
|
* @section sec_migrations Migration plugins
|
||||||
* Migration plugin definitions are stored in a module's 'migrations' directory.
|
* 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
|
* 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\Migration, with interface
|
||||||
* \Drupal\migrate\Plugin\MigrationInterface. Migration plugins are managed by
|
* \Drupal\migrate\Plugin\MigrationInterface. Migration plugins are managed by
|
||||||
* the \Drupal\migrate\Plugin\MigrationPluginManager class. Migration plugins
|
* the \Drupal\migrate\Plugin\MigrationPluginManager class. Migration plugins
|
||||||
|
|
|
@ -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() {
|
protected function getDiscovery() {
|
||||||
if (!isset($this->discovery)) {
|
if (!isset($this->discovery)) {
|
||||||
$directories = array_map(function ($directory) {
|
$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'];
|
return [$directory . '/migration_templates', $directory . '/migrations'];
|
||||||
}, $this->moduleHandler->getModuleDirectories());
|
}, $this->moduleHandler->getModuleDirectories());
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
name: 'Migration directory test'
|
||||||
|
type: module
|
||||||
|
package: Testing
|
||||||
|
version: VERSION
|
||||||
|
core: 8.x
|
||||||
|
dependencies:
|
||||||
|
- migrate
|
|
@ -0,0 +1,8 @@
|
||||||
|
id: migration_templates_test
|
||||||
|
label: Migration templates test
|
||||||
|
source:
|
||||||
|
plugin: embedded_data
|
||||||
|
process:
|
||||||
|
id: id
|
||||||
|
destination:
|
||||||
|
plugin: null
|
|
@ -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
Loading…
Reference in New Issue