Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?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;
/**
* MigrationEventSubscriber for Debugging Migrations.
*
* @class MigrationEventSubscriber
*/
class MigrationEventSubscriber implements EventSubscriberInterface {
/**
* Pre Row Save Function for --migrate-debug-pre.
*
* @param \Drupal\migrate\Event\MigratePreRowSaveEvent $event
* Pre-Row-Save Migrate Event.
*/
public function debugRowPreSave(MigratePreRowSaveEvent $event) {
$row = $event->getRow();
$using_drush = function_exists('drush_get_option');
if ($using_drush && drush_get_option('migrate-debug-pre')) {
// Start with capital letter for variables since this is actually a label.
$Source = $row->getSource();
$Destination = $row->getDestination();
// We use kint directly here since we want to support variable naming.
kint_require();
\Kint::dump($Source, $Destination);
}
}
/**
* Post Row Save Function for --migrate-debug.
*
* @param \Drupal\migrate\Event\MigratePostRowSaveEvent $event
* Post-Row-Save Migrate Event.
*/
public function debugRowPostSave(MigratePostRowSaveEvent $event) {
$row = $event->getRow();
$using_drush = function_exists('drush_get_option');
if ($using_drush && drush_get_option('migrate-debug')) {
// Start with capital letter for variables since this is actually a label.
$Source = $row->getSource();
$Destination = $row->getDestination();
$DestinationIDValues = $event->getDestinationIdValues();
// We use kint directly here since we want to support variable naming.
kint_require();
\Kint::dump($Source, $Destination, $DestinationIDValues);
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[MigrateEvents::PRE_ROW_SAVE][] = ['debugRowPreSave'];
$events[MigrateEvents::POST_ROW_SAVE][] = ['debugRowPostSave'];
return $events;
}
}