Commit 2f3c0a26 authored by Derimagia's avatar Derimagia

More code review

parent 14b8ac54
# Migrate Devel
Adds new options to `drush migrate-import` which allows developers to debug their migrations.
Adds new options to `drush migrate-import` which
allows developers to debug their migrations.
`drush migrate-import` comes from either the
[migrate_tools](https://www.drupal.org/project/migrate_tools) or the
[migrate_run](https://www.drupal.org/project/migrate_run) modules.
Currently uses Kint (from devel) directly to print out debug information
instead of devel in order to take advantage of cli coloring and named variable debugging.
instead of devel in order to take advantage of
cli coloring and named variable debugging.
Options are:
* `--migrate-debug` - Prints out rows as they run.
* `--migrate-debug-pre` - Same as above, but before the migration is run on the row.
* `--migrate-debug-pre` - Same as above before the process is run on the row.
<?php
/**
* MigrationEventSubscriber for Debugging Migrations.
*
* @category Class
* @package migrate_devel
*/
namespace Drupal\migrate_devel\EventSubscriber;
use Drupal\migrate\Event\MigrateEvents;
......@@ -11,6 +16,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
* MigrationEventSubscriber for Debugging Migrations.
*/
class MigrationEventSubscriber implements EventSubscriberInterface {
/**
* Pre Row Save Function for --migrate-debug-pre.
*
......@@ -19,13 +25,14 @@ class MigrationEventSubscriber implements EventSubscriberInterface {
public function debugRowPreSave(MigratePreRowSaveEvent $event) {
$row = $event->getRow();
if (function_exists('drush_get_option') && drush_get_option('migrate-debug-pre')) {
$using_drush = function_exists('drush_get_option');
if ($using_drush && drush_get_option('migrate-debug-pre')) {
// Starting 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 and CLI colors.
kint_require();
// Starting with capital letter for variables since this is actually a label.
\Kint::dump($Source, $Destination);
}
}
......@@ -38,14 +45,14 @@ class MigrationEventSubscriber implements EventSubscriberInterface {
public function debugRowPostSave(MigratePostRowSaveEvent $event) {
$row = $event->getRow();
if (function_exists('drush_get_option') && drush_get_option('migrate-debug')) {
$using_drush = function_exists('drush_get_option');
if ($using_drush && drush_get_option('migrate-debug')) {
// We use kint directly here since we want to support variable naming and CLI colors.
$Source = $row->getSource();
$Destination = $row->getDestination();
$DestinationIDValues = $event->getDestinationIdValues();
// We use kint directly here since we want to support variable naming and CLI colors.
kint_require();
// Starting with capital letter for variables since this is actually a label.
\Kint::dump($Source, $Destination, $DestinationIDValues);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment