You are here

class MigrationEventSubscriber in Migrate Devel 8

Same name and namespace in other branches
  1. 8.2 src/EventSubscriber/MigrationEventSubscriber.php \Drupal\migrate_devel\EventSubscriber\MigrationEventSubscriber

MigrationEventSubscriber for Debugging Migrations.

@class MigrationEventSubscriber

Hierarchy

  • class \Drupal\migrate_devel\EventSubscriber\MigrationEventSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of MigrationEventSubscriber

1 string reference to 'MigrationEventSubscriber'
migrate_devel.services.yml in ./migrate_devel.services.yml
migrate_devel.services.yml
1 service uses MigrationEventSubscriber
migrate_devel.migrate_event_subscriber in ./migrate_devel.services.yml
Drupal\migrate_devel\EventSubscriber\MigrationEventSubscriber

File

src/EventSubscriber/MigrationEventSubscriber.php, line 15

Namespace

Drupal\migrate_devel\EventSubscriber
View source
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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MigrationEventSubscriber::debugRowPostSave public function Post Row Save Function for --migrate-debug.
MigrationEventSubscriber::debugRowPreSave public function Pre Row Save Function for --migrate-debug-pre.
MigrationEventSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.