updated contrib modules
This commit is contained in:
@@ -2,10 +2,22 @@
|
||||
"name": "drupal/migrate_tools",
|
||||
"description": "Tools to assist in developing and running migrations.",
|
||||
"type": "drupal-module",
|
||||
"require-dev": {
|
||||
"drupal/coder": "^8"
|
||||
"homepage": "http://drupal.org/project/migrate_tools",
|
||||
"support": {
|
||||
"issues": "http://drupal.org/project/migrate_tools",
|
||||
"irc": "irc://irc.freenode.org/drupal-migrate",
|
||||
"source": "http://cgit.drupalcode.org/migrate_tools"
|
||||
},
|
||||
"license": "GPL-2.0+",
|
||||
"require": {},
|
||||
"minimum-stability": "dev"
|
||||
"require-dev": {
|
||||
"drupal/coder": "^8"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"drush": {
|
||||
"services": {
|
||||
"drush.services.yml": "^9"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,9 @@ use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\RequirementsInterface;
|
||||
use Drupal\migrate_tools\MigrateExecutable;
|
||||
use Drupal\migrate_tools\DrushLogMigrateMessage;
|
||||
use Drupal\Core\Datetime\DateFormatter;
|
||||
use Drupal\migrate_plus\Entity\MigrationGroup;
|
||||
use Drupal\migrate_tools\DrushLogMigrateMessage;
|
||||
use Drupal\migrate_tools\MigrateExecutable;
|
||||
|
||||
/**
|
||||
* Implements hook_drush_command().
|
||||
@@ -68,27 +67,27 @@ function migrate_tools_drush_command() {
|
||||
'aliases' => ['mi', 'mim'],
|
||||
];
|
||||
|
||||
$items['migrate-rollback'] = array(
|
||||
$items['migrate-rollback'] = [
|
||||
'description' => 'Rollback one or more migrations.',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'all' => 'Process all migrations.',
|
||||
'group' => 'A comma-separated list of migration groups to rollback',
|
||||
'tag' => 'ID of the migration tag to rollback',
|
||||
'feedback' => 'Frequency of progress messages, in items processed',
|
||||
),
|
||||
'arguments' => array(
|
||||
],
|
||||
'arguments' => [
|
||||
'migration' => 'Name of migration(s) to rollback. Delimit multiple using commas.',
|
||||
),
|
||||
'examples' => array(
|
||||
],
|
||||
'examples' => [
|
||||
'migrate-rollback --all' => 'Perform all migrations',
|
||||
'migrate-rollback --group=beer' => 'Rollback all migrations in the beer group',
|
||||
'migrate-rollback --tag=user' => 'Rollback all migrations with the user tag',
|
||||
'migrate-rollback --group=beer --tag=user' => 'Rollback all migrations in the beer group and with the user tag',
|
||||
'migrate-rollback beer_term,beer_node' => 'Rollback imported terms and nodes',
|
||||
),
|
||||
'drupal dependencies' => array('migrate_tools'),
|
||||
'aliases' => array('mr'),
|
||||
);
|
||||
],
|
||||
'drupal dependencies' => ['migrate_tools'],
|
||||
'aliases' => ['mr'],
|
||||
];
|
||||
|
||||
$items['migrate-stop'] = [
|
||||
'description' => 'Stop an active migration operation.',
|
||||
@@ -114,7 +113,7 @@ function migrate_tools_drush_command() {
|
||||
'migration' => 'ID of the migration',
|
||||
],
|
||||
'options' => [
|
||||
'csv' => 'Export messages as a CSV'
|
||||
'csv' => 'Export messages as a CSV',
|
||||
],
|
||||
'examples' => [
|
||||
'migrate-messages MyNode' => 'Show all messages for the MyNode migration',
|
||||
@@ -139,7 +138,10 @@ function migrate_tools_drush_command() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display migration status.
|
||||
*
|
||||
* @param string $migration_names
|
||||
* The migration names.
|
||||
*/
|
||||
function drush_migrate_tools_migrate_status($migration_names = '') {
|
||||
$names_only = drush_get_option('names-only');
|
||||
@@ -153,12 +155,12 @@ function drush_migrate_tools_migrate_status($migration_names = '') {
|
||||
$group_name = !empty($group) ? "{$group->label()} ({$group->id()})" : $group_id;
|
||||
if ($names_only) {
|
||||
$table[] = [
|
||||
dt('Group: @name', array('@name' => $group_name))
|
||||
dt('Group: @name', ['@name' => $group_name]),
|
||||
];
|
||||
}
|
||||
else {
|
||||
$table[] = [
|
||||
dt('Group: @name', array('@name' => $group_name)),
|
||||
dt('Group: @name', ['@name' => $group_name]),
|
||||
dt('Status'),
|
||||
dt('Total'),
|
||||
dt('Imported'),
|
||||
@@ -204,7 +206,7 @@ function drush_migrate_tools_migrate_status($migration_names = '') {
|
||||
$migrate_last_imported_store = \Drupal::keyValue('migrate_last_imported');
|
||||
$last_imported = $migrate_last_imported_store->get($migration->id(), FALSE);
|
||||
if ($last_imported) {
|
||||
/** @var DateFormatter $date_formatter */
|
||||
/** @var \Drupal\Core\Datetime\DateFormatter $date_formatter */
|
||||
$date_formatter = \Drupal::service('date.formatter');
|
||||
$last_imported = $date_formatter->format($last_imported / 1000,
|
||||
'custom', 'Y-m-d H:i:s');
|
||||
@@ -212,7 +214,14 @@ function drush_migrate_tools_migrate_status($migration_names = '') {
|
||||
else {
|
||||
$last_imported = '';
|
||||
}
|
||||
$table[] = [$migration_id, $status, $source_rows, $imported, $unprocessed, $last_imported];
|
||||
$table[] = [
|
||||
$migration_id,
|
||||
$status,
|
||||
$source_rows,
|
||||
$imported,
|
||||
$unprocessed,
|
||||
$last_imported,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,7 +229,10 @@ function drush_migrate_tools_migrate_status($migration_names = '') {
|
||||
}
|
||||
|
||||
/**
|
||||
* Import a migration.
|
||||
*
|
||||
* @param string $migration_names
|
||||
* The migration names.
|
||||
*/
|
||||
function drush_migrate_tools_migrate_import($migration_names = '') {
|
||||
$group_names = drush_get_option('group');
|
||||
@@ -257,17 +269,19 @@ function drush_migrate_tools_migrate_import($migration_names = '') {
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a single migration. If the --execute-dependencies option was given,
|
||||
* the migration's dependencies will also be executed first.
|
||||
* Executes a single migration.
|
||||
*
|
||||
* If the --execute-dependencies option was given, the migration's dependencies
|
||||
* will also be executed first.
|
||||
*
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration to execute.
|
||||
* The migration to execute.
|
||||
* @param string $migration_id
|
||||
* The migration ID (not used, just an artifact of array_walk()).
|
||||
* The migration ID (not used, just an artifact of array_walk()).
|
||||
* @param array $options
|
||||
* Additional options for the migration.
|
||||
* Additional options for the migration.
|
||||
*/
|
||||
function _drush_migrate_tools_execute_migration(MigrationInterface $migration, $migration_id, array $options = []) {
|
||||
function _drush_migrate_tools_execute_migration(MigrationInterface $migration, $migration_id, array $options = []) {
|
||||
$log = new DrushLogMigrateMessage();
|
||||
|
||||
if (drush_get_option('execute-dependencies')) {
|
||||
@@ -285,16 +299,22 @@ function _drush_migrate_tools_execute_migration(MigrationInterface $migration, $
|
||||
$migration->getIdMap()->prepareUpdate();
|
||||
}
|
||||
$executable = new MigrateExecutable($migration, $log, $options);
|
||||
// drush_op() provides --simulate support
|
||||
drush_op(array($executable, 'import'));
|
||||
// Function drush_op() provides --simulate support.
|
||||
drush_op([$executable, 'import']);
|
||||
if ($count = $executable->getFailedCount()) {
|
||||
// Nudge Drush to use a non-zero exit code.
|
||||
drush_set_error('MIGRATE_ERROR', dt('!name Migration - !count failed.', array('!name' => $migration_id, '!count' => $count)));
|
||||
drush_set_error('MIGRATE_ERROR', dt('!name Migration - !count failed.', [
|
||||
'!name' => $migration_id,
|
||||
'!count' => $count,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback migrations.
|
||||
*
|
||||
* @param string $migration_names
|
||||
* The migration names.
|
||||
*/
|
||||
function drush_migrate_tools_migrate_rollback($migration_names = '') {
|
||||
$group_names = drush_get_option('group');
|
||||
@@ -324,17 +344,21 @@ function drush_migrate_tools_migrate_rollback($migration_names = '') {
|
||||
foreach ($migration_list as $migration_id => $migration) {
|
||||
$executable = new MigrateExecutable($migration, $log, $options);
|
||||
// drush_op() provides --simulate support.
|
||||
drush_op(array($executable, 'rollback'));
|
||||
drush_op([$executable, 'rollback']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop a migration.
|
||||
*
|
||||
* @param string $migration_id
|
||||
* The migration id.
|
||||
*/
|
||||
function drush_migrate_tools_migrate_stop($migration_id = '') {
|
||||
/** @var MigrationInterface $migration */
|
||||
$migration = \Drupal::service('plugin.manager.migration')->createInstance($migration_id);
|
||||
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
|
||||
$migration = \Drupal::service('plugin.manager.migration')
|
||||
->createInstance($migration_id);
|
||||
if ($migration) {
|
||||
$status = $migration->getStatus();
|
||||
switch ($status) {
|
||||
@@ -359,11 +383,15 @@ function drush_migrate_tools_migrate_stop($migration_id = '') {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset status.
|
||||
*
|
||||
* @param string $migration_id
|
||||
* The migration id.
|
||||
*/
|
||||
function drush_migrate_tools_migrate_reset_status($migration_id = '') {
|
||||
/** @var MigrationInterface $migration */
|
||||
$migration = \Drupal::service('plugin.manager.migration')->createInstance($migration_id);
|
||||
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
|
||||
$migration = \Drupal::service('plugin.manager.migration')
|
||||
->createInstance($migration_id);
|
||||
if ($migration) {
|
||||
$status = $migration->getStatus();
|
||||
if ($status == MigrationInterface::STATUS_IDLE) {
|
||||
@@ -380,11 +408,15 @@ function drush_migrate_tools_migrate_reset_status($migration_id = '') {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print messages.
|
||||
*
|
||||
* @param string $migration_id
|
||||
* The migration id.
|
||||
*/
|
||||
function drush_migrate_tools_migrate_messages($migration_id) {
|
||||
/** @var MigrationInterface $migration */
|
||||
$migration = \Drupal::service('plugin.manager.migration')->createInstance($migration_id);
|
||||
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
|
||||
$migration = \Drupal::service('plugin.manager.migration')
|
||||
->createInstance($migration_id);
|
||||
if ($migration) {
|
||||
$map = $migration->getIdMap();
|
||||
$first = TRUE;
|
||||
@@ -399,7 +431,7 @@ function drush_migrate_tools_migrate_messages($migration_id) {
|
||||
}
|
||||
$first = FALSE;
|
||||
}
|
||||
$table[] = (array)$row;
|
||||
$table[] = (array) $row;
|
||||
}
|
||||
if (empty($table)) {
|
||||
drush_log(dt('No messages for this migration'), 'status');
|
||||
@@ -425,11 +457,15 @@ function drush_migrate_tools_migrate_messages($migration_id) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print source fields.
|
||||
*
|
||||
* @param string $migration_id
|
||||
* The migration id.
|
||||
*/
|
||||
function drush_migrate_tools_migrate_fields_source($migration_id) {
|
||||
/** @var MigrationInterface $migration */
|
||||
$migration = \Drupal::service('plugin.manager.migration')->createInstance($migration_id);
|
||||
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
|
||||
$migration = \Drupal::service('plugin.manager.migration')
|
||||
->createInstance($migration_id);
|
||||
if ($migration) {
|
||||
$source = $migration->getSourcePlugin();
|
||||
$table = [];
|
||||
@@ -447,9 +483,10 @@ function drush_migrate_tools_migrate_fields_source($migration_id) {
|
||||
* Retrieve a list of active migrations.
|
||||
*
|
||||
* @param string $migration_ids
|
||||
* Comma-separated list of migrations - if present, return only these migrations.
|
||||
* Comma-separated list of migrations - if present, return only these
|
||||
* migrations.
|
||||
*
|
||||
* @return MigrationInterface[][]
|
||||
* @return \Drupal\migrate\Plugin\MigrationInterface[][]
|
||||
* An array keyed by migration group, each value containing an array of
|
||||
* migrations or an empty array if no migrations match the input criteria.
|
||||
*/
|
||||
|
||||
@@ -7,8 +7,8 @@ dependencies:
|
||||
- drupal:migrate (>=8.3)
|
||||
- migrate_plus:migrate_plus
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-27
|
||||
version: '8.x-4.0-beta2'
|
||||
# Information added by Drupal.org packaging script on 2018-02-23
|
||||
version: '8.x-4.0-beta3'
|
||||
core: '8.x'
|
||||
project: 'migrate_tools'
|
||||
datestamp: 1511790488
|
||||
datestamp: 1519400307
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
* Implements hook_entity_type_build().
|
||||
*/
|
||||
function migrate_tools_entity_type_build(array &$entity_types) {
|
||||
// Inject our UI into the general migration and migration group config entities.
|
||||
// Inject our UI into the general migration and migration group config
|
||||
// entities.
|
||||
/** @var \Drupal\Core\Config\Entity\ConfigEntityType[] $entity_types */
|
||||
$entity_types['migration']
|
||||
->set('admin_permission', 'administer migrations')
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
services:
|
||||
logger.channel.migrate_tools:
|
||||
class: Drupal\Core\Logger\LoggerChannel
|
||||
factory: logger.factory:get
|
||||
arguments: ['migrate_tools']
|
||||
@@ -1,126 +1,207 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ruleset name="drupal_core">
|
||||
<description>PHP CodeSniffer configuration</description>
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="Drupal coding standards">
|
||||
<description>Drupal 8 coding standards</description>
|
||||
|
||||
<file>.</file>
|
||||
<arg name="extensions" value="install,module,php"/>
|
||||
<arg name="extensions" value="inc,install,module,php,profile,test,theme"/>
|
||||
|
||||
<!--Exclude third party code.-->
|
||||
<exclude-pattern>./vendor/*</exclude-pattern>
|
||||
|
||||
<!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.-->
|
||||
<!-- Drupal sniffs -->
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/ClassCreateInstanceSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/ClassDeclarationSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/UnusedUseStatementSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/UseLeadingBackslashSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/CSS/ColourDefinitionSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/ClassCommentSniff.php">
|
||||
<exclude name="Drupal.Commenting.ClassComment.Missing"/>
|
||||
</rule>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php">
|
||||
<!-- Sniff for these errors: SpacingAfterTagGroup, WrongEnd, SpacingBetween,
|
||||
ContentAfterOpen, SpacingBeforeShort, TagValueIndent, ShortStartSpace,
|
||||
SpacingAfter -->
|
||||
<exclude name="Drupal.Commenting.DocComment.LongNotCapital"/>
|
||||
<!-- ParamNotFirst still not decided for PHPUnit-based tests.
|
||||
@see https://www.drupal.org/node/2253915 -->
|
||||
<exclude name="Drupal.Commenting.DocComment.ParamNotFirst"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.SpacingBeforeTags"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.LongFullStop"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.ShortNotCapital"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.ShortFullStop"/>
|
||||
<!--Run Drupal standards.-->
|
||||
<rule ref="Drupal.Array"/>
|
||||
<rule ref="Drupal.Classes"/>
|
||||
<rule ref="Drupal.Commenting">
|
||||
<!-- TagsNotGrouped and ParamGroup have false-positives.
|
||||
@see https://www.drupal.org/node/2060925 -->
|
||||
<exclude name="Drupal.Commenting.DocComment.TagsNotGrouped"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.ParamGroup"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.ShortSingleLine"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.TagGroupSpacing"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.MissingShort"/>
|
||||
</rule>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentStarSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/FileCommentSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php">
|
||||
<exclude name="Drupal.Commenting.FunctionComment.IncorrectTypeHint"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.InvalidNoReturn"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.InvalidReturnNotVoid"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.InvalidTypeHint"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.Missing"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.MissingFile"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.MissingParamComment"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.MissingParamType"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.MissingReturnComment"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.MissingReturnType"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.ParamCommentFullStop"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.ParamCommentIndentation"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.ParamMissingDefinition"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.ParamNameNoMatch"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.TypeHintMissing"/>
|
||||
</rule>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/ControlStructures/ElseIfSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Files/TxtFileLineLengthSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Formatting/MultiLineAssignmentSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Formatting/SpaceInlineIfSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Formatting/SpaceUnaryOperatorSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Functions/DiscouragedFunctionsSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Functions/FunctionDeclarationSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/AutoAddedKeysSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php">
|
||||
<!-- Sniff for: LowerStart -->
|
||||
<exclude name="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/>
|
||||
</rule>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Scope/MethodScopeSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/EmptyInstallSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTSniff.php">
|
||||
<exclude name="Drupal.Semantics.FunctionT.BackslashSingleQuote"/>
|
||||
<exclude name="Drupal.Semantics.FunctionT.NotLiteralString"/>
|
||||
<exclude name="Drupal.Semantics.FunctionT.ConcatString"/>
|
||||
</rule>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/FunctionWatchdogSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/InstallHooksSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/LStringTranslatableSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/PregSecuritySniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/TInHookMenuSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/TInHookSchemaSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/CommaSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenTagNewlineSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/OperatorSpacingSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php"/>
|
||||
<rule ref="Drupal.ControlStructures"/>
|
||||
<rule ref="Drupal.CSS"/>
|
||||
<rule ref="Drupal.Files"/>
|
||||
<rule ref="Drupal.Formatting"/>
|
||||
<rule ref="Drupal.Functions"/>
|
||||
<rule ref="Drupal.InfoFiles"/>
|
||||
<rule ref="Drupal.Methods"/>
|
||||
<rule ref="Drupal.NamingConventions"/>
|
||||
<rule ref="Drupal.Scope"/>
|
||||
<rule ref="Drupal.Semantics"/>
|
||||
<rule ref="Drupal.Strings"/>
|
||||
<rule ref="Drupal.WhiteSpace"/>
|
||||
|
||||
<!-- Drupal Practice sniffs -->
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php"/>
|
||||
<rule ref="DrupalPractice.Commenting"/>
|
||||
|
||||
<!-- Generic sniffs -->
|
||||
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
|
||||
<rule ref="Generic.Files.ByteOrderMark"/>
|
||||
<rule ref="Generic.Files.LineEndings"/>
|
||||
<rule ref="Generic.Formatting.SpaceAfterCast"/>
|
||||
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
|
||||
<rule ref="Generic.NamingConventions.ConstructorName" />
|
||||
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
|
||||
<properties>
|
||||
<property name="checkClosures" value="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Generic.NamingConventions.ConstructorName"/>
|
||||
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
|
||||
<rule ref="Generic.PHP.DeprecatedFunctions"/>
|
||||
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
|
||||
<rule ref="Generic.PHP.LowerCaseKeyword"/>
|
||||
<rule ref="Generic.PHP.UpperCaseConstant"/>
|
||||
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
|
||||
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
|
||||
|
||||
<!-- MySource sniffs -->
|
||||
<rule ref="MySource.Debug.DebugCode"/>
|
||||
|
||||
<!-- PEAR sniffs -->
|
||||
<rule ref="PEAR.Files.IncludingFile"/>
|
||||
<!-- Disable some error messages that we do not want. -->
|
||||
<rule ref="PEAR.Files.IncludingFile.UseIncludeOnce">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Files.IncludingFile.UseInclude">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Files.IncludingFile.UseRequireOnce">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Files.IncludingFile.UseRequire">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Functions.ValidDefaultValue"/>
|
||||
|
||||
<!-- PEAR sniffs -->
|
||||
<rule ref="PEAR.Functions.FunctionCallSignature"/>
|
||||
<!-- The sniffs inside PEAR.Functions.FunctionCallSignature silenced below are
|
||||
also silenced in Drupal CS' ruleset.xml. The code below is a 1-on-1 copy
|
||||
from that file. -->
|
||||
<!-- Disable some error messages that we already cover. -->
|
||||
<rule ref="PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Functions.FunctionCallSignature.SpaceBeforeCloseBracket">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<!-- Disable some error messages that we do not want. -->
|
||||
<rule ref="PEAR.Functions.FunctionCallSignature.Indent">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
|
||||
<!-- PSR-2 sniffs -->
|
||||
<rule ref="PSR2.Classes.PropertyDeclaration">
|
||||
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
|
||||
</rule>
|
||||
<rule ref="PSR2.Namespaces.NamespaceDeclaration"/>
|
||||
<rule ref="PSR2.Namespaces.UseDeclaration">
|
||||
<exclude name="PSR2.Namespaces.UseDeclaration.UseAfterNamespace"/>
|
||||
</rule>
|
||||
|
||||
<!-- Squiz sniffs -->
|
||||
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration">
|
||||
<exclude name="Squiz.Arrays.ArrayDeclaration.NoKeySpecified"/>
|
||||
<exclude name="Squiz.Arrays.ArrayDeclaration.KeySpecified"/>
|
||||
</rule>
|
||||
<!-- Disable some error messages that we do not want. -->
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration.FirstValueNoNewline">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration.NoComma">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration.NotLowerCase">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Arrays.ArrayDeclaration.ValueNoNewline">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
|
||||
<!-- Disable some error messages that we already cover. -->
|
||||
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceBeforeClose">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
|
||||
<!-- Disable some error messages that we already cover. -->
|
||||
<rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterOpen">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingBeforeClose">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/>
|
||||
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<!-- Standard yet to be finalized on this (https://www.drupal.org/node/1539712). -->
|
||||
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.FirstParamSpacing">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.Indent">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.CloseBracketLine">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
|
||||
<properties>
|
||||
<property name="equalsSpacing" value="1"/>
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.NoSpaceBeforeArg">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
|
||||
<rule ref="Squiz.Strings.ConcatenationSpacing">
|
||||
<properties>
|
||||
<property name="spacing" value="1"/>
|
||||
<property name="ignoreNewlines" value="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
</rule>
|
||||
<rule ref="Squiz.WhiteSpace.LanguageConstructSpacing" />
|
||||
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
|
||||
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
|
||||
|
||||
<!-- Zend sniffs -->
|
||||
<rule ref="Zend.Files.ClosingTag"/>
|
||||
|
||||
</ruleset>
|
||||
|
||||
@@ -12,10 +12,8 @@ use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationPluginManager;
|
||||
use Drupal\migrate\Plugin\RequirementsInterface;
|
||||
use Drupal\migrate_tools\Drush9LogMigrateMessage;
|
||||
use Drupal\migrate_tools\DrushLogMigrateMessage;
|
||||
use Drupal\migrate_tools\MigrateExecutable;
|
||||
use Drush\Commands\DrushCommands;
|
||||
use Drush\Drush;
|
||||
|
||||
/**
|
||||
* Migrate Tools drush commands.
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ class MessageController extends ControllerBase {
|
||||
public function overview($migration_group, $migration) {
|
||||
$rows = [];
|
||||
$classes = static::getLogLevelClassMap();
|
||||
/** @var MigrationInterface $migration */
|
||||
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
|
||||
$migration = $this->migrationPluginManager->createInstance($migration);
|
||||
$source_id_field_names = array_keys($migration->getSourcePlugin()->getIds());
|
||||
$column_number = 1;
|
||||
|
||||
+2
-2
@@ -34,13 +34,13 @@ class MigrationGroupListBuilder extends ConfigEntityListBuilder {
|
||||
/**
|
||||
* Builds a row for an entity in the entity listing.
|
||||
*
|
||||
* @param EntityInterface $entity
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity for which to build the row.
|
||||
*
|
||||
* @return array
|
||||
* A render array of the table row for displaying the entity.
|
||||
*
|
||||
* @see Drupal\Core\Entity\EntityListController::render()
|
||||
* @see \Drupal\Core\Entity\EntityListController::render()
|
||||
*/
|
||||
public function buildRow(EntityInterface $entity) {
|
||||
$row['label'] = $entity->label();
|
||||
|
||||
+23
-7
@@ -8,6 +8,7 @@ use Drupal\Core\Entity\EntityHandlerInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Logger\LoggerChannelInterface;
|
||||
use Drupal\Core\Routing\CurrentRouteMatch;
|
||||
use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
|
||||
use Drupal\migrate_plus\Entity\MigrationGroup;
|
||||
@@ -37,6 +38,13 @@ class MigrationListBuilder extends ConfigEntityListBuilder implements EntityHand
|
||||
*/
|
||||
protected $migrationPluginManager;
|
||||
|
||||
/**
|
||||
* The logger service.
|
||||
*
|
||||
* @var \Drupal\Core\Logger\LoggerChannelInterface
|
||||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* Constructs a new EntityListBuilder object.
|
||||
*
|
||||
@@ -48,11 +56,14 @@ class MigrationListBuilder extends ConfigEntityListBuilder implements EntityHand
|
||||
* The current route match service.
|
||||
* @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager
|
||||
* The plugin manager for config entity-based migrations.
|
||||
* @param \Drupal\Core\Logger\LoggerChannelInterface $logger
|
||||
* The logger service.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, CurrentRouteMatch $current_route_match, MigrationPluginManagerInterface $migration_plugin_manager) {
|
||||
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, CurrentRouteMatch $current_route_match, MigrationPluginManagerInterface $migration_plugin_manager, LoggerChannelInterface $logger) {
|
||||
parent::__construct($entity_type, $storage);
|
||||
$this->currentRouteMatch = $current_route_match;
|
||||
$this->migrationPluginManager = $migration_plugin_manager;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +74,8 @@ class MigrationListBuilder extends ConfigEntityListBuilder implements EntityHand
|
||||
$entity_type,
|
||||
$container->get('entity.manager')->getStorage($entity_type->id()),
|
||||
$container->get('current_route_match'),
|
||||
$container->get('plugin.manager.migration')
|
||||
$container->get('plugin.manager.migration'),
|
||||
$container->get('logger.channel.migrate_tools')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -121,7 +133,7 @@ class MigrationListBuilder extends ConfigEntityListBuilder implements EntityHand
|
||||
* @param \Drupal\Core\Entity\EntityInterface $migration_entity
|
||||
* The migration plugin for which to build the row.
|
||||
*
|
||||
* @return array
|
||||
* @return array|null
|
||||
* A render array of the table row for displaying the plugin information.
|
||||
*
|
||||
* @see \Drupal\Core\Entity\EntityListController::render()
|
||||
@@ -147,7 +159,9 @@ class MigrationListBuilder extends ConfigEntityListBuilder implements EntityHand
|
||||
];
|
||||
$row['machine_name'] = $migration->id();
|
||||
$row['status'] = $migration->getStatusLabel();
|
||||
} catch (PluginException $e) {
|
||||
}
|
||||
catch (PluginException $e) {
|
||||
$this->logger->warning('Migration entity id %id is malformed', ['%id' => $migration_entity->id()]);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -196,7 +210,8 @@ class MigrationListBuilder extends ConfigEntityListBuilder implements EntityHand
|
||||
],
|
||||
],
|
||||
];
|
||||
} catch (PluginException $e) {
|
||||
}
|
||||
catch (PluginException $e) {
|
||||
// Derive the stats.
|
||||
$row['status'] = $this->t('No data found');
|
||||
$row['total'] = $this->t('N/A');
|
||||
@@ -211,10 +226,11 @@ class MigrationListBuilder extends ConfigEntityListBuilder implements EntityHand
|
||||
}
|
||||
|
||||
/**
|
||||
* Add group route parameter.
|
||||
*
|
||||
* @param \Drupal\Core\Url $url
|
||||
* The URL associated with an operation.
|
||||
*
|
||||
* @param $migration_group
|
||||
* @param string $migration_group
|
||||
* The migration's parent group.
|
||||
*/
|
||||
protected function addGroupParameter(Url $url, $migration_group) {
|
||||
|
||||
@@ -4,6 +4,11 @@ namespace Drupal\migrate_tools;
|
||||
|
||||
use Drupal\migrate\MigrateMessageInterface;
|
||||
|
||||
/**
|
||||
* Class DrushLogMigrateMessage.
|
||||
*
|
||||
* @package Drupal\migrate_tools
|
||||
*/
|
||||
class DrushLogMigrateMessage implements MigrateMessageInterface {
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@ use Drupal\Core\Url;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Class MigrationDeleteForm.
|
||||
* Provides the delete form for our Migration entity.
|
||||
*
|
||||
* @package Drupal\migrate_tools\Form
|
||||
*
|
||||
@@ -23,7 +23,7 @@ class MigrationDeleteForm extends EntityConfirmFormBase {
|
||||
*/
|
||||
public function getQuestion() {
|
||||
return $this->t('Are you sure you want to delete migration %label?', [
|
||||
'%label' => $this->entity->label(),
|
||||
'%label' => $this->entity->label(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
* Class MigrationEditForm
|
||||
*
|
||||
* Provides the edit form for our Migration entity.
|
||||
*
|
||||
* @package Drupal\migrate_tools\Form
|
||||
@@ -37,10 +35,11 @@ class MigrationEditForm extends MigrationFormBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add group route parameter.
|
||||
*
|
||||
* @param \Drupal\Core\Url $url
|
||||
* The URL associated with an operation.
|
||||
*
|
||||
* @param $migration_group
|
||||
* @param string $migration_group
|
||||
* The migration's parent group.
|
||||
*/
|
||||
protected function addGroupParameter(Url $url, $migration_group) {
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_tools\Form\MigrationExecuteForm
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_tools\Form;
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\MigrateMessage;
|
||||
use Drupal\migrate\MigrateMessageInterface;
|
||||
use Drupal\migrate\Plugin\Migration;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
|
||||
use Drupal\migrate_tools\MigrateBatchExecutable;
|
||||
use Drupal\migrate_tools\MigrateExecutable;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
@@ -129,13 +120,7 @@ class MigrationExecuteForm extends FormBase {
|
||||
completed.'),
|
||||
];
|
||||
// @TODO: Limit is not working. Perhaps because of batch? See
|
||||
// https://www.drupal.org/project/migrate_tools/issues/2924298
|
||||
// $form['options']['limit'] = [
|
||||
// '#type' => 'textfield',
|
||||
// '#title' => t('Limit to:'),
|
||||
// '#size' => 10,
|
||||
// '#description' => t('Set a limit of how many items to process for each migration task.'),
|
||||
// ];
|
||||
// https://www.drupal.org/project/migrate_tools/issues/2924298.
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -181,7 +166,7 @@ class MigrationExecuteForm extends FormBase {
|
||||
|
||||
if ($migration_name) {
|
||||
|
||||
/** @var MigrationInterface $migration */
|
||||
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
|
||||
$migration = $this->migrationPluginManager->createInstance($migration_name);
|
||||
$migrateMessage = new MigrateMessage();
|
||||
|
||||
@@ -204,7 +189,7 @@ class MigrationExecuteForm extends FormBase {
|
||||
$options = [
|
||||
'limit' => $limit,
|
||||
'update' => $update,
|
||||
'force' => $force
|
||||
'force' => $force,
|
||||
];
|
||||
|
||||
$executable = new MigrateBatchExecutable($migration, $migrateMessage, $options);
|
||||
|
||||
@@ -18,6 +18,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
class MigrationFormBase extends EntityForm {
|
||||
|
||||
/**
|
||||
* The entity query factory.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\Query\QueryFactory
|
||||
*/
|
||||
protected $entityQueryFactory;
|
||||
@@ -25,8 +27,8 @@ class MigrationFormBase extends EntityForm {
|
||||
/**
|
||||
* Construct the MigrationGroupFormBase.
|
||||
*
|
||||
* For simple entity forms, there's no need for a constructor. Our migration form
|
||||
* base, however, requires an entity query factory to be injected into it
|
||||
* For simple entity forms, there's no need for a constructor. Our migration
|
||||
* form base, however, requires an entity query factory to be injected into it
|
||||
* from the container. We later use this query factory to build an entity
|
||||
* query for the exists() method.
|
||||
*
|
||||
@@ -38,12 +40,7 @@ class MigrationFormBase extends EntityForm {
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method for MigrationFormBase.
|
||||
*
|
||||
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
|
||||
* A container interface service.
|
||||
*
|
||||
* @return \Drupal\migrate_tools\Form\MigrationGroupFormBase
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static($container->get('entity.query'));
|
||||
@@ -72,7 +69,7 @@ class MigrationFormBase extends EntityForm {
|
||||
$form['warning'] = [
|
||||
'#markup' => $this->t('Creating migrations is not yet supported. See <a href=":url">:url</a>', [
|
||||
':url' => 'https://www.drupal.org/node/2573241',
|
||||
])
|
||||
]),
|
||||
];
|
||||
|
||||
// Build the form.
|
||||
@@ -123,7 +120,7 @@ class MigrationFormBase extends EntityForm {
|
||||
* The entity ID.
|
||||
* @param array $element
|
||||
* The form element.
|
||||
* @param FormStateInterface $form_state
|
||||
* @param \Drupal\Core\Form\FormStateInterface $form_state
|
||||
* The form state.
|
||||
*
|
||||
* @return bool
|
||||
@@ -164,14 +161,7 @@ class MigrationFormBase extends EntityForm {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\Core\Entity\EntityFormController::save().
|
||||
*
|
||||
* @param array $form
|
||||
* An associative array containing the structure of the form.
|
||||
* @param \Drupal\Core\Form\FormStateInterface $form_state
|
||||
* An associative array containing the current state of the form.
|
||||
*
|
||||
* @return $this
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save(array $form, FormStateInterface $form_state) {
|
||||
$migration = $this->getEntity();
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ use Drupal\Core\Url;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Class MigrationGroupDeleteForm.
|
||||
* Provides the delete form for our Migration Group entity.
|
||||
*
|
||||
* @package Drupal\migrate_tools\Form
|
||||
*
|
||||
@@ -23,7 +23,7 @@ class MigrationGroupDeleteForm extends EntityConfirmFormBase {
|
||||
*/
|
||||
public function getQuestion() {
|
||||
return $this->t('Are you sure you want to delete migration group %label?', [
|
||||
'%label' => $this->entity->label(),
|
||||
'%label' => $this->entity->label(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@ namespace Drupal\migrate_tools\Form;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Class MigrationGroupEditForm
|
||||
*
|
||||
* Provides the edit form for our Migration Group entity.
|
||||
*
|
||||
* @package Drupal\migrate_tools\Form
|
||||
|
||||
+9
-19
@@ -17,6 +17,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
class MigrationGroupFormBase extends EntityForm {
|
||||
|
||||
/**
|
||||
* The query factory service.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\Query\QueryFactory
|
||||
*/
|
||||
protected $entityQueryFactory;
|
||||
@@ -24,10 +26,10 @@ class MigrationGroupFormBase extends EntityForm {
|
||||
/**
|
||||
* Construct the MigrationGroupFormBase.
|
||||
*
|
||||
* For simple entity forms, there's no need for a constructor. Our migration group form
|
||||
* base, however, requires an entity query factory to be injected into it
|
||||
* from the container. We later use this query factory to build an entity
|
||||
* query for the exists() method.
|
||||
* For simple entity forms, there's no need for a constructor. Our migration
|
||||
* group form base, however, requires an entity query factory to be injected
|
||||
* into it from the container. We later use this query factory to build an
|
||||
* entity query for the exists() method.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\Query\QueryFactory $query_factory
|
||||
* An entity query factory for the migration group entity type.
|
||||
@@ -37,12 +39,7 @@ class MigrationGroupFormBase extends EntityForm {
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method for MigrationGroupFormBase.
|
||||
*
|
||||
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
|
||||
* A container interface service.
|
||||
*
|
||||
* @return \Drupal\migrate_tools\Form\MigrationFormBase
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static($container->get('entity.query'));
|
||||
@@ -112,7 +109,7 @@ class MigrationGroupFormBase extends EntityForm {
|
||||
* The entity ID.
|
||||
* @param array $element
|
||||
* The form element.
|
||||
* @param FormStateInterface $form_state
|
||||
* @param \Drupal\Core\Form\FormStateInterface $form_state
|
||||
* The form state.
|
||||
*
|
||||
* @return bool
|
||||
@@ -153,14 +150,7 @@ class MigrationGroupFormBase extends EntityForm {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\Core\Entity\EntityFormController::save().
|
||||
*
|
||||
* @param array $form
|
||||
* An associative array containing the structure of the form.
|
||||
* @param \Drupal\Core\Form\FormStateInterface $form_state
|
||||
* An associative array containing the current state of the form.
|
||||
*
|
||||
* @return $this
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save(array $form, FormStateInterface $form_state) {
|
||||
$migration_group = $this->getEntity();
|
||||
|
||||
@@ -66,8 +66,9 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
* Sets the current batch content so listeners can update the messages.
|
||||
*
|
||||
* @param array $context
|
||||
* The batch context.
|
||||
*/
|
||||
public function setBatchContext(&$context) {
|
||||
public function setBatchContext(array &$context) {
|
||||
$this->batchContext = &$context;
|
||||
}
|
||||
|
||||
@@ -75,6 +76,7 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
* Gets a reference to the current batch context.
|
||||
*
|
||||
* @return array
|
||||
* The batch context.
|
||||
*/
|
||||
public function &getBatchContext() {
|
||||
return $this->batchContext;
|
||||
@@ -90,7 +92,7 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
$operations = $this->batchOperations([$this->migration], 'import', [
|
||||
'limit' => $this->itemLimit,
|
||||
'update' => $this->updateExistingRows,
|
||||
'force' => $this->checkDependencies
|
||||
'force' => $this->checkDependencies,
|
||||
]);
|
||||
|
||||
if (count($operations) > 0) {
|
||||
@@ -110,20 +112,18 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
/**
|
||||
* Helper to generate the batch operations for importing migrations.
|
||||
*
|
||||
* @param array $migrations
|
||||
* @param array $operation
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface[] $migrations
|
||||
* The migrations.
|
||||
* @param string $operation
|
||||
* The batch operation to perform.
|
||||
* @param array $options
|
||||
* The migration options.
|
||||
*
|
||||
* @return array
|
||||
* The batch operations to perform.
|
||||
*/
|
||||
protected function batchOperations($migrations, $operation, $options = []) {
|
||||
|
||||
protected function batchOperations(array $migrations, $operation, array $options = []) {
|
||||
$operations = [];
|
||||
|
||||
/**
|
||||
* @var string $id
|
||||
* @var Migration $migration
|
||||
*/
|
||||
foreach ($migrations as $id => $migration) {
|
||||
|
||||
if (!empty($options['update'])) {
|
||||
@@ -143,14 +143,14 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
$operations += $this->batchOperations($required_migrations, $operation, [
|
||||
'limit' => 0,
|
||||
'update' => $options['update'],
|
||||
'force' => $options['force']
|
||||
'force' => $options['force'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$operations[] = [
|
||||
'\Drupal\migrate_tools\MigrateBatchExecutable::batchProcessImport',
|
||||
[$migration->id(), $options]
|
||||
[$migration->id(), $options],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -158,15 +158,16 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch 'operation' callback
|
||||
* Batch 'operation' callback.
|
||||
*
|
||||
* @param string $migration_id
|
||||
* The migration id.
|
||||
* @param array $options
|
||||
* The batch executable options.
|
||||
* @param array $context
|
||||
*
|
||||
* The sandbox context.
|
||||
*/
|
||||
static public function batchProcessImport($migration_id, $options, &$context) {
|
||||
|
||||
public static function batchProcessImport($migration_id, array $options, array &$context) {
|
||||
if (empty($context['sandbox'])) {
|
||||
$context['finished'] = 0;
|
||||
$context['sandbox'] = [];
|
||||
@@ -178,7 +179,7 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
|
||||
// Prepare the migration executable.
|
||||
$message = new MigrateMessage();
|
||||
/** @var MigrationInterface $migration */
|
||||
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
|
||||
$migration = \Drupal::getContainer()->get('plugin.manager.migration')->createInstance($migration_id);
|
||||
$executable = new MigrateBatchExecutable($migration, $message, $options);
|
||||
|
||||
@@ -191,7 +192,7 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
'@updated' => 0,
|
||||
'@failures' => 0,
|
||||
'@ignored' => 0,
|
||||
'@name' => $migration->id()
|
||||
'@name' => $migration->id(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -204,14 +205,14 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
// Do the import.
|
||||
$result = $executable->import();
|
||||
|
||||
// Store the result, we will need to combine the results of all our iterations.
|
||||
// Store the result; will need to combine the results of all our iterations.
|
||||
$context['results'][$migration->id()] = [
|
||||
'@numitems' => $context['results'][$migration->id()]['@numitems'] + $executable->getProcessedCount(),
|
||||
'@created' => $context['results'][$migration->id()]['@created'] + $executable->getCreatedCount(),
|
||||
'@updated' => $context['results'][$migration->id()]['@updated'] + $executable->getUpdatedCount(),
|
||||
'@failures' => $context['results'][$migration->id()]['@failures'] + $executable->getFailedCount(),
|
||||
'@ignored' => $context['results'][$migration->id()]['@ignored'] + $executable->getIgnoredCount(),
|
||||
'@name' => $migration->id()
|
||||
'@name' => $migration->id(),
|
||||
];
|
||||
|
||||
// Do some housekeeping.
|
||||
@@ -226,7 +227,7 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
$context['finished'] = ((float) $context['sandbox']['counter'] / (float) $context['sandbox']['total']);
|
||||
$context['message'] = t('Importing %migration (@percent%).', [
|
||||
'%migration' => $migration->label(),
|
||||
'@percent' => (int) ($context['finished'] * 100)
|
||||
'@percent' => (int) ($context['finished'] * 100),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -236,12 +237,14 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
/**
|
||||
* Finished callback for import batches.
|
||||
*
|
||||
* @param $success
|
||||
* @param $results
|
||||
* @param $operations
|
||||
* @param $elapsed
|
||||
* @param bool $success
|
||||
* A boolean indicating whether the batch has completed successfully.
|
||||
* @param array $results
|
||||
* The value set in $context['results'] by callback_batch_operation().
|
||||
* @param array $operations
|
||||
* If $success is FALSE, contains the operations that remained unprocessed.
|
||||
*/
|
||||
static public function batchFinishedImport($success, $results, $operations, $elapsed) {
|
||||
public static function batchFinishedImport($success, array $results, array $operations) {
|
||||
if ($success) {
|
||||
foreach ($results as $migration_id => $result) {
|
||||
$singular_message = "Processed 1 item (@created created, @updated updated, @failures failed, @ignored ignored) - done with '@name'";
|
||||
@@ -255,7 +258,7 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function checkStatus() {
|
||||
$status = parent::checkStatus();
|
||||
@@ -278,11 +281,13 @@ class MigrateBatchExecutable extends MigrateExecutable {
|
||||
/**
|
||||
* Calculates how much a single batch iteration will handle.
|
||||
*
|
||||
* @param $context
|
||||
* @param array $context
|
||||
* The sandbox context.
|
||||
*
|
||||
* @return float
|
||||
* The batch limit.
|
||||
*/
|
||||
public function calculateBatchLimit($context) {
|
||||
public function calculateBatchLimit(array $context) {
|
||||
// TODO Maybe we need some other more sophisticated logic here?
|
||||
return ceil($context['sandbox']['total'] / 100);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ use Drupal\migrate\Event\MigrateMapDeleteEvent;
|
||||
use Drupal\migrate\Event\MigrateImportEvent;
|
||||
use Drupal\migrate_plus\Event\MigratePrepareRowEvent;
|
||||
|
||||
/**
|
||||
* Defines a migrate executable class for drush.
|
||||
*/
|
||||
class MigrateExecutable extends MigrateExecutableBase {
|
||||
|
||||
/**
|
||||
@@ -40,8 +43,9 @@ class MigrateExecutable extends MigrateExecutableBase {
|
||||
protected $deleteCounter = 0;
|
||||
|
||||
/**
|
||||
* Maximum number of items to process in this migration. 0 indicates no limit
|
||||
* is to be applied.
|
||||
* Maximum number of items to process in this migration.
|
||||
*
|
||||
* 0 indicates no limit is to be applied.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
@@ -63,6 +67,7 @@ class MigrateExecutable extends MigrateExecutableBase {
|
||||
|
||||
/**
|
||||
* Count of number of items processed so far in this migration.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $counter = 0;
|
||||
@@ -149,6 +154,7 @@ class MigrateExecutable extends MigrateExecutableBase {
|
||||
* Return the number of items created.
|
||||
*
|
||||
* @return int
|
||||
* The number of items created.
|
||||
*/
|
||||
public function getCreatedCount() {
|
||||
return $this->saveCounters[MigrateIdMapInterface::STATUS_IMPORTED];
|
||||
@@ -158,6 +164,7 @@ class MigrateExecutable extends MigrateExecutableBase {
|
||||
* Return the number of items updated.
|
||||
*
|
||||
* @return int
|
||||
* The updated count.
|
||||
*/
|
||||
public function getUpdatedCount() {
|
||||
return $this->saveCounters[MigrateIdMapInterface::STATUS_NEEDS_UPDATE];
|
||||
@@ -167,6 +174,7 @@ class MigrateExecutable extends MigrateExecutableBase {
|
||||
* Return the number of items ignored.
|
||||
*
|
||||
* @return int
|
||||
* The ignored count.
|
||||
*/
|
||||
public function getIgnoredCount() {
|
||||
return $this->saveCounters[MigrateIdMapInterface::STATUS_IGNORED];
|
||||
@@ -176,17 +184,20 @@ class MigrateExecutable extends MigrateExecutableBase {
|
||||
* Return the number of items that failed.
|
||||
*
|
||||
* @return int
|
||||
* The failed count.
|
||||
*/
|
||||
public function getFailedCount() {
|
||||
return $this->saveCounters[MigrateIdMapInterface::STATUS_FAILED];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total number of items processed. Note that STATUS_NEEDS_UPDATE
|
||||
* is not counted, since this is typically set on stubs created as side
|
||||
* effects, not on the primary item being imported.
|
||||
* Return the total number of items processed.
|
||||
*
|
||||
* Note that STATUS_NEEDS_UPDATE is not counted, since this is typically set
|
||||
* on stubs created as side effects, not on the primary item being imported.
|
||||
*
|
||||
* @return int
|
||||
* The processed count.
|
||||
*/
|
||||
public function getProcessedCount() {
|
||||
return $this->saveCounters[MigrateIdMapInterface::STATUS_IMPORTED] +
|
||||
@@ -199,6 +210,7 @@ class MigrateExecutable extends MigrateExecutableBase {
|
||||
* Return the number of items rolled back.
|
||||
*
|
||||
* @return int
|
||||
* The rollback count.
|
||||
*/
|
||||
public function getRollbackCount() {
|
||||
return $this->deleteCounter;
|
||||
@@ -237,10 +249,12 @@ class MigrateExecutable extends MigrateExecutableBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit information on what we've done since the last feedback (or the
|
||||
* beginning of this migration).
|
||||
* Emit information on what we've done.
|
||||
*
|
||||
* Either since the last feedback or the beginning of this migration.
|
||||
*
|
||||
* @param bool $done
|
||||
* TRUE if this is the last items to process. Otherwise FALSE.
|
||||
*/
|
||||
protected function progressMessage($done = TRUE) {
|
||||
$processed = $this->getProcessedCount();
|
||||
@@ -254,12 +268,15 @@ class MigrateExecutable extends MigrateExecutableBase {
|
||||
}
|
||||
$this->message->display(\Drupal::translation()->formatPlural($processed,
|
||||
$singular_message, $plural_message,
|
||||
['@numitems' => $processed,
|
||||
'@created' => $this->getCreatedCount(),
|
||||
'@updated' => $this->getUpdatedCount(),
|
||||
'@failures' => $this->getFailedCount(),
|
||||
'@ignored' => $this->getIgnoredCount(),
|
||||
'@name' => $this->migration->id()]));
|
||||
[
|
||||
'@numitems' => $processed,
|
||||
'@created' => $this->getCreatedCount(),
|
||||
'@updated' => $this->getUpdatedCount(),
|
||||
'@failures' => $this->getFailedCount(),
|
||||
'@ignored' => $this->getIgnoredCount(),
|
||||
'@name' => $this->migration->id(),
|
||||
]
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,10 +291,12 @@ class MigrateExecutable extends MigrateExecutableBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit information on what we've done since the last feedback (or the
|
||||
* beginning of this migration).
|
||||
* Emit information on what we've done.
|
||||
*
|
||||
* Either since the last feedback or the beginning of this migration.
|
||||
*
|
||||
* @param bool $done
|
||||
* TRUE if this is the last items to rollback. Otherwise FALSE.
|
||||
*/
|
||||
protected function rollbackMessage($done = TRUE) {
|
||||
$rolled_back = $this->getRollbackCount();
|
||||
@@ -290,9 +309,12 @@ class MigrateExecutable extends MigrateExecutableBase {
|
||||
$plural_message = "Rolled back @numitems items - continuing with '@name'";
|
||||
}
|
||||
$this->message->display(\Drupal::translation()->formatPlural($rolled_back,
|
||||
$singular_message, $plural_message,
|
||||
['@numitems' => $rolled_back,
|
||||
'@name' => $this->migration->id()]));
|
||||
$singular_message, $plural_message,
|
||||
[
|
||||
'@numitems' => $rolled_back,
|
||||
'@name' => $this->migration->id(),
|
||||
]
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -335,9 +357,8 @@ class MigrateExecutable extends MigrateExecutableBase {
|
||||
public function onPrepareRow(MigratePrepareRowEvent $event) {
|
||||
if (!empty($this->idlist)) {
|
||||
$row = $event->getRow();
|
||||
/**
|
||||
* @TODO replace for $source_id = $row->getSourceIdValues(); when https://www.drupal.org/node/2698023 is fixed
|
||||
*/
|
||||
// TODO: replace for $source_id = $row->getSourceIdValues();
|
||||
// when https://www.drupal.org/node/2698023 is fixed.
|
||||
$migration = $event->getMigration();
|
||||
$source_id = array_merge(array_flip(array_keys($migration->getSourcePlugin()
|
||||
->getIds())), $row->getSourceIdValues());
|
||||
|
||||
+3
-3
@@ -7,8 +7,8 @@ dependencies:
|
||||
- drupal:migrate (>=8.3)
|
||||
- migrate_plus:migrate_plus
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-27
|
||||
version: '8.x-4.0-beta2'
|
||||
# Information added by Drupal.org packaging script on 2018-02-23
|
||||
version: '8.x-4.0-beta3'
|
||||
core: '8.x'
|
||||
project: 'migrate_tools'
|
||||
datestamp: 1511790488
|
||||
datestamp: 1519400307
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ use Drupal\taxonomy\Entity\Vocabulary;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Execution form test
|
||||
* Execution form test.
|
||||
*
|
||||
* @group migrate_tools
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user