From 365d83df52a35faf16a8c6b403a2f008049d018f Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Tue, 10 Oct 2023 10:29:48 -0300 Subject: [PATCH 1/6] Widen `symfony/mime` spec. Required for D10 compatibility. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e64adcd0..7ccbf6b6 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "islandora/controlled_access_terms": "^2", "islandora/islandora": "^2", "iqb/substream": "dev-master", - "symfony/mime": "^5" + "symfony/mime": "^5 || ^6" }, "require-dev": { "drupal/devel": "^4" From 407c8862de4537b91d7a180aba0e5384cd42458c Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Tue, 10 Oct 2023 13:55:59 -0300 Subject: [PATCH 2/6] Fix up event dispatch to the new order. --- src/MigrateBatchExecutable.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/MigrateBatchExecutable.php b/src/MigrateBatchExecutable.php index df994ba0..60fd0e35 100644 --- a/src/MigrateBatchExecutable.php +++ b/src/MigrateBatchExecutable.php @@ -167,7 +167,7 @@ public function finishBatch($success, $results, $ops, $interval) { */ public function teardownMigration() { $this->getQueue()->deleteQueue(); - $this->getEventDispatcher()->dispatch(MigrateEvents::POST_IMPORT, new MigrateImportEvent($this->migration, $this->message)); + $this->getEventDispatcher()->dispatch(new MigrateImportEvent($this->migration, $this->message), MigrateEvents::POST_IMPORT); $this->migration->setStatus(MigrationInterface::STATUS_IDLE); } @@ -191,7 +191,7 @@ protected function enqueue() { ]), 'error'); return MigrationInterface::RESULT_FAILED; } - $this->getEventDispatcher()->dispatch(MigrateEvents::PRE_IMPORT, new MigrateImportEvent($this->migration, $this->message)); + $this->getEventDispatcher()->dispatch(new MigrateImportEvent($this->migration, $this->message), MigrateEvents::PRE_IMPORT); // Knock off migration if the requirements haven't been met. try { @@ -276,11 +276,11 @@ protected function processRowFromQueue(Row $row) { if ($save) { try { $destination = $this->migration->getDestinationPlugin(); - $this->getEventDispatcher()->dispatch(MigrateEvents::PRE_ROW_SAVE, new MigratePreRowSaveEvent($this->migration, $this->message, $row)); + $this->getEventDispatcher()->dispatch(new MigratePreRowSaveEvent($this->migration, $this->message, $row), MigrateEvents::PRE_ROW_SAVE); $destination_ids = $id_map->lookupDestinationIds($this->sourceIdValues); $destination_id_values = $destination_ids ? reset($destination_ids) : []; $destination_id_values = $destination->import($row, $destination_id_values); - $this->getEventDispatcher()->dispatch(MigrateEvents::POST_ROW_SAVE, new MigratePostRowSaveEvent($this->migration, $this->message, $row, $destination_id_values)); + $this->getEventDispatcher()->dispatch(new MigratePostRowSaveEvent($this->migration, $this->message, $row, $destination_id_values), MigrateEvents::POST_ROW_SAVE); if ($destination_id_values) { // We do not save an idMap entry for config. if ($destination_id_values !== TRUE) { From a0c79b2a6b4c515d9cb3fef79a014e0b93ce0819 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Wed, 18 Oct 2023 13:54:29 -0300 Subject: [PATCH 3/6] Define property. --- src/Plugin/migrate/id_map/SmartSql.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Plugin/migrate/id_map/SmartSql.php b/src/Plugin/migrate/id_map/SmartSql.php index 2d626147..aaf31fd2 100644 --- a/src/Plugin/migrate/id_map/SmartSql.php +++ b/src/Plugin/migrate/id_map/SmartSql.php @@ -42,6 +42,13 @@ class SmartSql extends Sql { */ protected bool $manageOrphans; + /** + * The entity type manager service. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected EntityTypeManagerInterface $entityTypeManager; + /** * {@inheritdoc} * From f147a1b583778b3e27484c989589c3ba8eb11760 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Thu, 19 Oct 2023 10:41:39 -0300 Subject: [PATCH 4/6] Squash some dynamically defined properties. --- .../process/DgiStandardTitleParagraph.php | 11 ++++++++-- src/Plugin/migrate/process/DcName.php | 7 +++++++ .../migrate/process/Xml/ContextQuery.php | 21 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) 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 354231c3..466d5469 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 @@ -33,11 +33,18 @@ class DgiStandardTitleParagraph extends ProcessPluginBase { /** - * Whether or not entities generated should be validated. + * Whether entities generated should be validated. * * @var bool */ - protected $validate = FALSE; + protected bool $validate = FALSE; + + /** + * The length to which to truncate the title. + * + * @var false|int + */ + private mixed $maxLength; /** * Constructor. diff --git a/src/Plugin/migrate/process/DcName.php b/src/Plugin/migrate/process/DcName.php index e0ffed2b..6da7e767 100644 --- a/src/Plugin/migrate/process/DcName.php +++ b/src/Plugin/migrate/process/DcName.php @@ -15,6 +15,13 @@ */ class DcName extends ProcessPluginBase { + /** + * Associative array containing the mapping. + * + * @var array + */ + protected array $map; + /** * {@inheritdoc} */ diff --git a/src/Plugin/migrate/process/Xml/ContextQuery.php b/src/Plugin/migrate/process/Xml/ContextQuery.php index af6d9d35..8de861ba 100644 --- a/src/Plugin/migrate/process/Xml/ContextQuery.php +++ b/src/Plugin/migrate/process/Xml/ContextQuery.php @@ -26,6 +26,27 @@ class ContextQuery extends ProcessPluginBase { use MissingBehaviorTrait; + /** + * The instance on which to run the query. + * + * @var \DOMXPath + */ + protected mixed $xpath; + + /** + * The query to execute. + * + * @var string + */ + protected string $query; + + /** + * The name of the method to use. + * + * @var string + */ + protected string $method; + /** * {@inheritdoc} */ From a17eaf288c54b5b7f6e299346ec76187c6de23f9 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Thu, 19 Oct 2023 13:50:40 -0300 Subject: [PATCH 5/6] Fix up some more properties. --- src/Plugin/migrate/process/SubProcess.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Plugin/migrate/process/SubProcess.php b/src/Plugin/migrate/process/SubProcess.php index a48fbf1e..5de6398b 100644 --- a/src/Plugin/migrate/process/SubProcess.php +++ b/src/Plugin/migrate/process/SubProcess.php @@ -101,6 +101,27 @@ class SubProcess extends ProcessPluginBase { */ protected $parentValueKey; + /** + * Flag indicating if we should handle multiple. + * + * @var bool + */ + protected bool $handleMultiple; + + /** + * The parent index. + * + * @var string + */ + protected string $parentIndex; + + /** + * The key as which to save the value in the return array. + * + * @var string + */ + protected string $outputKey; + /** * Constructor. */ From 0b9c70f9237b926fce09959e126cccb9ea1ac008 Mon Sep 17 00:00:00 2001 From: Adam Vessey Date: Tue, 24 Oct 2023 13:42:49 -0300 Subject: [PATCH 6/6] Add the new parameter. As per https://www.drupal.org/node/3277306 Was reported during testing of `dgi_group`. --- src/Plugin/migrate/id_map/SmartSql.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Plugin/migrate/id_map/SmartSql.php b/src/Plugin/migrate/id_map/SmartSql.php index aaf31fd2..5f24241c 100644 --- a/src/Plugin/migrate/id_map/SmartSql.php +++ b/src/Plugin/migrate/id_map/SmartSql.php @@ -2,16 +2,15 @@ namespace Drupal\dgi_migrate\Plugin\migrate\id_map; +use Drupal\Component\Plugin\PluginBase; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\migrate\EntityFieldDefinitionTrait; use Drupal\migrate\MigrateException; use Drupal\migrate\Plugin\migrate\destination\Entity; use Drupal\migrate\Plugin\migrate\id_map\Sql; -use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\MigrateIdMapInterface; - -use Drupal\Component\Plugin\PluginBase; -use Drupal\Core\Entity\EntityTypeManagerInterface; - +use Drupal\migrate\Plugin\MigrationInterface; +use Drupal\migrate\Plugin\MigrationPluginManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -54,8 +53,8 @@ class SmartSql extends Sql { * * @see https://drupal.org/i/2845340 */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $event_dispatcher); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher, MigrationPluginManagerInterface $migration_plugin_manager) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $event_dispatcher, $migration_plugin_manager); // Default generated table names, limited to 63 characters. $machine_name = mb_strtolower(str_replace(PluginBase::DERIVATIVE_SEPARATOR, '__', $this->migration->id()));