MigrationEventSubscriber.php in Migrate Devel 8.2
File
src/EventSubscriber/MigrationEventSubscriber.php
View source
<?php
namespace Drupal\migrate_devel\EventSubscriber;
use Drupal\migrate\Event\MigrateEvents;
use Drupal\migrate\Event\MigratePostRowSaveEvent;
use Drupal\migrate\Event\MigratePreRowSaveEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class MigrationEventSubscriber implements EventSubscriberInterface {
public function debugRowPreSave(MigratePreRowSaveEvent $event) {
if (PHP_SAPI !== 'cli') {
return;
}
$row = $event
->getRow();
if (in_array('migrate-debug-pre', \Drush\Drush::config()
->get('runtime.options'))) {
$Source = $row
->getSource();
$Destination = $row
->getDestination();
dump('---------------------------------------------------------------------', '| $Source |', '---------------------------------------------------------------------', $Source, '---------------------------------------------------------------------', '| $Destination |', '---------------------------------------------------------------------', $Destination);
}
}
public function debugRowPostSave(MigratePostRowSaveEvent $event) {
if (PHP_SAPI !== 'cli') {
return;
}
$row = $event
->getRow();
if (in_array('migrate-debug', \Drush\Drush::config()
->get('runtime.options'))) {
$Source = $row
->getSource();
$Destination = $row
->getDestination();
$DestinationIDValues = $event
->getDestinationIdValues();
dump('---------------------------------------------------------------------', '| $Source |', '---------------------------------------------------------------------', $Source, '---------------------------------------------------------------------', '| $Destination |', '---------------------------------------------------------------------', $Destination, '---------------------------------------------------------------------', '| $DestinationIdValues |', '---------------------------------------------------------------------', $DestinationIDValues);
}
}
public static function getSubscribedEvents() {
$events[MigrateEvents::PRE_ROW_SAVE][] = [
'debugRowPreSave',
];
$events[MigrateEvents::POST_ROW_SAVE][] = [
'debugRowPostSave',
];
return $events;
}
}