Skip to content

Commit

Permalink
Merge branch 'main' into DDST-905
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismacdonaldw authored Dec 17, 2024
2 parents 729c0d9 + 877038f commit c6a59ca
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2714,10 +2714,13 @@ process:
- '@_unspecified_rights_statement'
- plugin: null_coalesce
nid:
- plugin: dgi_migrate.process.locking_migration_lookup
- plugin: get
source: '@field_pid'
- &locking_lookup
plugin: dgi_migrate.process.locking_migration_lookup
migration: dgis_stub_nodes
lock_context_keys: &dgis_stub_nodes_lock_context_keys
stub_id: dgis_stub_nodes
lock_context_keys:
dgis_stub_nodes:
- { offset: [ 0 ], hash: '#/##' }
field_member_of:
Expand All @@ -2726,11 +2729,7 @@ process:
- '@_members'
- '@_constituents'
- plugin: multiple_values
- plugin: dgi_migrate.process.locking_migration_lookup
migration: dgis_stub_nodes
stub_id: dgis_stub_nodes
lock_context_keys:
<< : *dgis_stub_nodes_lock_context_keys
- << : *locking_lookup
migration_dependencies:
required:
- dgis_foxml_files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ process:
field_media_image/target_id: '@_file_id'
field_media_image/alt: '@name'
field_media_video_file: '@_file'
field_media_document: '@_file'
bundle:
- plugin: static_map
source: '@_models'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
services:
logger.channel.dgi_migrate_regenerate_pathauto_aliases:
parent: logger.channel_base
arguments: ['dgi_migrate_regenerate_pathauto_aliases']
dgi_migrate_regenerate_pathauto_aliases:
class: \Drupal\dgi_migrate_regenerate_pathauto_aliases\Commands\Pathauto
arguments:
- '@pathauto.generator'
- '@entity_type.manager'
- '@entity_type.bundle.info'
- '@logger.channel.dgi_migrate_regenerate_pathauto_aliases'
tags:
- name: drush.command
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Drupal\pathauto\PathautoGeneratorInterface;
use Drupal\pathauto\PathautoState;
use Drush\Commands\DrushCommands;
use Psr\Log\LoggerInterface;

/**
* Re-generates missing pathauto aliases.
Expand Down Expand Up @@ -49,14 +48,11 @@ class Pathauto extends DrushCommands {
* The entity type manager service.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* The entity type bundle info service.
* @param \Psr\Log\LoggerInterface $logger
* A logger to which to log.
*/
public function __construct(PathautoGeneratorInterface $pathauto_generator, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, LoggerInterface $logger) {
public function __construct(PathautoGeneratorInterface $pathauto_generator, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info) {
$this->pathautoGenerator = $pathauto_generator;
$this->entityTypeManager = $entity_type_manager;
$this->entityTypeBundleInfo = $entity_type_bundle_info;
$this->logger = $logger;
}

/**
Expand Down
32 changes: 16 additions & 16 deletions src/Plugin/migrate/source/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class Migration extends SourcePluginBase implements ContainerFactoryPluginInterf
*
* @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface
*/
protected $migrationPluginManager;
protected MigrationPluginManagerInterface $migrationPluginManager;

/**
* The target migration.
* Memoized target migration.
*
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $targetMigration;
protected MigrationInterface $targetMigration;

/**
* Constructor.
Expand All @@ -39,7 +39,6 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);

$this->migrationPluginManager = $migration_plugin_manager;
$this->targetMigration = $this->migrationPluginManager->createInstance($this->configuration['migration']);
}

/**
Expand All @@ -55,18 +54,28 @@ public static function create(ContainerInterface $container, array $configuratio
);
}

/**
* Load and identify the target migration.
*
* @return \Drupal\migrate\Plugin\MigrationInterface
* The target migration.
*/
protected function getTargetMigration() : MigrationInterface {
return $this->targetMigration ??= $this->migrationPluginManager->createInstance($this->configuration['migration']);
}

/**
* {@inheritdoc}
*/
public function initializeIterator() {
return new MigrationIterator($this->targetMigration->getIdMap(), 'currentDestination');
return new MigrationIterator($this->getTargetMigration()->getIdMap(), 'currentDestination');
}

/**
* {@inheritdoc}
*/
public function getIds() {
return (array) $this->targetMigration->getDestinationPlugin()->getIds();
return (array) $this->getTargetMigration()->getDestinationPlugin()->getIds();
}

/**
Expand All @@ -81,7 +90,7 @@ public function fields() {
*/
public function __toString() {
return strtr('target migration: @migration', [
'@migration' => $this->targetMigration->id(),
'@migration' => $this->getTargetMigration()->id(),
]);
}

Expand All @@ -106,13 +115,4 @@ public function __sleep() {
return $vars;
}

/**
* {@inheritdoc}
*/
public function __wakeup() {
parent::__wakeup();

$this->targetMigration = $this->migrationPluginManager->createInstance($this->configuration['migration']);
}

}

0 comments on commit c6a59ca

Please sign in to comment.