Commit 2257e634 authored by xjm's avatar xjm

Issue #2859246 by Jo Fitzgerald, phenaproxima, alexpott, xjm: Allow...

Issue #2859246 by Jo Fitzgerald, phenaproxima, alexpott, xjm: Allow MigrateExecutable to be constructed without a message object
parent d79a838e
......@@ -4,7 +4,6 @@
use Drupal\file\Plugin\migrate\process\d6\FileUri;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Row;
use Drupal\Tests\migrate\Unit\MigrateTestCase;
......@@ -69,7 +68,7 @@ public function testTemporary() {
}
protected function doTransform(array $value) {
$executable = new MigrateExecutable($this->getMigration(), new MigrateMessage());
$executable = new MigrateExecutable($this->getMigration());
$row = new Row();
return (new FileUri([], 'file_uri', []))
......
......@@ -96,16 +96,16 @@ class MigrateExecutable implements MigrateExecutableInterface {
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* The migration to run.
* @param \Drupal\migrate\MigrateMessageInterface $message
* The migrate message service.
* (optional) The migrate message service.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher.
* (optional) The event dispatcher.
*
* @throws \Drupal\migrate\MigrateException
*/
public function __construct(MigrationInterface $migration, MigrateMessageInterface $message, EventDispatcherInterface $event_dispatcher = NULL) {
public function __construct(MigrationInterface $migration, MigrateMessageInterface $message = NULL, EventDispatcherInterface $event_dispatcher = NULL) {
$this->migration = $migration;
$this->message = $message;
$this->migration->getIdMap()->setMessage($message);
$this->message = $message ?: new MigrateMessage();
$this->migration->getIdMap()->setMessage($this->message);
$this->eventDispatcher = $event_dispatcher;
// Record the memory limit in bytes
$limit = trim(ini_get('memory_limit'));
......
......@@ -3,7 +3,6 @@
namespace Drupal\Tests\migrate\Functional\process;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\Tests\BrowserTestBase;
......@@ -51,7 +50,7 @@ public function testExceptionThrow() {
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$executable = new MigrateExecutable($migration);
$result = $executable->import();
// Check that the migration has completed.
......
......@@ -5,7 +5,6 @@
use Drupal\KernelTests\KernelTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Plugin\migrate\destination\EntityContentBase;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Plugin\MigrationInterface;
......@@ -190,7 +189,7 @@ public function testEntityWithStringId() {
];
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$executable = new MigrateExecutable($migration);
$result = $executable->import();
$this->assertEquals(MigrationInterface::RESULT_COMPLETED, $result);
......
......@@ -7,7 +7,6 @@
use Drupal\migrate\Event\MigrateMapSaveEvent;
use Drupal\migrate\Event\MigratePostRowSaveEvent;
use Drupal\migrate\Event\MigratePreRowSaveEvent;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Event\MigrateEvents;
use Drupal\migrate\MigrateExecutable;
use Drupal\KernelTests\KernelTestBase;
......@@ -76,7 +75,7 @@ public function testMigrateEvents() {
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$executable = new MigrateExecutable($migration);
// As the import runs, events will be dispatched, recording the received
// information in state.
$executable->import();
......
......@@ -3,7 +3,6 @@
namespace Drupal\Tests\migrate\Kernel;
use Drupal\migrate\Event\MigratePostRowSaveEvent;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Event\MigrateEvents;
use Drupal\migrate\MigrateExecutable;
......@@ -56,7 +55,7 @@ public function testMigrateEvents() {
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$executable = new MigrateExecutable($migration);
// When the import runs, the first row imported will trigger an
// interruption.
$result = $executable->import();
......
......@@ -3,7 +3,6 @@
namespace Drupal\Tests\migrate\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
......@@ -50,7 +49,7 @@ public function testPrepareRowSkip() {
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$executable = new MigrateExecutable($migration);
$result = $executable->import();
$this->assertEqual($result, MigrationInterface::RESULT_COMPLETED);
......@@ -85,7 +84,7 @@ public function testPrepareRowSkip() {
];
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$executable = new MigrateExecutable($migration);
$result = $executable->import();
$this->assertEquals($result, MigrationInterface::RESULT_COMPLETED);
......
......@@ -4,7 +4,6 @@
use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Plugin\MigrationInterface;
/**
......@@ -66,7 +65,7 @@ public function testMultipleValueExplode(array $source_data, array $expected_dat
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$executable = new MigrateExecutable($migration);
$result = $executable->import();
// Migration needs to succeed before further assertions are made.
......
......@@ -4,7 +4,6 @@
use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Plugin\MigrationInterface;
/**
......@@ -94,7 +93,7 @@ public function testScalarAndMultipleValues(array $source_data, array $expected_
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$executable = new MigrateExecutable($migration);
$result = $executable->import();
// Migration needs to succeed before further assertions are made.
......
......@@ -4,7 +4,6 @@
use Drupal\migrate\Plugin\migrate\process\UrlEncode;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Row;
use Drupal\Tests\migrate\Unit\MigrateTestCase;
......@@ -56,7 +55,7 @@ public function testUrls($input, $output) {
* Encoded URL.
*/
protected function doTransform($value) {
$executable = new MigrateExecutable($this->getMigration(), new MigrateMessage());
$executable = new MigrateExecutable($this->getMigration());
$row = new Row();
return (new UrlEncode([], 'urlencode', []))
......
......@@ -9,7 +9,6 @@
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Plugin\RequirementsInterface;
/**
......@@ -49,7 +48,7 @@ function migrate_drupal_migration_plugins_alter(&$definitions) {
if ($source_plugin instanceof RequirementsInterface) {
$source_plugin->checkRequirements();
}
$executable = new MigrateExecutable($vocabulary_migration, new MigrateMessage());
$executable = new MigrateExecutable($vocabulary_migration);
$process = ['vid' => $definitions['d6_taxonomy_vocabulary']['process']['vid']];
foreach ($source_plugin as $row) {
$executable->processRow($row, $process);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment