You are here

public function MigrateExecutable::__construct in Migrate Tools 8

Same name and namespace in other branches
  1. 8.5 src/MigrateExecutable.php \Drupal\migrate_tools\MigrateExecutable::__construct()
  2. 8.2 src/MigrateExecutable.php \Drupal\migrate_tools\MigrateExecutable::__construct()
  3. 8.3 src/MigrateExecutable.php \Drupal\migrate_tools\MigrateExecutable::__construct()
  4. 8.4 src/MigrateExecutable.php \Drupal\migrate_tools\MigrateExecutable::__construct()

Constructs a MigrateExecutable and verifies and sets the memory limit.

Parameters

\Drupal\migrate\Plugin\MigrationInterface $migration: The migration to run.

\Drupal\migrate\MigrateMessageInterface $message: (optional) The migrate message service.

\Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher: (optional) The event dispatcher.

Throws

\Drupal\migrate\MigrateException

Overrides MigrateExecutable::__construct

File

src/MigrateExecutable.php, line 87
Contains \Drupal\migrate_tools\MigrateExecutable.

Class

MigrateExecutable

Namespace

Drupal\migrate_tools

Code

public function __construct(MigrationInterface $migration, MigrateMessageInterface $message, array $options = []) {
  parent::__construct($migration, $message);
  if (isset($options['limit'])) {
    $this->itemLimit = $options['limit'];
  }
  if (isset($options['feedback'])) {
    $this->feedback = $options['feedback'];
  }
  if (isset($options['idlist'])) {
    $this->idlist = explode(',', $options['idlist']);
  }
  $this->listeners[MigrateEvents::MAP_SAVE] = [
    $this,
    'onMapSave',
  ];
  $this->listeners[MigrateEvents::MAP_DELETE] = [
    $this,
    'onMapDelete',
  ];
  $this->listeners[MigrateEvents::POST_IMPORT] = [
    $this,
    'onPostImport',
  ];
  $this->listeners[MigrateEvents::POST_ROLLBACK] = [
    $this,
    'onPostRollback',
  ];
  $this->listeners[MigrateEvents::PRE_ROW_SAVE] = [
    $this,
    'onPreRowSave',
  ];
  $this->listeners[MigrateEvents::POST_ROW_DELETE] = [
    $this,
    'onPostRowDelete',
  ];
  $this->listeners[MigratePlusEvents::PREPARE_ROW] = [
    $this,
    'onPrepareRow',
  ];
  foreach ($this->listeners as $event => $listener) {
    \Drupal::service('event_dispatcher')
      ->addListener($event, $listener);
  }
}