From 4eda2b40e57b0575e338afdd777f69c30bb38955 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Mon, 15 Jan 2024 15:37:20 -0400 Subject: [PATCH 01/15] Pass all args. --- composer.json | 7 +++++++ drush.services.yml => drush.10-11.services.yml | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) rename drush.services.yml => drush.10-11.services.yml (52%) diff --git a/composer.json b/composer.json index 7ccbf6b..493806c 100644 --- a/composer.json +++ b/composer.json @@ -24,5 +24,12 @@ "suggest": { "discoverygarden/entity_reference_integrity_extra": "Deal with addtional 'entity_reference' fields.", "drupal/entity_reference_integrity": "Used to check things when a migration elects to 'manage_orphans'." + }, + "extra": { + "drush": { + "services": { + "drush.10-11.services.yml": "^10 || ^11" + } + } } } diff --git a/drush.services.yml b/drush.10-11.services.yml similarity index 52% rename from drush.services.yml rename to drush.10-11.services.yml index 5093c21..ace95f1 100644 --- a/drush.services.yml +++ b/drush.10-11.services.yml @@ -2,7 +2,10 @@ services: dgi_migrate.commands: class: \Drupal\dgi_migrate\Drush\Commands\MigrateCommands - factory: [null, create] - arguments: ['@service_container'] + arguments: + - '@plugin.manager.migration' + - '@date.formatter' + - '@entity_type.manager' + - '@keyvalue' tags: - { name: drush.command } From df148cd8680b5a2cc4b161fd4e290747e0325a7c Mon Sep 17 00:00:00 2001 From: Noel Chiasson Date: Mon, 12 Feb 2024 15:37:26 -0400 Subject: [PATCH 02/15] Removing redefinition of logger variable --- .../src/Commands/Pathauto.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/modules/dgi_migrate_regenerate_pathauto_aliases/src/Commands/Pathauto.php b/modules/dgi_migrate_regenerate_pathauto_aliases/src/Commands/Pathauto.php index b75937c..1589e0e 100644 --- a/modules/dgi_migrate_regenerate_pathauto_aliases/src/Commands/Pathauto.php +++ b/modules/dgi_migrate_regenerate_pathauto_aliases/src/Commands/Pathauto.php @@ -40,13 +40,6 @@ class Pathauto extends DrushCommands { */ protected $entityTypeBundleInfo; - /** - * Logger. - * - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - /** * Constructor. * From 5105f1f97689b8caba357a02632be8ceb0e79c7e Mon Sep 17 00:00:00 2001 From: Chris MacDonald <31731869+chrismacdonaldw@users.noreply.github.com> Date: Fri, 1 Mar 2024 11:37:03 -0400 Subject: [PATCH 03/15] Create dgi_migrate_alter --- .../Annotation/MigrationAlter.php | 47 +++++++++++++++++++ .../Exception/MigrationNotFoundException.php | 9 ++++ .../Plugin/MigrationAlterBase.php | 39 +++++++++++++++ .../Plugin/MigrationAlterInterface.php | 20 ++++++++ .../Plugin/MigrationAlterPluginManager.php | 39 +++++++++++++++ .../dgi_migrate_alter.info.yml | 5 ++ .../dgi_migrate_alter.module | 45 ++++++++++++++++++ .../dgi_migrate_alter.services.yml | 8 ++++ 8 files changed, 212 insertions(+) create mode 100644 modules/dgi_migrate_alter/Annotation/MigrationAlter.php create mode 100644 modules/dgi_migrate_alter/Exception/MigrationNotFoundException.php create mode 100644 modules/dgi_migrate_alter/Plugin/MigrationAlterBase.php create mode 100644 modules/dgi_migrate_alter/Plugin/MigrationAlterInterface.php create mode 100644 modules/dgi_migrate_alter/Plugin/MigrationAlterPluginManager.php create mode 100644 modules/dgi_migrate_alter/dgi_migrate_alter.info.yml create mode 100644 modules/dgi_migrate_alter/dgi_migrate_alter.module create mode 100644 modules/dgi_migrate_alter/dgi_migrate_alter.services.yml diff --git a/modules/dgi_migrate_alter/Annotation/MigrationAlter.php b/modules/dgi_migrate_alter/Annotation/MigrationAlter.php new file mode 100644 index 0000000..66b0a92 --- /dev/null +++ b/modules/dgi_migrate_alter/Annotation/MigrationAlter.php @@ -0,0 +1,47 @@ +getPluginDefinition()['migration_id']; + if (isset($migrations[$migration_id])) { + $this->alter($migrations[$migration_id]); + } + else { + throw new MigrationNotFoundException("Migration $migration_id not found."); + } + } + + /** + * Alters the specified migration array provided by alterMigrations. + * + * This method is intended to be overridden in child classes. + * Each child class should implement its own logic. + * + * @param array &$migration + * The migration array to alter. + */ + abstract protected function alter(array &$migration); + +} diff --git a/modules/dgi_migrate_alter/Plugin/MigrationAlterInterface.php b/modules/dgi_migrate_alter/Plugin/MigrationAlterInterface.php new file mode 100644 index 0000000..3e8fdb9 --- /dev/null +++ b/modules/dgi_migrate_alter/Plugin/MigrationAlterInterface.php @@ -0,0 +1,20 @@ +alterInfo('dgi_migrate_alter_' . $type. '_info'); + $this->setCacheBackend($cache_backend, 'dgi_migrate_alter' . $type . '_plugins'); + } + +} diff --git a/modules/dgi_migrate_alter/dgi_migrate_alter.info.yml b/modules/dgi_migrate_alter/dgi_migrate_alter.info.yml new file mode 100644 index 0000000..057e87d --- /dev/null +++ b/modules/dgi_migrate_alter/dgi_migrate_alter.info.yml @@ -0,0 +1,5 @@ +name: 'DGI Migrate Alter' +description: "Allows easy alterations of migrations through plugins." +type: module +package: DGI +core_version_requirement: ^9 || ^10 diff --git a/modules/dgi_migrate_alter/dgi_migrate_alter.module b/modules/dgi_migrate_alter/dgi_migrate_alter.module new file mode 100644 index 0000000..aa97269 --- /dev/null +++ b/modules/dgi_migrate_alter/dgi_migrate_alter.module @@ -0,0 +1,45 @@ +getDefinitions(); + $foxml_definitions = $foxml_alter_manager->getDefinitions(); + + foreach ($spreadsheet_definitions as $id => $definition) { + $logger->info('Altering migrations with spreadsheet plugin: ' . $id); + $plugin = $spreadsheet_alter_manager->createInstance($id); + + try { + $plugin->alterMigrations($migrations); + } + catch (MigrationNotFoundException $e) { + $logger->error('Migration not found: ' . $e->getMessage()); + } + } + + foreach ($foxml_definitions as $id => $definition) { + $logger->info('Altering migrations with foxml plugin: ' . $id); + $plugin = $foxml_alter_manager->createInstance($id); + + try { + $plugin->alterMigrations($migrations); + } + catch (MigrationNotFoundException $e) { + $logger->error('Migration not found: ' . $e->getMessage()); + } + } +} diff --git a/modules/dgi_migrate_alter/dgi_migrate_alter.services.yml b/modules/dgi_migrate_alter/dgi_migrate_alter.services.yml new file mode 100644 index 0000000..b7cf502 --- /dev/null +++ b/modules/dgi_migrate_alter/dgi_migrate_alter.services.yml @@ -0,0 +1,8 @@ +--- +services: + plugin.manager.dgi_migrate_alter.spreadsheet: + class: Drupal\dgi_migrate_alter\Plugin\MigrationAlterPluginManager + arguments: [spreadsheet, '@container.namespaces', '@cache.discovery', '@module_handler'] + plugin.manager.dgi_migrate_alter.foxml: + class: Drupal\dgi_migrate_alter\Plugin\MigrationAlterPluginManager + arguments: [foxml, '@container.namespaces', '@cache.discovery', '@module_handler'] From 497d9023ac8e0b307c4c50c297b5e2f585184f87 Mon Sep 17 00:00:00 2001 From: Chris MacDonald <31731869+chrismacdonaldw@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:31:34 -0400 Subject: [PATCH 04/15] Move some stuff around. --- .../dgi_migrate_alter/{ => src}/Annotation/MigrationAlter.php | 0 .../{ => src}/Exception/MigrationNotFoundException.php | 0 .../dgi_migrate_alter/{ => src}/Plugin/MigrationAlterBase.php | 2 +- .../{ => src}/Plugin/MigrationAlterInterface.php | 0 .../{ => src}/Plugin/MigrationAlterPluginManager.php | 4 ++-- 5 files changed, 3 insertions(+), 3 deletions(-) rename modules/dgi_migrate_alter/{ => src}/Annotation/MigrationAlter.php (100%) rename modules/dgi_migrate_alter/{ => src}/Exception/MigrationNotFoundException.php (100%) rename modules/dgi_migrate_alter/{ => src}/Plugin/MigrationAlterBase.php (96%) rename modules/dgi_migrate_alter/{ => src}/Plugin/MigrationAlterInterface.php (100%) rename modules/dgi_migrate_alter/{ => src}/Plugin/MigrationAlterPluginManager.php (92%) diff --git a/modules/dgi_migrate_alter/Annotation/MigrationAlter.php b/modules/dgi_migrate_alter/src/Annotation/MigrationAlter.php similarity index 100% rename from modules/dgi_migrate_alter/Annotation/MigrationAlter.php rename to modules/dgi_migrate_alter/src/Annotation/MigrationAlter.php diff --git a/modules/dgi_migrate_alter/Exception/MigrationNotFoundException.php b/modules/dgi_migrate_alter/src/Exception/MigrationNotFoundException.php similarity index 100% rename from modules/dgi_migrate_alter/Exception/MigrationNotFoundException.php rename to modules/dgi_migrate_alter/src/Exception/MigrationNotFoundException.php diff --git a/modules/dgi_migrate_alter/Plugin/MigrationAlterBase.php b/modules/dgi_migrate_alter/src/Plugin/MigrationAlterBase.php similarity index 96% rename from modules/dgi_migrate_alter/Plugin/MigrationAlterBase.php rename to modules/dgi_migrate_alter/src/Plugin/MigrationAlterBase.php index aebfa25..5af30e0 100644 --- a/modules/dgi_migrate_alter/Plugin/MigrationAlterBase.php +++ b/modules/dgi_migrate_alter/src/Plugin/MigrationAlterBase.php @@ -6,7 +6,7 @@ use Drupal\dgi_migrate_alter\Exception\MigrationNotFoundException; /** - * Base class for CSV Alteration plugins. + * Base class for migration alter plugins. */ abstract class MigrationAlterBase extends PluginBase implements MigrationAlterInterface { diff --git a/modules/dgi_migrate_alter/Plugin/MigrationAlterInterface.php b/modules/dgi_migrate_alter/src/Plugin/MigrationAlterInterface.php similarity index 100% rename from modules/dgi_migrate_alter/Plugin/MigrationAlterInterface.php rename to modules/dgi_migrate_alter/src/Plugin/MigrationAlterInterface.php diff --git a/modules/dgi_migrate_alter/Plugin/MigrationAlterPluginManager.php b/modules/dgi_migrate_alter/src/Plugin/MigrationAlterPluginManager.php similarity index 92% rename from modules/dgi_migrate_alter/Plugin/MigrationAlterPluginManager.php rename to modules/dgi_migrate_alter/src/Plugin/MigrationAlterPluginManager.php index 3f28a8c..a95b315 100644 --- a/modules/dgi_migrate_alter/Plugin/MigrationAlterPluginManager.php +++ b/modules/dgi_migrate_alter/src/Plugin/MigrationAlterPluginManager.php @@ -7,7 +7,7 @@ use Drupal\Core\Plugin\DefaultPluginManager; /** - * Provides the CSV alteration plugin manager. + * Provides the migration alter plugin manager. */ class MigrationAlterPluginManager extends DefaultPluginManager { @@ -15,7 +15,7 @@ class MigrationAlterPluginManager extends DefaultPluginManager { * Constructs a new MigrationAlterManager object. * * @param string $type - * The type of the plugin: csv, foxml. + * The type of the plugin: spreadsheet, foxml. * @param \Traversable $namespaces * An object that implements \Traversable which contains the root paths * keyed by the corresponding namespace to look for plugin implementations. From 749631f9179846ef06cc3563a0bdc2f4538b8d7c Mon Sep 17 00:00:00 2001 From: Chris MacDonald <31731869+chrismacdonaldw@users.noreply.github.com> Date: Fri, 1 Mar 2024 12:37:57 -0400 Subject: [PATCH 05/15] Address some linting issues. --- modules/dgi_migrate_alter/src/Annotation/MigrationAlter.php | 1 - .../src/Exception/MigrationNotFoundException.php | 3 +-- .../src/Plugin/MigrationAlterPluginManager.php | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/dgi_migrate_alter/src/Annotation/MigrationAlter.php b/modules/dgi_migrate_alter/src/Annotation/MigrationAlter.php index 66b0a92..e2af833 100644 --- a/modules/dgi_migrate_alter/src/Annotation/MigrationAlter.php +++ b/modules/dgi_migrate_alter/src/Annotation/MigrationAlter.php @@ -1,6 +1,5 @@ alterInfo('dgi_migrate_alter_' . $type. '_info'); + $this->alterInfo('dgi_migrate_alter_' . $type . '_info'); $this->setCacheBackend($cache_backend, 'dgi_migrate_alter' . $type . '_plugins'); } From d1150b2fea00833b590123b9aab731720588fd03 Mon Sep 17 00:00:00 2001 From: Chris MacDonald <31731869+chrismacdonaldw@users.noreply.github.com> Date: Tue, 5 Mar 2024 13:11:00 -0400 Subject: [PATCH 06/15] Write readme --- modules/dgi_migrate_alter/README.md | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 modules/dgi_migrate_alter/README.md diff --git a/modules/dgi_migrate_alter/README.md b/modules/dgi_migrate_alter/README.md new file mode 100644 index 0000000..9e93a40 --- /dev/null +++ b/modules/dgi_migrate_alter/README.md @@ -0,0 +1,49 @@ +# DGI Migrate Alter + +## Introduction +A module to easily alter migrations using the `MigrationAlter` plugin. + +## Features +The module adds the `MigrationAlter` plugin base, which allows for the easy alteration of migrations. + +The `MigrationAlter` plugin base has four fields: + - `id` + - `label` + - `description` + - `migration_id` + - The id of the migration you wish to alter + +The path to place the alter plugins is as follows: + - `module/Plugin/dgi_migrate_alter/spreadsheet` + - `module/Plugin/dgi_migrate_alter/foxml` + +There is no strict difference between the two, and are pathed as such strictly for organization. + +The alter itself should be written in the `alter` function. + +## Installation + +Install as usual, see +[this](https://drupal.org/documentation/install/modules-themes/modules-8) for +further information. + +## Troubleshooting/Issues + +Having problems or solved a problem? Contact +[discoverygarden](http://support.discoverygarden.ca). + +## Maintainers and Sponsors + +Current maintainers: + +* [discoverygarden](http://www.discoverygarden.ca) + +## Development/Contribution + +If you would like to contribute to this module, please check out github's helpful +[Contributing to projects](https://docs.github.com/en/get-started/quickstart/contributing-to-projects) documentation and Islandora community's [Documention for developers](https://islandora.github.io/documentation/contributing/CONTRIBUTING/#github-issues) to create an issue or pull request and/or +contact [discoverygarden](http://support.discoverygarden.ca). + +## License + +[GPLv3](http://www.gnu.org/licenses/gpl-3.0.txt) From 876c4c3d2a86eded5938ffd2293966fbdb8b919e Mon Sep 17 00:00:00 2001 From: JojoVes Date: Fri, 10 May 2024 13:24:52 -0300 Subject: [PATCH 07/15] alphabetise use statements used phpcbf --standard=Drupal,DrupalPractice --- modules/devel/src/Plugin/migrate/process/Ddm.php | 2 +- .../src/Config/Overrides.php | 2 +- .../src/Commands/DspaceCommands.php | 3 +-- .../modules/xslt/src/Controller/Xslt.php | 4 +--- .../EventSubscriber/ConfigEventSubscriber.php | 6 ++---- .../xslt/src/Plugin/migrate/process/Process.php | 5 ++--- .../migrate/process/ConstituentSequence.php | 2 +- .../process/DgiStandardTitleParagraph.php | 3 +-- .../tests/src/Kernel/RoleMapperMigrationTest.php | 3 +-- .../tests/src/Unit/RoleMapperTest.php | 3 +-- .../src/EventSubscriber/EventSubscriber.php | 16 +++++++--------- .../src/Commands/Pathauto.php | 8 ++++---- src/MigrateBatchExecutable.php | 15 +++++++-------- .../migrate/process/AbstractEntityAccessor.php | 6 ++---- src/Plugin/migrate/process/AssembleDate.php | 4 ++-- src/Plugin/migrate/process/CrossDeepen.php | 2 +- src/Plugin/migrate/process/DcName.php | 2 +- .../migrate/process/DetermineExtension.php | 8 ++++---- src/Plugin/migrate/process/Method.php | 4 ++-- src/Plugin/migrate/process/NaiveFileCopy.php | 8 ++++---- src/Plugin/migrate/process/Realpath.php | 8 ++++---- src/Plugin/migrate/process/StaticMap.php | 2 +- src/Plugin/migrate/process/SubProcess.php | 2 +- src/Plugin/migrate/process/Subindex.php | 4 ++-- src/Plugin/migrate/process/Subproperty.php | 4 ++-- src/Plugin/migrate/process/TypedRelation.php | 6 ++---- src/Plugin/migrate/process/UnpackArray.php | 4 ++-- src/Plugin/migrate/process/Xml/AbstractDom.php | 4 ++-- src/Plugin/migrate/process/Xml/ContextQuery.php | 4 ++-- src/Plugin/migrate/process/Xml/Xpath.php | 4 ++-- src/Plugin/migrate/source/Migration.php | 6 +++--- src/Routing/RouteSubscriber.php | 3 +-- 32 files changed, 70 insertions(+), 87 deletions(-) diff --git a/modules/devel/src/Plugin/migrate/process/Ddm.php b/modules/devel/src/Plugin/migrate/process/Ddm.php index ec51c25..e742298 100644 --- a/modules/devel/src/Plugin/migrate/process/Ddm.php +++ b/modules/devel/src/Plugin/migrate/process/Ddm.php @@ -2,8 +2,8 @@ namespace Drupal\dgi_migrate_devel\Plugin\migrate\process; -use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; /** diff --git a/modules/dgi_migrate_big_set_overrides/src/Config/Overrides.php b/modules/dgi_migrate_big_set_overrides/src/Config/Overrides.php index 76f47c2..2346053 100644 --- a/modules/dgi_migrate_big_set_overrides/src/Config/Overrides.php +++ b/modules/dgi_migrate_big_set_overrides/src/Config/Overrides.php @@ -4,8 +4,8 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Cache\CacheableMetadata; -use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Config\ConfigFactoryOverrideInterface; use Drupal\Core\Config\StorageInterface; /** diff --git a/modules/dgi_migrate_dspace/src/Commands/DspaceCommands.php b/modules/dgi_migrate_dspace/src/Commands/DspaceCommands.php index 738fa39..a70049f 100644 --- a/modules/dgi_migrate_dspace/src/Commands/DspaceCommands.php +++ b/modules/dgi_migrate_dspace/src/Commands/DspaceCommands.php @@ -2,10 +2,9 @@ namespace Drupal\dgi_migrate_dspace\Commands; -use Drupal\migrate\Plugin\MigrationPluginManagerInterface; - use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\migrate\Plugin\MigrationPluginManagerInterface; use Drush\Commands\DrushCommands; /** diff --git a/modules/dgi_migrate_foxml_standard_mods/modules/xslt/src/Controller/Xslt.php b/modules/dgi_migrate_foxml_standard_mods/modules/xslt/src/Controller/Xslt.php index 1734600..e2d6edc 100644 --- a/modules/dgi_migrate_foxml_standard_mods/modules/xslt/src/Controller/Xslt.php +++ b/modules/dgi_migrate_foxml_standard_mods/modules/xslt/src/Controller/Xslt.php @@ -2,14 +2,12 @@ namespace Drupal\dgi_migrate_foxml_standard_mods_xslt\Controller; -use Drupal\dgi_migrate_foxml_standard_mods_xslt\Form\Settings; - use Drupal\Core\Access\AccessResult; use Drupal\Core\Cache\CacheableResponse; use Drupal\Core\Config\Config; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Session\AccountInterface; - +use Drupal\dgi_migrate_foxml_standard_mods_xslt\Form\Settings; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\IpUtils; use Symfony\Component\HttpFoundation\Request; diff --git a/modules/dgi_migrate_foxml_standard_mods/modules/xslt/src/EventSubscriber/ConfigEventSubscriber.php b/modules/dgi_migrate_foxml_standard_mods/modules/xslt/src/EventSubscriber/ConfigEventSubscriber.php index fafba13..1095695 100644 --- a/modules/dgi_migrate_foxml_standard_mods/modules/xslt/src/EventSubscriber/ConfigEventSubscriber.php +++ b/modules/dgi_migrate_foxml_standard_mods/modules/xslt/src/EventSubscriber/ConfigEventSubscriber.php @@ -2,13 +2,11 @@ namespace Drupal\dgi_migrate_foxml_standard_mods_xslt\EventSubscriber; -use Drupal\dgi_migrate_foxml_standard_mods_xslt\Form\Settings; -use Drupal\migrate\Plugin\MigrationPluginManagerInterface; - use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface; use Drupal\Core\Config\ConfigCrudEvent; use Drupal\Core\Config\ConfigEvents; - +use Drupal\dgi_migrate_foxml_standard_mods_xslt\Form\Settings; +use Drupal\migrate\Plugin\MigrationPluginManagerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** diff --git a/modules/dgi_migrate_foxml_standard_mods/modules/xslt/src/Plugin/migrate/process/Process.php b/modules/dgi_migrate_foxml_standard_mods/modules/xslt/src/Plugin/migrate/process/Process.php index 413881f..35099db 100644 --- a/modules/dgi_migrate_foxml_standard_mods/modules/xslt/src/Plugin/migrate/process/Process.php +++ b/modules/dgi_migrate_foxml_standard_mods/modules/xslt/src/Plugin/migrate/process/Process.php @@ -2,10 +2,9 @@ namespace Drupal\dgi_migrate_foxml_standard_mods_xslt\Plugin\migrate\process; -use Drupal\dgi_saxon_helper_migrate\Plugin\migrate\process\Saxon; -use Drupal\dgi_saxon_helper\TransformerInterface; - use Drupal\Core\Url; +use Drupal\dgi_saxon_helper\TransformerInterface; +use Drupal\dgi_saxon_helper_migrate\Plugin\migrate\process\Saxon; /** * Wrapper to help perform _our_ transformation. diff --git a/modules/dgi_migrate_foxml_standard_mods/src/Plugin/migrate/process/ConstituentSequence.php b/modules/dgi_migrate_foxml_standard_mods/src/Plugin/migrate/process/ConstituentSequence.php index fa4f118..e9b87ff 100644 --- a/modules/dgi_migrate_foxml_standard_mods/src/Plugin/migrate/process/ConstituentSequence.php +++ b/modules/dgi_migrate_foxml_standard_mods/src/Plugin/migrate/process/ConstituentSequence.php @@ -2,8 +2,8 @@ namespace Drupal\dgi_migrate_foxml_standard_mods\Plugin\migrate\process; -use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; /** diff --git a/modules/dgi_migrate_foxml_standard_mods/src/Plugin/migrate/process/DgiStandardTitleParagraph.php b/modules/dgi_migrate_foxml_standard_mods/src/Plugin/migrate/process/DgiStandardTitleParagraph.php index 466d546..58ddaea 100644 --- a/modules/dgi_migrate_foxml_standard_mods/src/Plugin/migrate/process/DgiStandardTitleParagraph.php +++ b/modules/dgi_migrate_foxml_standard_mods/src/Plugin/migrate/process/DgiStandardTitleParagraph.php @@ -2,6 +2,7 @@ namespace Drupal\dgi_migrate_foxml_standard_mods\Plugin\migrate\process; +use Drupal\Component\Utility\Unicode; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateSkipRowException; use Drupal\migrate\Plugin\MigrationInterface; @@ -9,8 +10,6 @@ use Drupal\migrate\Row; use Drupal\paragraphs\Entity\Paragraph; -use Drupal\Component\Utility\Unicode; - /** * Generate a Title paragraph. * diff --git a/modules/dgi_migrate_foxml_standard_mods/tests/src/Kernel/RoleMapperMigrationTest.php b/modules/dgi_migrate_foxml_standard_mods/tests/src/Kernel/RoleMapperMigrationTest.php index 2fc0163..14a0b13 100644 --- a/modules/dgi_migrate_foxml_standard_mods/tests/src/Kernel/RoleMapperMigrationTest.php +++ b/modules/dgi_migrate_foxml_standard_mods/tests/src/Kernel/RoleMapperMigrationTest.php @@ -3,10 +3,9 @@ namespace Drupal\Tests\dgi_migrate_foxml_standard_mods\Kernel; use Drupal\KernelTests\KernelTestBase; -use Symfony\Component\Yaml\Yaml; - use Drupal\migrate\MigrateExecutable; use Drupal\migrate\Row; +use Symfony\Component\Yaml\Yaml; /** * Test out the role mapper. diff --git a/modules/dgi_migrate_foxml_standard_mods/tests/src/Unit/RoleMapperTest.php b/modules/dgi_migrate_foxml_standard_mods/tests/src/Unit/RoleMapperTest.php index 439aa4a..5f76bef 100644 --- a/modules/dgi_migrate_foxml_standard_mods/tests/src/Unit/RoleMapperTest.php +++ b/modules/dgi_migrate_foxml_standard_mods/tests/src/Unit/RoleMapperTest.php @@ -2,9 +2,8 @@ namespace Drupal\Tests\dgi_migrate_foxml_standard_mods\Unit; -use Drupal\Tests\UnitTestCase; - use Drupal\dgi_migrate_foxml_standard_mods\Plugin\migrate\process\TypedRelation; +use Drupal\Tests\UnitTestCase; /** * Test out the role mapper. diff --git a/modules/dgi_migrate_imagemagick_cleanup/src/EventSubscriber/EventSubscriber.php b/modules/dgi_migrate_imagemagick_cleanup/src/EventSubscriber/EventSubscriber.php index 3f02bcb..9f38f68 100644 --- a/modules/dgi_migrate_imagemagick_cleanup/src/EventSubscriber/EventSubscriber.php +++ b/modules/dgi_migrate_imagemagick_cleanup/src/EventSubscriber/EventSubscriber.php @@ -2,18 +2,16 @@ namespace Drupal\dgi_migrate_imagemagick_cleanup\EventSubscriber; -use Drupal\dgi_migrate_imagemagick_cleanup\Event\TempImageEvent; -use Drupal\migrate\Event\MigrateEvents; -use Drupal\migrate\Event\MigratePreRowSaveEvent; -use Drupal\migrate\Event\MigratePostRowSaveEvent; -use Drupal\imagemagick\Event\ImagemagickExecutionEvent; -use Drupal\imagemagick\ImagemagickExecArguments; - use Drupal\Core\DestructableInterface; -use Drupal\Core\File\FileSystemInterface; use Drupal\Core\File\Exception\FileException; +use Drupal\Core\File\FileSystemInterface; use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface; - +use Drupal\dgi_migrate_imagemagick_cleanup\Event\TempImageEvent; +use Drupal\imagemagick\Event\ImagemagickExecutionEvent; +use Drupal\imagemagick\ImagemagickExecArguments; +use Drupal\migrate\Event\MigrateEvents; +use Drupal\migrate\Event\MigratePostRowSaveEvent; +use Drupal\migrate\Event\MigratePreRowSaveEvent; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; diff --git a/modules/dgi_migrate_regenerate_pathauto_aliases/src/Commands/Pathauto.php b/modules/dgi_migrate_regenerate_pathauto_aliases/src/Commands/Pathauto.php index 1589e0e..9d0dd54 100644 --- a/modules/dgi_migrate_regenerate_pathauto_aliases/src/Commands/Pathauto.php +++ b/modules/dgi_migrate_regenerate_pathauto_aliases/src/Commands/Pathauto.php @@ -2,13 +2,13 @@ namespace Drupal\dgi_migrate_regenerate_pathauto_aliases\Commands; -use Drupal\Core\Entity\EntityTypeBundleInfoInterface; -use Drupal\pathauto\PathautoGeneratorInterface; -use Drush\Commands\DrushCommands; use Drupal\Core\DependencyInjection\DependencySerializationTrait; -use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\pathauto\PathautoGeneratorInterface; use Drupal\pathauto\PathautoState; +use Drush\Commands\DrushCommands; use Psr\Log\LoggerInterface; /** diff --git a/src/MigrateBatchExecutable.php b/src/MigrateBatchExecutable.php index 60fd0e3..9344dc6 100644 --- a/src/MigrateBatchExecutable.php +++ b/src/MigrateBatchExecutable.php @@ -2,23 +2,22 @@ namespace Drupal\dgi_migrate; +use Drupal\Component\Utility\Timer; +use Drupal\Core\DependencyInjection\DependencySerializationTrait; use Drupal\Core\Queue\QueueInterface; -use Drupal\migrate\MigrateException; -use Drupal\migrate_tools\IdMapFilter; -use Drupal\migrate_tools\MigrateExecutable; use Drupal\migrate\Event\MigrateEvents; use Drupal\migrate\Event\MigrateImportEvent; use Drupal\migrate\Event\MigratePostRowSaveEvent; use Drupal\migrate\Event\MigratePreRowSaveEvent; use Drupal\migrate\Exception\RequirementsException; -use Drupal\migrate\Plugin\MigrateIdMapInterface; -use Drupal\migrate\Plugin\MigrationInterface; +use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateMessageInterface; use Drupal\migrate\MigrateSkipRowException; +use Drupal\migrate\Plugin\MigrateIdMapInterface; +use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Row; - -use Drupal\Core\DependencyInjection\DependencySerializationTrait; -use Drupal\Component\Utility\Timer; +use Drupal\migrate_tools\IdMapFilter; +use Drupal\migrate_tools\MigrateExecutable; /** * Migration executable to run as fully queued batch. diff --git a/src/Plugin/migrate/process/AbstractEntityAccessor.php b/src/Plugin/migrate/process/AbstractEntityAccessor.php index d45586b..0a640bf 100644 --- a/src/Plugin/migrate/process/AbstractEntityAccessor.php +++ b/src/Plugin/migrate/process/AbstractEntityAccessor.php @@ -2,12 +2,10 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; -use Drupal\migrate\EntityFieldDefinitionTrait; -use Drupal\migrate\ProcessPluginBase; - use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; - +use Drupal\migrate\EntityFieldDefinitionTrait; +use Drupal\migrate\ProcessPluginBase; use Symfony\Component\DependencyInjection\ContainerInterface; /** diff --git a/src/Plugin/migrate/process/AssembleDate.php b/src/Plugin/migrate/process/AssembleDate.php index 4b430bc..86a6078 100644 --- a/src/Plugin/migrate/process/AssembleDate.php +++ b/src/Plugin/migrate/process/AssembleDate.php @@ -2,9 +2,9 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; -use Drupal\migrate\ProcessPluginBase; -use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateException; +use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; /** diff --git a/src/Plugin/migrate/process/CrossDeepen.php b/src/Plugin/migrate/process/CrossDeepen.php index 5d23dc1..679a18c 100644 --- a/src/Plugin/migrate/process/CrossDeepen.php +++ b/src/Plugin/migrate/process/CrossDeepen.php @@ -2,9 +2,9 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; -use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; /** diff --git a/src/Plugin/migrate/process/DcName.php b/src/Plugin/migrate/process/DcName.php index 6da7e76..4fd1b19 100644 --- a/src/Plugin/migrate/process/DcName.php +++ b/src/Plugin/migrate/process/DcName.php @@ -2,8 +2,8 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; -use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; /** diff --git a/src/Plugin/migrate/process/DetermineExtension.php b/src/Plugin/migrate/process/DetermineExtension.php index 3f18a36..7f84a07 100644 --- a/src/Plugin/migrate/process/DetermineExtension.php +++ b/src/Plugin/migrate/process/DetermineExtension.php @@ -2,12 +2,12 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; -use Symfony\Component\Mime\MimeTypes; -use Drupal\migrate\ProcessPluginBase; -use Drupal\migrate\MigrateExecutableInterface; -use Drupal\migrate\Row; use Drupal\migrate\MigrateException; +use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Plugin\MigrationInterface; +use Drupal\migrate\ProcessPluginBase; +use Drupal\migrate\Row; +use Symfony\Component\Mime\MimeTypes; /** * Determine a file extension from a MIME-type. diff --git a/src/Plugin/migrate/process/Method.php b/src/Plugin/migrate/process/Method.php index 3603d93..dd468be 100644 --- a/src/Plugin/migrate/process/Method.php +++ b/src/Plugin/migrate/process/Method.php @@ -2,10 +2,10 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; -use Drupal\migrate\ProcessPluginBase; +use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; -use Drupal\migrate\MigrateException; /** * Call a method on an object. diff --git a/src/Plugin/migrate/process/NaiveFileCopy.php b/src/Plugin/migrate/process/NaiveFileCopy.php index 931b936..1e30eb5 100644 --- a/src/Plugin/migrate/process/NaiveFileCopy.php +++ b/src/Plugin/migrate/process/NaiveFileCopy.php @@ -2,17 +2,17 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; -use Drupal\migrate\Plugin\migrate\process\FileCopy; +use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\File\Exception\FileException; use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface; use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\Plugin\migrate\process\FileCopy; +use Drupal\migrate\Plugin\MigrateProcessInterface; use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\Config\ConfigFactoryInterface; -use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface; -use Drupal\migrate\Plugin\MigrateProcessInterface; /** * Naive file_copy implementation. diff --git a/src/Plugin/migrate/process/Realpath.php b/src/Plugin/migrate/process/Realpath.php index 3c08dbe..125dc40 100644 --- a/src/Plugin/migrate/process/Realpath.php +++ b/src/Plugin/migrate/process/Realpath.php @@ -2,13 +2,13 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; -use Drupal\migrate\ProcessPluginBase; +use Drupal\Core\File\FileSystemInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; -use Drupal\migrate\MigrateException; -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\File\FileSystemInterface; /** * Wrapper for FileSystem::realpath. diff --git a/src/Plugin/migrate/process/StaticMap.php b/src/Plugin/migrate/process/StaticMap.php index 6396699..7360ce1 100644 --- a/src/Plugin/migrate/process/StaticMap.php +++ b/src/Plugin/migrate/process/StaticMap.php @@ -5,8 +5,8 @@ use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateSkipProcessException; use Drupal\migrate\MigrateSkipRowException; -use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\migrate\process\StaticMap as Upstream; +use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Row; /** diff --git a/src/Plugin/migrate/process/SubProcess.php b/src/Plugin/migrate/process/SubProcess.php index 5de6398..2743e72 100644 --- a/src/Plugin/migrate/process/SubProcess.php +++ b/src/Plugin/migrate/process/SubProcess.php @@ -2,9 +2,9 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; -use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateSkipRowException; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; /** diff --git a/src/Plugin/migrate/process/Subindex.php b/src/Plugin/migrate/process/Subindex.php index a270744..aa9de0c 100644 --- a/src/Plugin/migrate/process/Subindex.php +++ b/src/Plugin/migrate/process/Subindex.php @@ -2,10 +2,10 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; -use Drupal\migrate\ProcessPluginBase; +use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; -use Drupal\migrate\MigrateException; /** * Accesses a property from an object. diff --git a/src/Plugin/migrate/process/Subproperty.php b/src/Plugin/migrate/process/Subproperty.php index 3470dba..c804d4c 100644 --- a/src/Plugin/migrate/process/Subproperty.php +++ b/src/Plugin/migrate/process/Subproperty.php @@ -2,10 +2,10 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; -use Drupal\migrate\ProcessPluginBase; +use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; -use Drupal\migrate\MigrateException; /** * Accesses a property from an object. diff --git a/src/Plugin/migrate/process/TypedRelation.php b/src/Plugin/migrate/process/TypedRelation.php index cd87778..678fe08 100644 --- a/src/Plugin/migrate/process/TypedRelation.php +++ b/src/Plugin/migrate/process/TypedRelation.php @@ -2,12 +2,10 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; -use Drupal\migrate\MigrateException; - -use Drupal\Core\Plugin\ContainerFactoryPluginInterface; - use Symfony\Component\DependencyInjection\ContainerInterface; /** diff --git a/src/Plugin/migrate/process/UnpackArray.php b/src/Plugin/migrate/process/UnpackArray.php index 7b1531b..2dc32d4 100644 --- a/src/Plugin/migrate/process/UnpackArray.php +++ b/src/Plugin/migrate/process/UnpackArray.php @@ -2,10 +2,10 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process; -use Drupal\migrate\ProcessPluginBase; +use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; -use Drupal\migrate\MigrateException; /** * Unpack an array. diff --git a/src/Plugin/migrate/process/Xml/AbstractDom.php b/src/Plugin/migrate/process/Xml/AbstractDom.php index 507c1ef..8b885f1 100644 --- a/src/Plugin/migrate/process/Xml/AbstractDom.php +++ b/src/Plugin/migrate/process/Xml/AbstractDom.php @@ -3,10 +3,10 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process\Xml; use Drupal\dgi_migrate\Plugin\migrate\process\MissingBehaviorTrait; -use Drupal\migrate\ProcessPluginBase; +use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; -use Drupal\migrate\MigrateException; /** * Parses X(HT)ML into a DOMDocument instance. diff --git a/src/Plugin/migrate/process/Xml/ContextQuery.php b/src/Plugin/migrate/process/Xml/ContextQuery.php index 8de861b..4d825cf 100644 --- a/src/Plugin/migrate/process/Xml/ContextQuery.php +++ b/src/Plugin/migrate/process/Xml/ContextQuery.php @@ -2,10 +2,10 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process\Xml; -use Drupal\migrate\ProcessPluginBase; +use Drupal\dgi_migrate\Plugin\migrate\process\MissingBehaviorTrait; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; -use Drupal\dgi_migrate\Plugin\migrate\process\MissingBehaviorTrait; /** * Query a DOMXPath using a DOMNode context as the source. diff --git a/src/Plugin/migrate/process/Xml/Xpath.php b/src/Plugin/migrate/process/Xml/Xpath.php index f7252d0..df2e3e3 100644 --- a/src/Plugin/migrate/process/Xml/Xpath.php +++ b/src/Plugin/migrate/process/Xml/Xpath.php @@ -2,10 +2,10 @@ namespace Drupal\dgi_migrate\Plugin\migrate\process\Xml; -use Drupal\migrate\ProcessPluginBase; +use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; -use Drupal\migrate\MigrateException; /** * Instantiate XPath processor. diff --git a/src/Plugin/migrate/source/Migration.php b/src/Plugin/migrate/source/Migration.php index 211e1ea..2872c78 100644 --- a/src/Plugin/migrate/source/Migration.php +++ b/src/Plugin/migrate/source/Migration.php @@ -2,12 +2,12 @@ namespace Drupal\dgi_migrate\Plugin\migrate\source; -use Drupal\migrate\Plugin\migrate\source\SourcePluginBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\dgi_migrate\MigrationIterator; +use Drupal\migrate\Plugin\migrate\source\SourcePluginBase; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\MigrationPluginManagerInterface; -use Drupal\dgi_migrate\MigrationIterator; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Perform a migration based upon the results of another migration. diff --git a/src/Routing/RouteSubscriber.php b/src/Routing/RouteSubscriber.php index 049f812..1677266 100644 --- a/src/Routing/RouteSubscriber.php +++ b/src/Routing/RouteSubscriber.php @@ -3,9 +3,8 @@ namespace Drupal\dgi_migrate\Routing; use Drupal\Core\Routing\RouteSubscriberBase; -use Symfony\Component\Routing\RouteCollection; - use Drupal\dgi_migrate\Form\MigrationExecuteForm; +use Symfony\Component\Routing\RouteCollection; /** * Route subscriber handler. From 2938037f719546462508e9034dc1a7a1e90e961c Mon Sep 17 00:00:00 2001 From: Noel Chiasson Date: Tue, 14 May 2024 15:56:09 -0300 Subject: [PATCH 08/15] Allowing islandora_drush_utils:^2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ae223c3..592a400 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "require": { "discoverygarden/dgi_saxon_helper": "^1", "discoverygarden/foxml": "^1", - "discoverygarden/islandora_drush_utils": "^1", + "discoverygarden/islandora_drush_utils": "^1 || ^2", "discoverygarden/update-helper": "^1", "drupal/imagemagick": "^3.2", "drupal/migrate_directory": "^1 || ^2", From 2855aabb5a2d31292c3c2d70c68b8a748df6cffb Mon Sep 17 00:00:00 2001 From: Chris MacDonald <31731869+chrismacdonaldw@users.noreply.github.com> Date: Thu, 16 May 2024 14:26:19 -0300 Subject: [PATCH 09/15] Create destination plugin w/ revisions --- src/Plugin/migrate/destination/DgiEntity.php | 89 ++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/Plugin/migrate/destination/DgiEntity.php diff --git a/src/Plugin/migrate/destination/DgiEntity.php b/src/Plugin/migrate/destination/DgiEntity.php new file mode 100644 index 0000000..1008c1b --- /dev/null +++ b/src/Plugin/migrate/destination/DgiEntity.php @@ -0,0 +1,89 @@ +migrationId = $migration->id(); + return $instance; + } + + /** + * {@inheritdoc} + */ + public function import(Row $row, array $old_destination_id_values = []) { + $this->rollbackAction = MigrateIdMapInterface::ROLLBACK_DELETE; + $entity = $this->getEntity($row, $old_destination_id_values); + + if (!$entity) { + throw new MigrateException('Unable to get entity'); + } + + assert($entity instanceof ContentEntityInterface); + + if ($this->isEntityValidationRequired($entity)) { + $this->validateEntity($entity); + } + + if (!$entity->isNew()) { + $entity->setNewRevision(); + $entity->setRevisionCreationTime(time()); + + $revision_message = $this->generateRevisionMessage($entity); + $entity->setRevisionLogMessage($revision_message); + } + + $ids = $this->save($entity, $old_destination_id_values); + + if ($this->isTranslationDestination()) { + $ids[] = $entity->language()->getId(); + } + + return $ids; + } + + /** + * Generates a detailed revision message based on the entity and row data. + * + * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * The content entity. + * @param \Drupal\migrate\Row $row + * The row object containing migration data. + * + * @return string + * The generated revision message. + */ + protected function generateRevisionMessage(ContentEntityInterface $entity) { + $entity_id = $entity->id(); + + return sprintf('Migration %s generated new revision for NID %d', $this->migrationId, $entity_id); + } +} From 878d42a8e1c359f9cd24edde8c0c53859950c644 Mon Sep 17 00:00:00 2001 From: Chris MacDonald <31731869+chrismacdonaldw@users.noreply.github.com> Date: Thu, 16 May 2024 14:27:17 -0300 Subject: [PATCH 10/15] Remove old comment. --- src/Plugin/migrate/destination/DgiEntity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/migrate/destination/DgiEntity.php b/src/Plugin/migrate/destination/DgiEntity.php index 1008c1b..8546e25 100644 --- a/src/Plugin/migrate/destination/DgiEntity.php +++ b/src/Plugin/migrate/destination/DgiEntity.php @@ -71,7 +71,7 @@ public function import(Row $row, array $old_destination_id_values = []) { } /** - * Generates a detailed revision message based on the entity and row data. + * Generates a detailed revision message based on the entity. * * @param \Drupal\Core\Entity\ContentEntityInterface $entity * The content entity. From fa7c862da3d60f7bb7ac53b71ac9037a4aeca0aa Mon Sep 17 00:00:00 2001 From: Chris MacDonald <31731869+chrismacdonaldw@users.noreply.github.com> Date: Thu, 16 May 2024 15:08:40 -0300 Subject: [PATCH 11/15] Adjsut for codesniffer. --- src/Plugin/migrate/destination/DgiEntity.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Plugin/migrate/destination/DgiEntity.php b/src/Plugin/migrate/destination/DgiEntity.php index 8546e25..9029f54 100644 --- a/src/Plugin/migrate/destination/DgiEntity.php +++ b/src/Plugin/migrate/destination/DgiEntity.php @@ -11,13 +11,25 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** + * Provides a custom destination plugin for generating entity revisions. + * + * This class extends the EntityContentBase class to provide a custom + * destination plugin for Drupal migrations. It allows for the creation of + * revisions during the migration process, and maintains revision history. + * + * @see \Drupal\migrate\Plugin\migrate\destination\EntityContentBase + * * @MigrateDestination( * id = "dgi_node" * ) */ class DgiEntity extends EntityContentBase { - /** @var string $entityType */ + /** + * The entity type. + * + * @var string + */ public static $entityType = 'node'; /** @@ -75,8 +87,6 @@ public function import(Row $row, array $old_destination_id_values = []) { * * @param \Drupal\Core\Entity\ContentEntityInterface $entity * The content entity. - * @param \Drupal\migrate\Row $row - * The row object containing migration data. * * @return string * The generated revision message. @@ -86,4 +96,5 @@ protected function generateRevisionMessage(ContentEntityInterface $entity) { return sprintf('Migration %s generated new revision for NID %d', $this->migrationId, $entity_id); } + } From 49e023f9470897d464226252838d9ea4c1e36b2e Mon Sep 17 00:00:00 2001 From: Chris MacDonald <31731869+chrismacdonaldw@users.noreply.github.com> Date: Thu, 23 May 2024 13:24:41 -0300 Subject: [PATCH 12/15] Enhance plugin configuration --- ...{DgiEntity.php => DgiRevisionedEntity.php} | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) rename src/Plugin/migrate/destination/{DgiEntity.php => DgiRevisionedEntity.php} (80%) diff --git a/src/Plugin/migrate/destination/DgiEntity.php b/src/Plugin/migrate/destination/DgiRevisionedEntity.php similarity index 80% rename from src/Plugin/migrate/destination/DgiEntity.php rename to src/Plugin/migrate/destination/DgiRevisionedEntity.php index 9029f54..560960b 100644 --- a/src/Plugin/migrate/destination/DgiEntity.php +++ b/src/Plugin/migrate/destination/DgiRevisionedEntity.php @@ -20,17 +20,17 @@ * @see \Drupal\migrate\Plugin\migrate\destination\EntityContentBase * * @MigrateDestination( - * id = "dgi_node" + * id = "dgi_revisioned_entity" * ) */ -class DgiEntity extends EntityContentBase { +class DgiRevisionedEntity extends EntityContentBase { /** * The entity type. * * @var string */ - public static $entityType = 'node'; + public static string $entityType; /** * The migration ID. @@ -43,6 +43,7 @@ class DgiEntity extends EntityContentBase { * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { + static::$entityType = $configuration['entity_type'] ?? 'node'; $instance = parent::create($container, $configuration, 'entity:' . static::$entityType, $plugin_definition, $migration); $instance->migrationId = $migration->id(); return $instance; @@ -69,7 +70,7 @@ public function import(Row $row, array $old_destination_id_values = []) { $entity->setNewRevision(); $entity->setRevisionCreationTime(time()); - $revision_message = $this->generateRevisionMessage($entity); + $revision_message = $this->generateRevisionMessage(); $entity->setRevisionLogMessage($revision_message); } @@ -83,18 +84,13 @@ public function import(Row $row, array $old_destination_id_values = []) { } /** - * Generates a detailed revision message based on the entity. - * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity - * The content entity. + * Generates a detailed revision message. * * @return string * The generated revision message. */ - protected function generateRevisionMessage(ContentEntityInterface $entity) { - $entity_id = $entity->id(); - - return sprintf('Migration %s generated new revision for NID %d', $this->migrationId, $entity_id); + protected function generateRevisionMessage() { + return sprintf('New revision generated by migration `%s`.', $this->migrationId); } } From dcd63efd41a1cdb40d347f0abb1491abc200cc6a Mon Sep 17 00:00:00 2001 From: Chris MacDonald <31731869+chrismacdonaldw@users.noreply.github.com> Date: Tue, 28 May 2024 16:26:00 -0300 Subject: [PATCH 13/15] Update src/Plugin/migrate/destination/DgiRevisionedEntity.php Co-authored-by: Adam <607975+adam-vessey@users.noreply.github.com> --- src/Plugin/migrate/destination/DgiRevisionedEntity.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Plugin/migrate/destination/DgiRevisionedEntity.php b/src/Plugin/migrate/destination/DgiRevisionedEntity.php index 560960b..400b889 100644 --- a/src/Plugin/migrate/destination/DgiRevisionedEntity.php +++ b/src/Plugin/migrate/destination/DgiRevisionedEntity.php @@ -43,8 +43,9 @@ class DgiRevisionedEntity extends EntityContentBase { * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { - static::$entityType = $configuration['entity_type'] ?? 'node'; - $instance = parent::create($container, $configuration, 'entity:' . static::$entityType, $plugin_definition, $migration); + $entity_type = $configuration['entity_type'] ?? 'node'; + $instance = parent::create($container, $configuration, 'entity:' . $entity_type, $plugin_definition, $migration); + $instance->entityType = $entity_type; $instance->migrationId = $migration->id(); return $instance; } From 312b3878bde1aae8d538784a1d8f1f2c5aaba1b0 Mon Sep 17 00:00:00 2001 From: Chris MacDonald <31731869+chrismacdonaldw@users.noreply.github.com> Date: Tue, 28 May 2024 16:26:11 -0300 Subject: [PATCH 14/15] Update src/Plugin/migrate/destination/DgiRevisionedEntity.php Co-authored-by: Adam <607975+adam-vessey@users.noreply.github.com> --- src/Plugin/migrate/destination/DgiRevisionedEntity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/migrate/destination/DgiRevisionedEntity.php b/src/Plugin/migrate/destination/DgiRevisionedEntity.php index 400b889..6a35a8b 100644 --- a/src/Plugin/migrate/destination/DgiRevisionedEntity.php +++ b/src/Plugin/migrate/destination/DgiRevisionedEntity.php @@ -30,7 +30,7 @@ class DgiRevisionedEntity extends EntityContentBase { * * @var string */ - public static string $entityType; + public string $entityType; /** * The migration ID. From 62ca0090a4fdcecff97f355f5663bdc2e8a4ca5f Mon Sep 17 00:00:00 2001 From: Noel Chiasson Date: Tue, 11 Jun 2024 11:24:42 -0300 Subject: [PATCH 15/15] Fixing coder complaint about use ordering --- src/Drush/Commands/MigrateCommands.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Drush/Commands/MigrateCommands.php b/src/Drush/Commands/MigrateCommands.php index 3a2b4ae..64cf9c7 100644 --- a/src/Drush/Commands/MigrateCommands.php +++ b/src/Drush/Commands/MigrateCommands.php @@ -5,8 +5,8 @@ use Consolidation\OutputFormatters\StructuredData\RowsOfFields; use Drupal\Component\Graph\Graph; use Drupal\Core\StringTranslation\StringTranslationTrait; -use Drupal\dgi_migrate\StompQueue; use Drupal\dgi_migrate\MigrateBatchExecutable; +use Drupal\dgi_migrate\StompQueue; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate_tools\Drush\Commands\MigrateToolsCommands; use Drupal\migrate_tools\Drush9LogMigrateMessage;