Commit 1e98b164 authored by alexpott's avatar alexpott

Issue #2384529 by hussainweb, rpayanm: Make the class variables protected for Migration

parent c4990fc1
......@@ -41,21 +41,21 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
*
* @var string
*/
public $id;
protected $id;
/**
* The human-readable label for the migration.
*
* @var string
*/
public $label;
protected $label;
/**
* The plugin ID for the row.
*
* @var string
*/
public $row;
protected $row;
/**
* The source configuration, with at least a 'plugin' key.
......@@ -64,7 +64,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
*
* @var array
*/
public $source;
protected $source;
/**
* The source plugin.
......@@ -78,21 +78,21 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
*
* @var array
*/
public $process;
protected $process;
/**
* The configuration describing the load plugins.
*
* @var array
*/
public $load;
protected $load;
/**
* The cached process plugins.
*
* @var array
*/
protected $processPlugins = array();
protected $processPlugins = [];
/**
* The destination configuration, with at least a 'plugin' key.
......@@ -101,7 +101,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
*
* @var array
*/
public $destination;
protected $destination;
/**
* The destination plugin.
......@@ -117,7 +117,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
*
* @var string
*/
public $idMap = array();
protected $idMap = [];
/**
* The identifier map.
......@@ -134,7 +134,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
*
* @var array
*/
public $sourceIds = array();
protected $sourceIds = [];
/**
* The destination identifiers.
......@@ -144,14 +144,14 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
*
* @var array
*/
public $destinationIds = FALSE;
protected $destinationIds = [];
/**
* Information on the high water mark.
*
* @var array
*/
public $highWaterProperty;
protected $highWaterProperty;
/**
* Indicate whether the primary system of record for this migration is the
......@@ -163,7 +163,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
*
* @var string
*/
public $systemOfRecord = self::SOURCE;
protected $systemOfRecord = self::SOURCE;
/**
* Specify value of source_row_status for current map row. Usually set by
......@@ -171,7 +171,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
*
* @var int
*/
public $sourceRowStatus = MigrateIdMapInterface::STATUS_IMPORTED;
protected $sourceRowStatus = MigrateIdMapInterface::STATUS_IMPORTED;
/**
* @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface
......@@ -179,23 +179,25 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
protected $highWaterStorage;
/**
* Track time of last import if TRUE.
*
* @var bool
*/
public $trackLastImported = FALSE;
protected $trackLastImported = FALSE;
/**
* These migrations must be already executed before this migration can run.
*
* @var array
*/
protected $requirements = array();
protected $requirements = [];
/**
* These migrations, if ran at all, must be executed before this migration.
*
* @var array
*/
public $migration_dependencies = array();
protected $migration_dependencies = [];
/**
* The entity manager.
......@@ -382,4 +384,55 @@ public function isComplete() {
return $this->getMigrationResult() === static::RESULT_COMPLETED;
}
/**
* {@inheritdoc}
*/
public function getProcess() {
return $this->process;
}
/**
* {@inheritdoc}
*/
public function setProcess(array $process) {
$this->process = $process;
return $this;
}
/**
* {@inheritdoc}
*/
public function getSystemOfRecord() {
return $this->systemOfRecord;
}
/**
* {@inheritdoc}
*/
public function setSystemOfRecord($system_of_record) {
$this->systemOfRecord = $system_of_record;
return $this;
}
/**
* {@inheritdoc}
*/
public function isTrackLastImported() {
return $this->trackLastImported;
}
/**
* {@inheritdoc}
*/
public function setTrackLastImported($track_last_imported) {
$this->trackLastImported = (bool) $track_last_imported;
return $this;
}
/**
* {@inheritdoc}
*/
public function getMigrationDependencies() {
return $this->migration_dependencies;
}
}
......@@ -179,4 +179,66 @@ public function setMigrationResult($result);
*/
public function getMigrationResult();
/**
* Get the current configuration describing the process plugins.
*
* @return array
* The configuration describing the process plugins.
*/
public function getProcess();
/**
* Set the current configuration describing the process plugins.
*
* @param array $process
* The configuration describing the process plugins.
*
* @return $this
*/
public function setProcess(array $process);
/**
* Get the current system of record of the migration.
*
* @return string
* The current system of record of the migration.
*/
public function getSystemOfRecord();
/**
* Set the system of record for the migration.
*
* @param string $system_of_record
* The system of record of the migration.
*
* @return $this
*/
public function setSystemOfRecord($system_of_record);
/**
* Checks if the migration should track time of last import.
*
* @return bool
* TRUE if the migration is tracking last import time.
*/
public function isTrackLastImported();
/**
* Set if the migration should track time of last import.
*
* @param bool $track_last_imported
* Boolean value to indicate if the migration should track last import time.
*
* @return $this
*/
public function setTrackLastImported($track_last_imported);
/**
* Get the dependencies for this migration.
*
* @return array
* The dependencies for this migrations.
*/
public function getMigrationDependencies();
}
......@@ -27,20 +27,22 @@ public function buildDependencyMigration(array $migrations, array $dynamic_ids)
$requirement_graph = array();
$different = FALSE;
foreach ($migrations as $migration) {
/** @var \Drupal\migrate\Entity\Migration $migration */
/** @var \Drupal\migrate\Entity\MigrationInterface $migration */
$id = $migration->id();
$requirements[$id] = array();
$dependency_graph[$id]['edges'] = array();
if (isset($migration->migration_dependencies['required'])) {
foreach ($migration->migration_dependencies['required'] as $dependency) {
$migration_dependencies = $migration->getMigrationDependencies();
if (isset($migration_dependencies['required'])) {
foreach ($migration_dependencies['required'] as $dependency) {
if (!isset($dynamic_ids[$dependency])) {
$this->addDependency($requirement_graph, $id, $dependency, $dynamic_ids);
}
$this->addDependency($dependency_graph, $id, $dependency, $dynamic_ids);
}
}
if (isset($migration->migration_dependencies['optional'])) {
foreach ($migration->migration_dependencies['optional'] as $dependency) {
if (isset($migration_dependencies['optional'])) {
foreach ($migration_dependencies['optional'] as $dependency) {
$different = TRUE;
$this->addDependency($dependency_graph, $id, $dependency, $dynamic_ids);
}
......
......@@ -98,13 +98,15 @@ public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = N
$this->processTextField($field_name, $data, $migration);
break;
default:
$migration->process[$field_name] = $field_name;
$process = $migration->getProcess();
$process[$field_name] = $field_name;
$migration->setProcess($process);
}
}
}
else {
$fields = array_keys($migration->getSourcePlugin()->fields());
$migration->process += array_combine($fields, $fields);
$migration->setProcess($migration->getProcess() + array_combine($fields, $fields));
}
$migrations[$migration->id()] = $migration;
}
......@@ -132,10 +134,12 @@ protected function processTextField($field_name, $field_data, MigrationInterface
$value_key = $field_data['db_storage'] ? $field_name : "$field_name/value";
$format_key = $field_data['db_storage'] ? $field_name . '_format' : "$field_name/format" ;
$migration->process["$field_name/value"] = $value_key;
$process = $migration->getProcess();
$process["$field_name/value"] = $value_key;
// See d6_user, signature_format for an example of the YAML that
// represents this process array.
$migration->process["$field_name/format"] = [
$process["$field_name/format"] = [
[
'plugin' => 'static_map',
'bypass' => TRUE,
......@@ -150,6 +154,8 @@ protected function processTextField($field_name, $field_data, MigrationInterface
'no_stub' => 1,
],
];
$migration->setProcess($process);
}
/**
......@@ -163,7 +169,8 @@ protected function processTextField($field_name, $field_data, MigrationInterface
* The migration entity.
*/
protected function processFileField($field_name, $field_data, MigrationInterface $migration) {
$migration->process[$field_name] = [
$process = $migration->getProcess();
$process[$field_name] = [
'plugin' => 'd6_cck_file',
'source' => [
$field_name,
......@@ -171,6 +178,7 @@ protected function processFileField($field_name, $field_data, MigrationInterface
$field_name . '_data',
],
];
$migration->setProcess($process);
}
/**
......@@ -186,7 +194,8 @@ protected function processFileField($field_name, $field_data, MigrationInterface
protected function processLinkField($field_name, $field_data, MigrationInterface $migration) {
// Specifically process the link field until core is fixed.
// @see https://www.drupal.org/node/2235457
$migration->process[$field_name] = [
$process = $migration->getProcess();
$process[$field_name] = [
'plugin' => 'd6_cck_link',
'source' => [
$field_name,
......@@ -194,6 +203,7 @@ protected function processLinkField($field_name, $field_data, MigrationInterface
$field_name . '_attributes',
],
];
$migration->setProcess($process);
}
}
......@@ -36,9 +36,11 @@ protected function setUp() {
$dumps = array(
$this->getDumpDirectory() . '/Files.php',
);
/** @var \Drupal\migrate\entity\Migration $migration */
/** @var \Drupal\migrate\Entity\MigrationInterface $migration */
$migration = entity_load('migration', 'd6_file');
$migration->source['conf_path'] = 'core/modules/simpletest';
$source = $migration->get('source');
$source['conf_path'] = 'core/modules/simpletest';
$migration->set('source', $source);
$this->prepare($migration, $dumps);
$executable = new MigrateExecutable($migration, $this);
$executable->import();
......
......@@ -35,9 +35,11 @@ protected function setUp() {
$this->getDumpDirectory() . '/UsersRoles.php',
$this->getDumpDirectory() . '/EventTimezones.php',
);
/** @var \Drupal\migrate\entity\Migration $migration */
/** @var \Drupal\migrate\Entity\MigrationInterface $migration */
$migration = entity_load('migration', 'd6_user_picture_file');
$migration->source['conf_path'] = 'core/modules/simpletest';
$source = $migration->get('source');
$source['conf_path'] = 'core/modules/simpletest';
$migration->set('source', $source);
$this->prepare($migration, $dumps);
$executable = new MigrateExecutable($migration, $this);
$executable->import();
......
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