MigrateHelper.php in Panopoly 8.2
File
modules/panopoly/panopoly_core/src/MigrateHelper.php
View source
<?php
namespace Drupal\panopoly_core;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
class MigrateHelper {
protected $migrationManager;
protected $migrateMessage;
public function __construct(MigrationPluginManagerInterface $migration_manager) {
$this->migrationManager = $migration_manager;
}
protected function getMessageObject() {
if (!$this->migrateMessage) {
$this->migrateMessage = new MigrateMessage();
}
return $this->migrateMessage;
}
protected function createExecutable(MigrationInterface $migration) {
return new MigrateExecutable($migration, $this
->getMessageObject());
}
public function import(array $migration_ids) {
$migrations = $this->migrationManager
->createInstances($migration_ids);
foreach ($migrations as $migration) {
$executable = $this
->createExecutable($migration);
$executable
->import();
}
}
public function rollback(array $migration_ids) {
$migration_ids = array_reverse($migration_ids);
$migrations = $this->migrationManager
->createInstances($migration_ids);
foreach ($migrations as $migration) {
$executable = $this
->createExecutable($migration);
$executable
->rollback();
}
}
}
Classes
Name |
Description |
MigrateHelper |
Service with some helper functions for working with migrate. |