Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
47febbf6
Commit
47febbf6
authored
Mar 30, 2016
by
alexpott
Browse files
Issue
#2694009
by heddn: MigrationInterface doesn't include get()
parent
e9fc0f1a
Changes
14
Hide whitespace changes
Inline
Side-by-side
core/modules/file/src/Plugin/migrate/source/d7/File.php
View file @
47febbf6
...
...
@@ -91,7 +91,7 @@ public function prepareRow(Row $row) {
// the source_base_path in order to make them all relative.
// @todo https://www.drupal.org/node/2577871 Don't depend on destination
// configuration and figure out if this is even needed at all?
$path
=
str_replace
(
$this
->
migration
->
get
(
'd
estination
'
)[
'source_base_path'
],
NULL
,
$path
);
$path
=
str_replace
(
$this
->
migration
->
get
D
estination
Configuration
(
)[
'source_base_path'
],
NULL
,
$path
);
$row
->
setSourceProperty
(
'filepath'
,
$path
);
return
parent
::
prepareRow
(
$row
);
}
...
...
core/modules/file/tests/src/Kernel/Migrate/d6/FileMigrationTestTrait.php
View file @
47febbf6
...
...
@@ -24,7 +24,7 @@ protected function setUpMigratedFiles() {
/** @var \Drupal\migrate\Plugin\migration $migration */
$migration
=
$migration_plugin_manager
->
createInstance
(
'd6_file'
);
$source
=
$migration
->
get
(
's
ource
'
);
$source
=
$migration
->
get
S
ource
Configuration
(
);
$source
[
'site_path'
]
=
'core/modules/simpletest'
;
$migration
->
set
(
'source'
,
$source
);
$this
->
executeMigration
(
$migration
);
...
...
core/modules/migrate/src/MigrateExecutable.php
View file @
47febbf6
...
...
@@ -261,7 +261,7 @@ public function import() {
$this
->
handleException
(
$e
);
}
}
if
(
$high_water_property
=
$this
->
migration
->
get
(
'h
ighWaterProperty
'
))
{
if
(
$high_water_property
=
$this
->
migration
->
get
H
ighWaterProperty
(
))
{
$this
->
migration
->
saveHighWater
(
$row
->
getSourceProperty
(
$high_water_property
[
'name'
]));
}
...
...
core/modules/migrate/src/Plugin/Migration.php
View file @
47febbf6
...
...
@@ -131,7 +131,9 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
protected
$destinationIds
=
[];
/**
* Information on the high water mark.
* Information on the property used as the high watermark.
*
* Array of 'name' & (optional) db 'alias' properties used for high watermark.
*
* @var array
*/
...
...
@@ -331,6 +333,9 @@ public function label() {
*
* @return mixed
* The value for that property, or NULL if the property does not exist.
*
* @deprecated in Drupal 8.1.x, will be removed before Drupal 9.0.x. Use
* more specific getters instead.
*/
public
function
get
(
$property
)
{
return
isset
(
$this
->
$property
)
?
$this
->
$property
:
NULL
;
...
...
@@ -677,4 +682,39 @@ public function getPluginDefinition() {
}
return
$definition
;
}
/**
* {@inheritdoc}
*/
public
function
getDestinationConfiguration
()
{
return
$this
->
destination
;
}
/**
* {@inheritdoc}
*/
public
function
getSourceConfiguration
()
{
return
$this
->
source
;
}
/**
* {@inheritdoc}
*/
public
function
getHighWaterProperty
()
{
return
$this
->
highWaterProperty
;
}
/**
* {@inheritdoc}
*/
public
function
getTrackLastImported
()
{
$this
->
trackLastImported
;
}
/**
* {@inheritdoc}
*/
public
function
getDestinationIds
()
{
$this
->
destinationIds
;
}
}
core/modules/migrate/src/Plugin/MigrationInterface.php
View file @
47febbf6
...
...
@@ -332,4 +332,51 @@ public function setTrackLastImported($track_last_imported);
*/
public
function
getMigrationDependencies
();
/**
* Get the destination configuration, with at least a 'plugin' key.
*
* @return array
* The destination configuration.
*/
public
function
getDestinationConfiguration
();
/**
* Get the source configuration, with at least a 'plugin' key.
*
* @return array
* The source configuration.
*/
public
function
getSourceConfiguration
();
/**
* Get information on the property used as the high watermark.
*
* Array of 'name' & (optional) db 'alias' properties used for high watermark.
*
* @see Drupal\migrate\Plugin\migrate\source\SqlBase::initializeIterator()
*
* @return array
* The property used as the high watermark.
*/
public
function
getHighWaterProperty
();
/**
* If true, track time of last import.
*
* @return bool
* Flag to determine desire of tracking time of last import.
*/
public
function
getTrackLastImported
();
/**
* The destination identifiers.
*
* An array of destination identifiers: the keys are the name of the
* properties, the values are dependent on the ID map plugin.
*
* @return array
* Destination identifiers.
*/
public
function
getDestinationIds
();
}
core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
View file @
47febbf6
...
...
@@ -570,7 +570,7 @@ public function saveIdMapping(Row $row, array $destination_id_values, $source_ro
$this
->
message
->
display
(
t
(
'Could not save to map table due to missing destination id values'
),
'error'
);
return
;
}
if
(
$this
->
migration
->
get
(
't
rackLastImported
'
))
{
if
(
$this
->
migration
->
get
T
rackLastImported
(
))
{
$fields
[
'last_imported'
]
=
time
();
}
$keys
=
[
static
::
SOURCE_IDS_HASH
=>
$this
->
getSourceIDsHash
(
$source_id_values
)];
...
...
core/modules/migrate/src/Plugin/migrate/process/Migration.php
View file @
47febbf6
...
...
@@ -121,7 +121,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
}
$destination_plugin
=
$migration
->
getDestinationPlugin
(
TRUE
);
// Only keep the process necessary to produce the destination ID.
$process
=
$migration
->
get
(
'p
rocess
'
);
$process
=
$migration
->
get
P
rocess
(
);
// We already have the source ID values but need to key them for the Row
// constructor.
...
...
@@ -131,7 +131,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
$values
[
$source_id
]
=
$source_id_values
[
$migration
->
id
()][
$index
];
}
$stub_row
=
new
Row
(
$values
+
$migration
->
get
(
's
ource
'
),
$source_ids
,
TRUE
);
$stub_row
=
new
Row
(
$values
+
$migration
->
get
S
ource
Configuration
(
),
$source_ids
,
TRUE
);
// Do a normal migration with the stub row.
$migrate_executable
->
processRow
(
$stub_row
,
$process
);
...
...
core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
View file @
47febbf6
...
...
@@ -153,7 +153,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
$this
->
idMap
=
$this
->
migration
->
getIdMap
();
// Pull out the current highwater mark if we have a highwater property.
if
(
$this
->
highWaterProperty
=
$this
->
migration
->
get
(
'h
ighWaterProperty
'
))
{
if
(
$this
->
highWaterProperty
=
$this
->
migration
->
get
H
ighWaterProperty
(
))
{
$this
->
originalHighWater
=
$this
->
migration
->
getHighWater
();
}
...
...
@@ -300,7 +300,7 @@ public function next() {
$row_data
=
$this
->
getIterator
()
->
current
()
+
$this
->
configuration
;
$this
->
getIterator
()
->
next
();
$row
=
new
Row
(
$row_data
,
$this
->
migration
->
getSourcePlugin
()
->
getIds
(),
$this
->
migration
->
get
(
'd
estinationIds
'
));
$row
=
new
Row
(
$row_data
,
$this
->
migration
->
getSourcePlugin
()
->
getIds
(),
$this
->
migration
->
get
D
estinationIds
(
));
// Populate the source key for this row.
$this
->
currentSourceIds
=
$row
->
getSourceIdValues
();
...
...
core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
View file @
47febbf6
...
...
@@ -166,7 +166,7 @@ protected function prepareQuery() {
*/
protected
function
initializeIterator
()
{
$this
->
prepareQuery
();
$high_water_property
=
$this
->
migration
->
get
(
'h
ighWaterProperty
'
);
$high_water_property
=
$this
->
migration
->
get
H
ighWaterProperty
(
);
// Get the key values, for potential use in joining to the map table.
$keys
=
array
();
...
...
@@ -208,7 +208,7 @@ protected function initializeIterator() {
$map_key
=
'sourceid'
.
$count
;
$this
->
query
->
addField
(
$alias
,
$map_key
,
"migrate_map_
$map_key
"
);
}
if
(
$n
=
count
(
$this
->
migration
->
get
(
'd
estinationIds
'
)))
{
if
(
$n
=
count
(
$this
->
migration
->
get
D
estinationIds
(
)))
{
for
(
$count
=
1
;
$count
<=
$n
;
$count
++
)
{
$map_key
=
'destid'
.
$count
++
;
$this
->
query
->
addField
(
$alias
,
$map_key
,
"migrate_map_
$map_key
"
);
...
...
core/modules/migrate/tests/src/Unit/MigrateTestCase.php
View file @
47febbf6
...
...
@@ -83,9 +83,9 @@ protected function getMigration() {
$configuration
=
&
$this
->
migrationConfiguration
;
$migration
->
method
(
'get'
)
->
willReturnCallback
(
function
(
$argument
)
use
(
&
$configuration
)
{
return
isset
(
$configuration
[
$argument
])
?
$configuration
[
$argument
]
:
''
;
$migration
->
method
(
'get
HighWaterProperty
'
)
->
willReturnCallback
(
function
()
use
(
$configuration
)
{
return
isset
(
$configuration
[
'highWaterProperty'
])
?
$configuration
[
'highWaterProperty'
]
:
''
;
});
$migration
->
method
(
'set'
)
...
...
core/modules/migrate/tests/src/Unit/process/MigrationTest.php
View file @
47febbf6
...
...
@@ -76,8 +76,8 @@ public function testTransformWithStubbing() {
$migration_plugin
->
id
()
->
willReturn
(
'actual_migration'
);
$destination_migration
->
id
()
->
willReturn
(
'destination_migration'
);
$destination_migration
->
getDestinationPlugin
(
TRUE
)
->
shouldBeCalled
();
$destination_migration
->
get
(
'p
rocess
'
)
->
willReturn
([]);
$destination_migration
->
get
(
's
ource
'
)
->
willReturn
([]);
$destination_migration
->
get
P
rocess
(
)
->
willReturn
([]);
$destination_migration
->
get
S
ource
Configuration
(
)
->
willReturn
([]);
$source_plugin
=
$this
->
prophesize
(
MigrateSourceInterface
::
class
);
$source_plugin
->
getIds
()
->
willReturn
([
'nid'
]);
...
...
core/modules/migrate_drupal/src/Plugin/migrate/destination/EntityFieldStorageConfig.php
View file @
47febbf6
...
...
@@ -75,7 +75,7 @@ public function calculateDependencies() {
$this
->
dependencies
=
parent
::
calculateDependencies
();
// Add a dependency on the module that provides the field type using the
// source plugin configuration.
$source_configuration
=
$this
->
migration
->
get
(
's
ource
'
);
$source_configuration
=
$this
->
migration
->
get
S
ource
Configuration
(
);
if
(
isset
(
$source_configuration
[
'constants'
][
'type'
]))
{
$field_type
=
$this
->
fieldTypePluginManager
->
getDefinition
(
$source_configuration
[
'constants'
][
'type'
]);
$this
->
addDependency
(
'module'
,
$field_type
[
'provider'
]);
...
...
core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php
View file @
47febbf6
...
...
@@ -112,7 +112,7 @@ public static function run($initial_ids, $operation, $config, &$context) {
$migration
=
\
Drupal
::
service
(
'plugin.manager.migration'
)
->
createInstance
(
$migration_id
);
// @TODO, remove this in https://www.drupal.org/node/2681869.
$destination
=
$migration
->
get
(
'd
estination
'
);
$destination
=
$migration
->
get
D
estination
Configuration
(
);
if
(
$destination
[
'plugin'
]
===
'entity:file'
)
{
// Make sure we have a single trailing slash.
$source_base_path
=
rtrim
(
$config
[
'source_base_path'
],
'/'
)
.
'/'
;
...
...
core/modules/user/tests/src/Kernel/Migrate/d6/MigrateUserPictureFileTest.php
View file @
47febbf6
...
...
@@ -27,7 +27,7 @@ protected function setUp() {
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
$migration
=
$this
->
getMigration
(
'd6_user_picture_file'
);
$source
=
$migration
->
get
(
's
ource
'
);
$source
=
$migration
->
get
S
ource
Configuration
(
);
$source
[
'site_path'
]
=
'core/modules/simpletest'
;
$migration
->
set
(
'source'
,
$source
);
$this
->
executeMigration
(
$migration
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment