Skip to content
GitLab
Explore
Sign in
project
drupal
Compare revisions
3ee04b473198505af763fde15ca2eed69ee6e90f to 8.1.x
Hide whitespace changes
Inline
Side-by-side
core/modules/migrate/src/Plugin/migrate/process/DedupeBase.php
View file @
614ba415
...
...
@@ -15,6 +15,8 @@
* creating filter format names, the current value is checked against the
* existing filter format names and if it exists, a numeric postfix is added
* and incremented until a unique value is created.
*
* @link https://www.drupal.org/node/2345929 Online handbook documentation for dedupebase process plugin @endlink
*/
abstract
class
DedupeBase
extends
ProcessPluginBase
{
...
...
core/modules/migrate/src/Plugin/migrate/process/DedupeEntity.php
View file @
614ba415
...
...
@@ -10,6 +10,8 @@
/**
* Ensures value is not duplicated against an entity field.
*
* @link https://www.drupal.org/node/2135325 Online handbook documentation for dedupe_entity process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "dedupe_entity"
* )
...
...
core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php
View file @
614ba415
...
...
@@ -9,6 +9,8 @@
/**
* This plugin sets missing values on the destination.
*
* @link https://www.drupal.org/node/2135313 Online handbook documentation for default_value process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "default_value"
* )
...
...
core/modules/migrate/src/Plugin/migrate/process/Explode.php
View file @
614ba415
...
...
@@ -10,6 +10,8 @@
/**
* This plugin explodes a delimited string into an array of values.
*
* @link https://www.drupal.org/node/2674504 Online handbook documentation for explode process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "explode"
* )
...
...
core/modules/migrate/src/Plugin/migrate/process/Extract.php
View file @
614ba415
...
...
@@ -11,7 +11,7 @@
/**
* This plugin extracts a value from an array.
*
* @
see
https://www.drupal.org/node/2152731
* @
link
https://www.drupal.org/node/2152731
Online handbook documentation for extract process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "extract"
...
...
core/modules/migrate/src/Plugin/migrate/process/Flatten.php
View file @
614ba415
...
...
@@ -12,7 +12,7 @@
* once a single value gets transformed into multiple values. This plugin will
* flatten them back down to single values again.
*
* @
see
https://www.drupal.org/node/2154215
* @
link
https://www.drupal.org/node/2154215
Online handbook documentation for flatten process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "flatten",
...
...
core/modules/migrate/src/Plugin/migrate/process/Get.php
View file @
614ba415
...
...
@@ -9,6 +9,8 @@
/**
* This plugin copies from the source to the destination.
*
* @link https://www.drupal.org/node/2135307 Online handbook documentation for get process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "get"
* )
...
...
core/modules/migrate/src/Plugin/migrate/process/Iterator.php
View file @
614ba415
...
...
@@ -9,7 +9,7 @@
/**
* This plugin iterates and processes an array.
*
* @
see
https://www.drupal.org/node/2135345
* @
link
https://www.drupal.org/node/2135345
Online handbook documentation for iterator process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "iterator",
...
...
core/modules/migrate/src/Plugin/migrate/process/MachineName.php
View file @
614ba415
...
...
@@ -17,6 +17,8 @@
* and replaced by an underscore and multiple underscores are collapsed into
* one.
*
* @link https://www.drupal.org/node/2135323 Online handbook documentation for machine_name process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "machine_name"
* )
...
...
core/modules/migrate/src/Plugin/migrate/process/Migration.php
View file @
614ba415
...
...
@@ -4,7 +4,7 @@
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
use
Drupal\migrate\MigrateSkipProcessException
;
use
Drupal\migrate\Plugin\MigratePluginManager
;
use
Drupal\migrate\Plugin\MigratePluginManager
Interface
;
use
Drupal\migrate\Plugin\MigrationPluginManagerInterface
;
use
Drupal\migrate\Plugin\MigrateIdMapInterface
;
use
Drupal\migrate\ProcessPluginBase
;
...
...
@@ -16,6 +16,8 @@
/**
* Calculates the value of a property based on a previous migration.
*
* @link https://www.drupal.org/node/2149801 Online handbook documentation for migration process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "migration"
* )
...
...
@@ -39,7 +41,7 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
/**
* {@inheritdoc}
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
MigrationInterface
$migration
,
MigrationPluginManagerInterface
$migration_plugin_manager
,
MigratePluginManager
$process_plugin_manager
)
{
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
MigrationInterface
$migration
,
MigrationPluginManagerInterface
$migration_plugin_manager
,
MigratePluginManager
Interface
$process_plugin_manager
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
);
$this
->
migrationPluginManager
=
$migration_plugin_manager
;
$this
->
migration
=
$migration
;
...
...
core/modules/migrate/src/Plugin/migrate/process/Route.php
View file @
614ba415
...
...
@@ -11,7 +11,10 @@
use
Drupal\migrate\Row
;
/**
* @MigrateProcessPlugin(
*
* @link https://www.drupal.org/node/2750777 Online handbook documentation for route process plugin @endlink
*
* * @MigrateProcessPlugin(
* id = "route"
* )
*/
...
...
core/modules/migrate/src/Plugin/migrate/process/SkipOnEmpty.php
View file @
614ba415
...
...
@@ -11,6 +11,8 @@
/**
* If the source evaluates to empty, we skip processing or the whole row.
*
* @link https://www.drupal.org/node/2228793 Online handbook documentation for skip_on_empty process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "skip_on_empty"
* )
...
...
core/modules/migrate/src/Plugin/migrate/process/SkipRowIfNotSet.php
View file @
614ba415
...
...
@@ -10,6 +10,8 @@
/**
* If the source evaluates to empty, we skip the current row.
*
* @link https://www.drupal.org/node/2345935 Online handbook documentation for skip_row_if_not_set process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "skip_row_if_not_set",
* handle_multiples = TRUE
...
...
core/modules/migrate/src/Plugin/migrate/process/StaticMap.php
View file @
614ba415
...
...
@@ -12,7 +12,7 @@
/**
* This plugin changes the current value based on a static lookup map.
*
* @
see
https://www.drupal.org/node/2143521
* @
link
https://www.drupal.org/node/2143521
Online handbook documentation for static_map process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "static_map"
...
...
core/modules/migrate/src/Plugin/migrate/process/Substr.php
View file @
614ba415
...
...
@@ -11,6 +11,8 @@
/**
* This plugin returns a substring of the current value.
*
* @link https://www.drupal.org/node/2771965 Online handbook documentation for substr process plugin @endlink
*
* @MigrateProcessPlugin(
* id = "substr"
* )
...
...
core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php
View file @
614ba415
...
...
@@ -15,7 +15,7 @@
*
* @ingroup migration
*/
class
MigrateCckFieldPluginManager
extends
MigratePluginManager
{
class
MigrateCckFieldPluginManager
extends
MigratePluginManager
implements
MigrateCckFieldPluginManagerInterface
{
/**
* The default version of core to use for cck field plugins.
...
...
@@ -29,7 +29,7 @@ class MigrateCckFieldPluginManager extends MigratePluginManager {
/**
* {@inheritdoc}
*/
public
function
createInstanc
e
(
$field_type
,
array
$configuration
=
array
()
,
MigrationInterface
$migration
=
NULL
)
{
public
function
getPluginIdFromFieldTyp
e
(
$field_type
,
array
$configuration
=
[]
,
MigrationInterface
$migration
=
NULL
)
{
$core
=
static
::
DEFAULT_CORE_VERSION
;
if
(
!
empty
(
$configuration
[
'core'
]))
{
$core
=
$configuration
[
'core'
];
...
...
@@ -45,7 +45,7 @@ public function createInstance($field_type, array $configuration = array(), Migr
foreach
(
$this
->
getDefinitions
()
as
$plugin_id
=>
$definition
)
{
if
(
in_array
(
$core
,
$definition
[
'core'
]))
{
if
(
array_key_exists
(
$field_type
,
$definition
[
'type_map'
])
||
$field_type
===
$plugin_id
)
{
return
parent
::
createInstance
(
$plugin_id
,
$configuration
,
$migration
)
;
return
$plugin_id
;
}
}
}
...
...
core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManagerInterface.php
0 → 100644
View file @
614ba415
<?php
namespace
Drupal\migrate_drupal\Plugin
;
use
Drupal\migrate\Plugin\MigratePluginManagerInterface
;
use
Drupal\migrate\Plugin\MigrationInterface
;
interface
MigrateCckFieldPluginManagerInterface
extends
MigratePluginManagerInterface
{
/**
* Get the plugin ID from the field type.
*
* @param string $field_type
* The field type being migrated.
* @param array $configuration
* (optional) An array of configuration relevant to the plugin instance.
* @param \Drupal\migrate\Plugin\MigrationInterface|null $migration
* (optional) The current migration instance.
*
* @return string
* The ID of the plugin for the field_type if available.
*
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* If the plugin cannot be determined, such as if the field type is invalid.
*/
public
function
getPluginIdFromFieldType
(
$field_type
,
array
$configuration
=
[],
MigrationInterface
$migration
=
NULL
);
}
core/modules/migrate_drupal/src/Plugin/migrate/CckMigration.php
View file @
614ba415
...
...
@@ -2,13 +2,15 @@
namespace
Drupal\migrate_drupal\Plugin\migrate
;
use
Drupal\Component\Plugin\Exception\PluginNotFoundException
;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
use
Drupal\migrate\Exception\RequirementsException
;
use
Drupal\migrate\Plugin\MigrateDestinationPluginManager
;
use
Drupal\migrate\Plugin\MigratePluginManager
;
use
Drupal\migrate\Plugin\MigratePluginManager
Interface
;
use
Drupal\migrate\Plugin\Migration
;
use
Drupal\migrate\Plugin\MigrationPluginManagerInterface
;
use
Drupal\migrate\Plugin\RequirementsInterface
;
use
Drupal\migrate_drupal
\Plugin\MigrateCckFieldPluginManagerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
...
...
@@ -40,7 +42,7 @@ class CckMigration extends Migration implements ContainerFactoryPluginInterface
/**
* The cckfield plugin manager.
*
* @var \Drupal\migrate\Plugin\MigratePluginManager
* @var \Drupal\migrate
_drupal
\Plugin\Migrate
CckField
PluginManager
Interface
*/
protected
$cckPluginManager
;
...
...
@@ -53,20 +55,20 @@ class CckMigration extends Migration implements ContainerFactoryPluginInterface
* The plugin ID.
* @param mixed $plugin_definition
* The plugin definition.
* @param \Drupal\migrate\Plugin\MigratePluginManager $cck_manager
* @param \Drupal\migrate
_drupal
\Plugin\Migrate
CckField
PluginManager
Interface
$cck_manager
* The cckfield plugin manager.
* @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager
* The migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $source_plugin_manager
* @param \Drupal\migrate\Plugin\MigratePluginManager
Interface
$source_plugin_manager
* The source migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $process_plugin_manager
* @param \Drupal\migrate\Plugin\MigratePluginManager
Interface
$process_plugin_manager
* The process migration plugin manager.
* @param \Drupal\migrate\Plugin\MigrateDestinationPluginManager $destination_plugin_manager
* The destination migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $idmap_plugin_manager
* @param \Drupal\migrate\Plugin\MigratePluginManager
Interface
$idmap_plugin_manager
* The ID map migration plugin manager.
*/
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
MigratePluginManager
$cck_manager
,
MigrationPluginManagerInterface
$migration_plugin_manager
,
MigratePluginManager
$source_plugin_manager
,
MigratePluginManager
$process_plugin_manager
,
MigrateDestinationPluginManager
$destination_plugin_manager
,
MigratePluginManager
$idmap_plugin_manager
)
{
public
function
__construct
(
array
$configuration
,
$plugin_id
,
$plugin_definition
,
Migrate
CckField
PluginManager
Interface
$cck_manager
,
MigrationPluginManagerInterface
$migration_plugin_manager
,
MigratePluginManager
Interface
$source_plugin_manager
,
MigratePluginManager
Interface
$process_plugin_manager
,
MigrateDestinationPluginManager
$destination_plugin_manager
,
MigratePluginManager
Interface
$idmap_plugin_manager
)
{
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
,
$migration_plugin_manager
,
$source_plugin_manager
,
$process_plugin_manager
,
$destination_plugin_manager
,
$idmap_plugin_manager
);
$this
->
cckPluginManager
=
$cck_manager
;
}
...
...
@@ -106,12 +108,19 @@ public function getProcess() {
}
foreach
(
$source_plugin
as
$row
)
{
$field_type
=
$row
->
getSourceProperty
(
'type'
);
if
(
!
isset
(
$this
->
processedFieldTypes
[
$field_type
])
&&
$this
->
cckPluginManager
->
hasDefinition
(
$field_type
))
{
try
{
$plugin_id
=
$this
->
cckPluginManager
->
getPluginIdFromFieldType
(
$field_type
,
[],
$this
);
}
catch
(
PluginNotFoundException
$ex
)
{
continue
;
}
if
(
!
isset
(
$this
->
processedFieldTypes
[
$field_type
]))
{
$this
->
processedFieldTypes
[
$field_type
]
=
TRUE
;
// Allow the cckfield plugin to alter the migration as necessary so
// that it knows how to handle fields of this type.
if
(
!
isset
(
$this
->
cckPluginCache
[
$field_type
]))
{
$this
->
cckPluginCache
[
$field_type
]
=
$this
->
cckPluginManager
->
createInstance
(
$
field_type
,
[],
$this
);
$this
->
cckPluginCache
[
$field_type
]
=
$this
->
cckPluginManager
->
createInstance
(
$
plugin_id
,
[],
$this
);
}
call_user_func
([
$this
->
cckPluginCache
[
$field_type
],
$this
->
pluginDefinition
[
'cck_plugin_method'
]],
$this
);
}
...
...
core/modules/migrate_drupal/tests/src/Kernel/MigrateCckFieldPluginManagerTest.php
View file @
614ba415
...
...
@@ -22,32 +22,33 @@ class MigrateCckFieldPluginManagerTest extends MigrateDrupalTestBase {
public
function
testPluginSelection
()
{
$plugin_manager
=
\Drupal
::
service
(
'plugin.manager.migrate.cckfield'
);
$this
->
assertIdentical
(
'Drupal\\file\\Plugin\\migrate\\cckfield\\d6\\FileField'
,
get_class
(
$plugin_manager
->
createInstance
(
'filefield'
,
[
'core'
=>
6
])));
$plugin_id
=
$plugin_manager
->
getPluginIdFromFieldType
(
'filefield'
,
[
'core'
=>
6
]);
$this
->
assertIdentical
(
'Drupal\\file\\Plugin\\migrate\\cckfield\\d6\\FileField'
,
get_class
(
$plugin_manager
->
createInstance
(
$plugin_id
,
[
'core'
=>
6
])));
try
{
// If this test passes,
createInstanc
e will raise a
// If this test passes,
getPluginIdFromFieldTyp
e will raise a
// PluginNotFoundException and we'll never reach fail().
$plugin_manager
->
createInstanc
e
(
'filefield'
,
[
'core'
=>
7
]);
$plugin_manager
->
getPluginIdFromFieldTyp
e
(
'filefield'
,
[
'core'
=>
7
]);
$this
->
fail
(
'Expected Drupal\Component\Plugin\Exception\PluginNotFoundException.'
);
}
catch
(
PluginNotFoundException
$e
)
{
$this
->
assertIdentical
(
$e
->
getMessage
(),
"Plugin ID 'filefield' was not found."
);
}
$this
->
assertIdentical
(
'
Drupal\\file\\Plugin\\migrate\\cckfield\\d7\\ImageField'
,
get_class
(
$plugin_manager
->
createInstanc
e
(
'image'
,
[
'core'
=>
7
]))
)
;
$this
->
assertIdentical
(
'
Drupal\\file\\Plugin\\migrate\\cckfield\\d7\\FileField'
,
get_class
(
$plugin_manager
->
createInstanc
e
(
'file'
,
[
'core'
=>
7
]))
)
;
$this
->
assertIdentical
(
'
Drupal\\migrate_cckfield_plugin_manager_test\\Plugin\\migrate\\cckfield\\D6FileField'
,
get_class
(
$plugin_manager
->
createInstanc
e
(
'file'
,
[
'core'
=>
6
]))
)
;
$this
->
assertIdentical
(
'
image'
,
$plugin_manager
->
getPluginIdFromFieldTyp
e
(
'image'
,
[
'core'
=>
7
]));
$this
->
assertIdentical
(
'
file'
,
$plugin_manager
->
getPluginIdFromFieldTyp
e
(
'file'
,
[
'core'
=>
7
]));
$this
->
assertIdentical
(
'
d6_file'
,
$plugin_manager
->
getPluginIdFromFieldTyp
e
(
'file'
,
[
'core'
=>
6
]));
$this
->
assertIdentical
(
'
Drupal\\text\\Plugin\\migrate\\cckfield\\TextField'
,
get_class
(
$plugin_manager
->
createInstanc
e
(
'text'
,
[
'core'
=>
6
]))
)
;
$this
->
assertIdentical
(
'
Drupal\\text\\Plugin\\migrate\\cckfield\\TextField'
,
get_class
(
$plugin_manager
->
createInstanc
e
(
'text'
,
[
'core'
=>
7
]))
)
;
$this
->
assertIdentical
(
'
text'
,
$plugin_manager
->
getPluginIdFromFieldTyp
e
(
'text'
,
[
'core'
=>
6
]));
$this
->
assertIdentical
(
'
text'
,
$plugin_manager
->
getPluginIdFromFieldTyp
e
(
'text'
,
[
'core'
=>
7
]));
// Test fallback when no core version is specified.
$this
->
assertIdentical
(
'
Drupal\\migrate_cckfield_plugin_manager_test\\Plugin\\migrate\\cckfield\\D6NoC
ore
V
ersion
S
pecified'
,
get_class
(
$plugin_manager
->
createInstanc
e
(
'd6_no_core_version_specified'
,
[
'core'
=>
6
]))
)
;
$this
->
assertIdentical
(
'
d6_no_c
ore
_v
ersion
_s
pecified'
,
$plugin_manager
->
getPluginIdFromFieldTyp
e
(
'd6_no_core_version_specified'
,
[
'core'
=>
6
]));
try
{
// If this test passes,
createInstanc
e will raise a
// If this test passes,
getPluginIdFromFieldTyp
e will raise a
// PluginNotFoundException and we'll never reach fail().
$plugin_manager
->
createInstanc
e
(
'd6_no_core_version_specified'
,
[
'core'
=>
7
]);
$plugin_manager
->
getPluginIdFromFieldTyp
e
(
'd6_no_core_version_specified'
,
[
'core'
=>
7
]);
$this
->
fail
(
'Expected Drupal\Component\Plugin\Exception\PluginNotFoundException.'
);
}
catch
(
PluginNotFoundException
$e
)
{
...
...
core/modules/node/src/Plugin/migrate/D6NodeDeriver.php
View file @
614ba415
...
...
@@ -3,11 +3,12 @@
namespace
Drupal\node\Plugin\migrate
;
use
Drupal\Component\Plugin\Derivative\DeriverBase
;
use
Drupal\Component\Plugin\
PluginManagerInterface
;
use
Drupal\Component\Plugin\
Exception\PluginNotFoundException
;
use
Drupal\Core\Database\DatabaseExceptionWrapper
;
use
Drupal\Core\Plugin\Discovery\ContainerDeriverInterface
;
use
Drupal\migrate\Exception\RequirementsException
;
use
Drupal\migrate\Plugin\MigrationDeriverTrait
;
use
Drupal\migrate_drupal
\Plugin\MigrateCckFieldPluginManagerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
...
...
@@ -33,7 +34,7 @@ class D6NodeDeriver extends DeriverBase implements ContainerDeriverInterface {
/**
* The CCK plugin manager.
*
* @var \Drupal\
Component\Plugin\
PluginManagerInterface
* @var \Drupal\
migrate_drupal\Plugin\MigrateCckField
PluginManagerInterface
*/
protected
$cckPluginManager
;
...
...
@@ -49,12 +50,12 @@ class D6NodeDeriver extends DeriverBase implements ContainerDeriverInterface {
*
* @param string $base_plugin_id
* The base plugin ID for the plugin ID.
* @param \Drupal\
Component\Plugin\
PluginManagerInterface $cck_manager
* @param \Drupal\
migrate_drupal\Plugin\MigrateCckField
PluginManagerInterface $cck_manager
* The CCK plugin manager.
* @param bool $translations
* Whether or not to include translations.
*/
public
function
__construct
(
$base_plugin_id
,
PluginManagerInterface
$cck_manager
,
$translations
)
{
public
function
__construct
(
$base_plugin_id
,
MigrateCckField
PluginManagerInterface
$cck_manager
,
$translations
)
{
$this
->
basePluginId
=
$base_plugin_id
;
$this
->
cckPluginManager
=
$cck_manager
;
$this
->
includeTranslations
=
$translations
;
...
...
@@ -128,14 +129,15 @@ public function getDerivativeDefinitions($base_plugin_definition) {
if
(
isset
(
$fields
[
$node_type
]))
{
foreach
(
$fields
[
$node_type
]
as
$field_name
=>
$info
)
{
$field_type
=
$info
[
'type'
];
if
(
$this
->
cckPluginManager
->
hasDefinition
(
$info
[
'type'
]))
{
try
{
$plugin_id
=
$this
->
cckPluginManager
->
getPluginIdFromFieldType
(
$field_type
,
[
'core'
=>
6
],
$migration
);
if
(
!
isset
(
$this
->
cckPluginCache
[
$field_type
]))
{
$this
->
cckPluginCache
[
$field_type
]
=
$this
->
cckPluginManager
->
createInstance
(
$
field_type
,
[
'core'
=>
6
],
$migration
);
$this
->
cckPluginCache
[
$field_type
]
=
$this
->
cckPluginManager
->
createInstance
(
$
plugin_id
,
[
'core'
=>
6
],
$migration
);
}
$this
->
cckPluginCache
[
$field_type
]
->
processCckFieldValues
(
$migration
,
$field_name
,
$info
);
}
else
{
catch
(
PluginNotFoundException
$ex
)
{
$migration
->
setProcessOfProperty
(
$field_name
,
$field_name
);
}
}
...
...
Prev
1
2
3
4
Next