Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D10-27: D10 compat, from practice #118

Merged
merged 6 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/MigrateBatchExecutable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
20 changes: 13 additions & 7 deletions src/Plugin/migrate/id_map/SmartSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -42,13 +41,20 @@ class SmartSql extends Sql {
*/
protected bool $manageOrphans;

/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected EntityTypeManagerInterface $entityTypeManager;

/**
* {@inheritdoc}
*
* @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()));
Expand Down
7 changes: 7 additions & 0 deletions src/Plugin/migrate/process/DcName.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
*/
class DcName extends ProcessPluginBase {

/**
* Associative array containing the mapping.
*
* @var array
*/
protected array $map;

/**
* {@inheritdoc}
*/
Expand Down
21 changes: 21 additions & 0 deletions src/Plugin/migrate/process/SubProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
21 changes: 21 additions & 0 deletions src/Plugin/migrate/process/Xml/ContextQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
*/
Expand Down