You are here

public function MigrateExecutable::__construct in Migrate Tools 8.5

Same name and namespace in other branches
  1. 8 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

1 call to MigrateExecutable::__construct()
MigrateBatchExecutable::__construct in src/MigrateBatchExecutable.php
Constructs a MigrateExecutable and verifies and sets the memory limit.
1 method overrides MigrateExecutable::__construct()
MigrateBatchExecutable::__construct in src/MigrateBatchExecutable.php
Constructs a MigrateExecutable and verifies and sets the memory limit.

File

src/MigrateExecutable.php, line 98

Class

MigrateExecutable
Defines a migrate executable class for drush.

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['sync'])) {
    $this->migration
      ->set('syncSource', $options['sync']);
  }
  $this->idlist = MigrateTools::buildIdList($options);
  $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) {
    $this
      ->getEventDispatcher()
      ->addListener($event, $listener);
  }
}