class MigrateHelper in Panopoly 8.2
Service with some helper functions for working with migrate.
Hierarchy
- class \Drupal\panopoly_core\MigrateHelper
Expanded class hierarchy of MigrateHelper
1 file declares its use of MigrateHelper
- MigrateHelperTest.php in modules/
panopoly/ panopoly_core/ tests/ src/ Unit/ MigrateHelperTest.php
1 string reference to 'MigrateHelper'
- panopoly_core.services.yml in modules/
panopoly/ panopoly_core/ panopoly_core.services.yml - modules/panopoly/panopoly_core/panopoly_core.services.yml
1 service uses MigrateHelper
- panopoly_core.migrate_helper in modules/
panopoly/ panopoly_core/ panopoly_core.services.yml - Drupal\panopoly_core\MigrateHelper
File
- modules/
panopoly/ panopoly_core/ src/ MigrateHelper.php, line 13
Namespace
Drupal\panopoly_coreView source
class MigrateHelper {
/**
* The migration plugin manager.
*
* @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface
*/
protected $migrationManager;
/**
* The migrate message object.
*
* @var \Drupal\migrate\MigrateMessageInterface
*/
protected $migrateMessage;
/**
* Constructs the migration helper server.
*
* @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_manager
* The migration manager.
*/
public function __construct(MigrationPluginManagerInterface $migration_manager) {
$this->migrationManager = $migration_manager;
}
/**
* Gets the migrate message object.
*
* @return \Drupal\migrate\MigrateMessageInterface
* The migrate message object.
*/
protected function getMessageObject() {
if (!$this->migrateMessage) {
$this->migrateMessage = new MigrateMessage();
}
return $this->migrateMessage;
}
/**
* Create a new migrate executable.
*
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* The migration.
*
* @return \Drupal\migrate\MigrateExecutableInterface
* The migrate executable.
*/
protected function createExecutable(MigrationInterface $migration) {
return new MigrateExecutable($migration, $this
->getMessageObject());
}
/**
* Imports the given migrations in order.
*
* @param string[] $migration_ids
* List of migration ids to import.
*/
public function import(array $migration_ids) {
$migrations = $this->migrationManager
->createInstances($migration_ids);
foreach ($migrations as $migration) {
$executable = $this
->createExecutable($migration);
$executable
->import();
}
}
/**
* Rolls back the given migrations in reverse order.
*
* @param array $migration_ids
* List of migration ids to rollback.
*/
public function rollback(array $migration_ids) {
// Do the migrations in reverse (half-ass dependency checking).
$migration_ids = array_reverse($migration_ids);
$migrations = $this->migrationManager
->createInstances($migration_ids);
foreach ($migrations as $migration) {
$executable = $this
->createExecutable($migration);
$executable
->rollback();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MigrateHelper:: |
protected | property | The migrate message object. | |
MigrateHelper:: |
protected | property | The migration plugin manager. | |
MigrateHelper:: |
protected | function | Create a new migrate executable. | |
MigrateHelper:: |
protected | function | Gets the migrate message object. | |
MigrateHelper:: |
public | function | Imports the given migrations in order. | |
MigrateHelper:: |
public | function | Rolls back the given migrations in reverse order. | |
MigrateHelper:: |
public | function | Constructs the migration helper server. |