Adds event subscriber for post migration operations.

This commit is contained in:
2022-02-15 18:44:20 +00:00
parent 45b8ce5631
commit c6f921dd53
2 changed files with 45 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
services:
post_migration_subscriber:
class: '\Drupal\cdesai_migrate\EventSubscriber\DemoPostMigrationSubscriber'
tags:
- { name: 'event_subscriber' }
@@ -0,0 +1,40 @@
<?php
namespace Drupal\cdesai_migrate\EventSubscriber;
use Drupal\migrate\Event\MigrateEvents;
use Drupal\migrate\Event\MigratePostRowSaveEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Class PostMigrationSubscriber.
*
* Run our user flagging after the last node migration is run.
*
* @package Drupal\YOUR_MODULE
*/
class DemoPostMigrationSubscriber implements EventSubscriberInterface {
/**
* Get subscribed events.
*
* @inheritdoc
*/
public static function getSubscribedEvents(): array {
$events[MigrateEvents::POST_ROW_SAVE][] = ['onMigratePostImport'];
return $events;
}
/**
* Callback for MigrateEvents::POST_ROW_SAVE event.
*
* @param \Drupal\migrate\Event\MigratePostRowSaveEvent $event
* The import event object.
*/
public function onMigratePostImport(MigratePostRowSaveEvent $event) {
if ($event->getMigration()->getBaseId() == 'cdesai_basic_pages') {
// CODE REDACTED
}
}
}