Adds event subscriber for post migration operations.
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user