updated contrib modules
This commit is contained in:
@@ -17,8 +17,8 @@
|
||||
"source": "https://cgit.drupalcode.org/migrate_plus"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"require": {},
|
||||
"suggest": {
|
||||
"sainsburys/guzzle-oauth2-plugin": "3.0 required for the OAuth2 authentication plugin"
|
||||
"sainsburys/guzzle-oauth2-plugin": "3.0 required for the OAuth2 authentication plugin",
|
||||
"ext-soap": "*"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ process:
|
||||
title: name
|
||||
nid: bid
|
||||
uid:
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
migration: beer_user
|
||||
source: aid
|
||||
sticky:
|
||||
@@ -22,7 +22,7 @@ process:
|
||||
default_value: 0
|
||||
field_migrate_example_country: countries
|
||||
field_migrate_example_beer_style:
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
migration: beer_term
|
||||
source: terms
|
||||
# Some Drupal fields may have multiple components we may want to set
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ process:
|
||||
# IDs in map tables, and the migration plugin is the means of performing a
|
||||
# lookup in those map tables during processing.
|
||||
parent:
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
# Here we reference the migration whose map table we're performing a lookup
|
||||
# against. You'll note that in this case we're actually referencing this
|
||||
# migration itself, since category parents are imported by the same
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ process:
|
||||
# when that migration runs it knows that each incoming beer should overwrite
|
||||
# its stub instead of creating a new node.
|
||||
field_migrate_example_favbeers:
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
source: beers
|
||||
migration: beer_node
|
||||
|
||||
|
||||
+5
-3
@@ -7,9 +7,11 @@ dependencies:
|
||||
- drupal:migrate
|
||||
- migrate_plus:migrate_example_setup
|
||||
- migrate_plus:migrate_plus
|
||||
- drupal:menu_ui
|
||||
- drupal:path
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-05-10
|
||||
version: '8.x-4.0-beta1'
|
||||
# Information added by Drupal.org packaging script on 2017-12-12
|
||||
version: '8.x-4.0-beta2'
|
||||
core: '8.x'
|
||||
project: 'migrate_plus'
|
||||
datestamp: 1494450189
|
||||
datestamp: 1513088305
|
||||
|
||||
+3
-3
@@ -11,8 +11,8 @@ dependencies:
|
||||
- drupal:options
|
||||
- drupal:taxonomy
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-05-10
|
||||
version: '8.x-4.0-beta1'
|
||||
# Information added by Drupal.org packaging script on 2017-12-12
|
||||
version: '8.x-4.0-beta2'
|
||||
core: '8.x'
|
||||
project: 'migrate_plus'
|
||||
datestamp: 1494450189
|
||||
datestamp: 1513088305
|
||||
|
||||
+132
-130
@@ -27,270 +27,272 @@ function migrate_example_setup_install() {
|
||||
}
|
||||
|
||||
function migrate_example_beer_schema_node() {
|
||||
return array(
|
||||
return [
|
||||
'description' => 'Beers of the world.',
|
||||
'fields' => array(
|
||||
'bid' => array(
|
||||
'fields' => [
|
||||
'bid' => [
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Beer ID.',
|
||||
),
|
||||
'name' => array(
|
||||
],
|
||||
'name' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'body' => array(
|
||||
],
|
||||
'body' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Full description of the beer.',
|
||||
),
|
||||
'excerpt' => array(
|
||||
],
|
||||
'excerpt' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Abstract for this beer.',
|
||||
),
|
||||
'countries' => array(
|
||||
],
|
||||
'countries' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Countries of origin. Multiple values, delimited by pipe',
|
||||
),
|
||||
'aid' => array(
|
||||
],
|
||||
'aid' => [
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
'description' => 'Account Id of the author.',
|
||||
),
|
||||
'image' => array(
|
||||
],
|
||||
'image' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Image path',
|
||||
),
|
||||
'image_alt' => array(
|
||||
],
|
||||
'image_alt' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Image ALT',
|
||||
),
|
||||
'image_title' => array(
|
||||
],
|
||||
'image_title' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Image title',
|
||||
),
|
||||
'image_description' => array(
|
||||
],
|
||||
'image_description' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Image description',
|
||||
),
|
||||
),
|
||||
'primary key' => array('bid'),
|
||||
);
|
||||
],
|
||||
],
|
||||
'primary key' => ['bid'],
|
||||
];
|
||||
}
|
||||
|
||||
function migrate_example_beer_schema_topic() {
|
||||
return array(
|
||||
return [
|
||||
'description' => 'Categories',
|
||||
'fields' => array(
|
||||
'style' => array(
|
||||
'fields' => [
|
||||
'style' => [
|
||||
'type' => 'varchar_ascii',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'details' => array(
|
||||
],
|
||||
'details' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'style_parent' => array(
|
||||
],
|
||||
'style_parent' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Parent topic, if any',
|
||||
),
|
||||
'region' => array(
|
||||
],
|
||||
'region' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Region first associated with this style',
|
||||
),
|
||||
'hoppiness' => array(
|
||||
],
|
||||
'hoppiness' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Relative hoppiness of the beer',
|
||||
),
|
||||
),
|
||||
'primary key' => array('style'),
|
||||
);
|
||||
],
|
||||
],
|
||||
'primary key' => ['style'],
|
||||
];
|
||||
}
|
||||
|
||||
function migrate_example_beer_schema_topic_node() {
|
||||
return array(
|
||||
return [
|
||||
'description' => 'Beers topic pairs.',
|
||||
'fields' => array(
|
||||
'bid' => array(
|
||||
'fields' => [
|
||||
'bid' => [
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Beer ID.',
|
||||
),
|
||||
'style' => array(
|
||||
],
|
||||
'style' => [
|
||||
'type' => 'varchar_ascii',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'description' => 'Topic name',
|
||||
),
|
||||
),
|
||||
'primary key' => array('style', 'bid'),
|
||||
);
|
||||
],
|
||||
],
|
||||
'primary key' => ['style', 'bid'],
|
||||
];
|
||||
}
|
||||
|
||||
function migrate_example_beer_schema_comment() {
|
||||
return array(
|
||||
return [
|
||||
'description' => 'Beers comments.',
|
||||
'fields' => array(
|
||||
'cid' => array(
|
||||
'fields' => [
|
||||
'cid' => [
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Comment ID.',
|
||||
),
|
||||
'bid' => array(
|
||||
],
|
||||
'bid' => [
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Beer ID that is being commented upon',
|
||||
),
|
||||
'cid_parent' => array(
|
||||
],
|
||||
'cid_parent' => [
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
'description' => 'Parent comment ID in case of comment replies.',
|
||||
),
|
||||
'subject' => array(
|
||||
],
|
||||
'subject' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Comment subject',
|
||||
),
|
||||
'body' => array(
|
||||
],
|
||||
'body' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Comment body',
|
||||
),
|
||||
'name' => array(
|
||||
],
|
||||
'name' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Comment name (if anon)',
|
||||
),
|
||||
'mail' => array(
|
||||
],
|
||||
'mail' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Comment email (if anon)',
|
||||
),
|
||||
'aid' => array(
|
||||
],
|
||||
'aid' => [
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
'description' => 'Account ID (if any).',
|
||||
),
|
||||
),
|
||||
'primary key' => array('cid'),
|
||||
);
|
||||
],
|
||||
],
|
||||
'primary key' => ['cid'],
|
||||
];
|
||||
}
|
||||
|
||||
function migrate_example_beer_schema_account() {
|
||||
return array(
|
||||
return [
|
||||
'description' => 'Beers accounts.',
|
||||
'fields' => array(
|
||||
'aid' => array(
|
||||
'fields' => [
|
||||
'aid' => [
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Account ID',
|
||||
),
|
||||
'status' => array(
|
||||
],
|
||||
'status' => [
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Blocked_Allowed',
|
||||
),
|
||||
'registered' => array(
|
||||
],
|
||||
'registered' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'description' => 'Registration date',
|
||||
),
|
||||
'username' => array(
|
||||
],
|
||||
'username' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Account name (for login)',
|
||||
),
|
||||
'nickname' => array(
|
||||
],
|
||||
'nickname' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Account name (for display)',
|
||||
),
|
||||
'password' => array(
|
||||
],
|
||||
'password' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Account password (raw)',
|
||||
),
|
||||
'email' => array(
|
||||
],
|
||||
'email' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Account email',
|
||||
),
|
||||
'sex' => array(
|
||||
],
|
||||
'sex' => [
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
'description' => 'Gender (0 for male, 1 for female)',
|
||||
),
|
||||
'beers' => array(
|
||||
],
|
||||
'beers' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
'description' => 'Favorite Beers',
|
||||
),
|
||||
),
|
||||
'primary key' => array('aid'),
|
||||
);
|
||||
],
|
||||
],
|
||||
'primary key' => ['aid'],
|
||||
];
|
||||
}
|
||||
|
||||
function migrate_example_beer_data_node() {
|
||||
$fields = array('bid', 'name', 'body', 'excerpt', 'countries', 'aid', 'image',
|
||||
'image_alt', 'image_title', 'image_description');
|
||||
$fields = ['bid', 'name', 'body', 'excerpt', 'countries', 'aid', 'image',
|
||||
'image_alt', 'image_title', 'image_description'];
|
||||
$query = db_insert('migrate_example_beer_node')
|
||||
->fields($fields);
|
||||
->fields($fields);
|
||||
// Use high bid numbers to avoid overwriting an existing node id.
|
||||
$data = array(
|
||||
array(99999999, 'Heineken', 'Blab Blah Blah Green', 'Green', 'Netherlands|Belgium', 0, 'heineken.jpg', 'Heinekin alt', 'Heinekin title', 'Heinekin description'), // comes with migrate_example project.
|
||||
array(99999998, 'Miller Lite', 'We love Miller Brewing', 'Tasteless', 'USA|Canada', 1, NULL, NULL, NULL, NULL),
|
||||
array(99999997, 'Boddington', 'English occasionally get something right', 'A treat', 'United Kingdom', 1, NULL, NULL, NULL, NULL),
|
||||
);
|
||||
$data = [
|
||||
[99999999, 'Heineken', 'Blab Blah Blah Green', 'Green', 'Netherlands|Belgium', 0, 'heineken.jpg', 'Heinekin alt', 'Heinekin title', 'Heinekin description'], // comes with migrate_example project.
|
||||
[99999998, 'Miller Lite', 'We love Miller Brewing', 'Tasteless', 'USA|Canada', 1, NULL, NULL, NULL, NULL],
|
||||
[99999997, 'Boddington', 'English occasionally get something right', 'A treat', 'United Kingdom', 1, NULL, NULL, NULL, NULL],
|
||||
];
|
||||
foreach ($data as $row) {
|
||||
$query->values(array_combine($fields, $row));
|
||||
}
|
||||
$query->execute();
|
||||
}
|
||||
|
||||
// Note that alice has duplicate username. Exercises dedupe_entity plugin.
|
||||
// @TODO duplicate email also.
|
||||
/**
|
||||
* Note that alice has duplicate username. Exercises dedupe_entity plugin.
|
||||
*@TODO duplicate email also.
|
||||
*/
|
||||
function migrate_example_beer_data_account() {
|
||||
$fields = array('status', 'registered', 'username', 'nickname', 'password', 'email', 'sex', 'beers');
|
||||
$fields = ['status', 'registered', 'username', 'nickname', 'password', 'email', 'sex', 'beers'];
|
||||
$query = db_insert('migrate_example_beer_account')
|
||||
->fields($fields);
|
||||
$data = array(
|
||||
array(1, '2010-03-30 10:31:05', 'alice', 'alice in beerland', 'alicepass', 'alice@example.com', '1', '99999999|99999998|99999997'),
|
||||
array(1, '2010-04-04 10:31:05', 'alice', 'alice in aleland', 'alicepass', 'alice2@example.com', '1', '99999999|99999998|99999997'),
|
||||
array(0, '2007-03-15 10:31:05', 'bob', 'rebob', 'bobpass', 'bob@example.com', '0', '99999999|99999997'),
|
||||
array(1, '2004-02-29 10:31:05', 'charlie', 'charlie chocolate', 'mykids', 'charlie@example.com', '0', '99999999|99999998'),
|
||||
);
|
||||
$data = [
|
||||
[1, '2010-03-30 10:31:05', 'alice', 'alice in beerland', 'alicepass', 'alice@example.com', '1', '99999999|99999998|99999997'],
|
||||
[1, '2010-04-04 10:31:05', 'alice', 'alice in aleland', 'alicepass', 'alice2@example.com', '1', '99999999|99999998|99999997'],
|
||||
[0, '2007-03-15 10:31:05', 'bob', 'rebob', 'bobpass', 'bob@example.com', '0', '99999999|99999997'],
|
||||
[1, '2004-02-29 10:31:05', 'charlie', 'charlie chocolate', 'mykids', 'charlie@example.com', '0', '99999999|99999998'],
|
||||
];
|
||||
foreach ($data as $row) {
|
||||
$query->values(array_combine($fields, $row));
|
||||
}
|
||||
@@ -298,16 +300,16 @@ function migrate_example_beer_data_account() {
|
||||
}
|
||||
|
||||
function migrate_example_beer_data_comment() {
|
||||
$fields = array('bid', 'cid_parent', 'subject', 'body', 'name', 'mail', 'aid');
|
||||
$fields = ['bid', 'cid_parent', 'subject', 'body', 'name', 'mail', 'aid'];
|
||||
$query = db_insert('migrate_example_beer_comment')
|
||||
->fields($fields);
|
||||
$data = array(
|
||||
array(99999998, NULL, 'im first', 'full body', 'alice', 'alice@example.com', 0),
|
||||
array(99999998, NULL, 'im second', 'aromatic', 'alice', 'alice@example.com', 0),
|
||||
array(99999999, NULL, 'im parent', 'malty', 'alice', 'alice@example.com', 0),
|
||||
array(99999999, 1, 'im child', 'cold body', 'bob', NULL, 1),
|
||||
array(99999999, 4, 'im grandchild', 'bitter body', 'charlie@example.com', NULL, 1),
|
||||
);
|
||||
$data = [
|
||||
[99999998, NULL, 'im first', 'full body', 'alice', 'alice@example.com', 0],
|
||||
[99999998, NULL, 'im second', 'aromatic', 'alice', 'alice@example.com', 0],
|
||||
[99999999, NULL, 'im parent', 'malty', 'alice', 'alice@example.com', 0],
|
||||
[99999999, 1, 'im child', 'cold body', 'bob', NULL, 1],
|
||||
[99999999, 4, 'im grandchild', 'bitter body', 'charlie@example.com', NULL, 1],
|
||||
];
|
||||
foreach ($data as $row) {
|
||||
$query->values(array_combine($fields, $row));
|
||||
}
|
||||
@@ -315,14 +317,14 @@ function migrate_example_beer_data_comment() {
|
||||
}
|
||||
|
||||
function migrate_example_beer_data_topic() {
|
||||
$fields = array('style', 'details', 'style_parent', 'region', 'hoppiness');
|
||||
$fields = ['style', 'details', 'style_parent', 'region', 'hoppiness'];
|
||||
$query = db_insert('migrate_example_beer_topic')
|
||||
->fields($fields);
|
||||
$data = array(
|
||||
array('ale', 'traditional', NULL, 'Medieval British Isles', 'Medium'),
|
||||
array('red ale', 'colorful', 'ale', NULL, NULL),
|
||||
array('pilsner', 'refreshing', NULL, 'Pilsen, Bohemia (now Czech Republic)', 'Low'),
|
||||
);
|
||||
$data = [
|
||||
['ale', 'traditional', NULL, 'Medieval British Isles', 'Medium'],
|
||||
['red ale', 'colorful', 'ale', NULL, NULL],
|
||||
['pilsner', 'refreshing', NULL, 'Pilsen, Bohemia (now Czech Republic)', 'Low'],
|
||||
];
|
||||
foreach ($data as $row) {
|
||||
$query->values(array_combine($fields, $row));
|
||||
}
|
||||
@@ -330,14 +332,14 @@ function migrate_example_beer_data_topic() {
|
||||
}
|
||||
|
||||
function migrate_example_beer_data_topic_node() {
|
||||
$fields = array('bid', 'style');
|
||||
$fields = ['bid', 'style'];
|
||||
$query = db_insert('migrate_example_beer_topic_node')
|
||||
->fields($fields);
|
||||
$data = array(
|
||||
array(99999999, 'pilsner'),
|
||||
array(99999999, 'red ale'),
|
||||
array(99999998, 'red ale'),
|
||||
);
|
||||
$data = [
|
||||
[99999999, 'pilsner'],
|
||||
[99999999, 'red ale'],
|
||||
[99999998, 'red ale'],
|
||||
];
|
||||
foreach ($data as $row) {
|
||||
$query->values(array_combine($fields, $row));
|
||||
}
|
||||
|
||||
+3
-3
@@ -8,11 +8,11 @@ destination:
|
||||
plugin: entity:comment
|
||||
process:
|
||||
pid:
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
migration: beer_comment
|
||||
source: cid_parent
|
||||
entity_id:
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
migration: beer_node
|
||||
source: bid
|
||||
entity_type:
|
||||
@@ -26,7 +26,7 @@ process:
|
||||
default_value: node_comments
|
||||
subject: subject
|
||||
uid:
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
migration: beer_user
|
||||
source: aid
|
||||
name: name
|
||||
|
||||
+2
-2
@@ -18,9 +18,9 @@ class BeerComment extends SqlBase {
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('migrate_example_beer_comment', 'mec')
|
||||
->fields('mec', ['cid', 'cid_parent', 'name', 'mail', 'aid',
|
||||
->fields('mec', ['cid', 'cid_parent', 'name', 'mail', 'aid',
|
||||
'body', 'bid', 'subject'])
|
||||
->orderBy('cid_parent', 'ASC');
|
||||
->orderBy('cid_parent', 'ASC');
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ class BeerNode extends SqlBase {
|
||||
* below.
|
||||
*/
|
||||
$query = $this->select('migrate_example_beer_node', 'b')
|
||||
->fields('b', ['bid', 'name', 'body', 'excerpt', 'aid',
|
||||
->fields('b', ['bid', 'name', 'body', 'excerpt', 'aid',
|
||||
'countries', 'image', 'image_alt', 'image_title',
|
||||
'image_description']);
|
||||
return $query;
|
||||
@@ -82,7 +82,7 @@ class BeerNode extends SqlBase {
|
||||
* the beer_term migration).
|
||||
*/
|
||||
$terms = $this->select('migrate_example_beer_topic_node', 'bt')
|
||||
->fields('bt', ['style'])
|
||||
->fields('bt', ['style'])
|
||||
->condition('bid', $row->getSourceProperty('bid'))
|
||||
->execute()
|
||||
->fetchCol();
|
||||
|
||||
+3
-3
@@ -50,9 +50,9 @@ class BeerTerm extends SqlBase {
|
||||
* to humans what the field represents. You should always
|
||||
*/
|
||||
$fields = [
|
||||
'style' => $this->t('Account ID'),
|
||||
'details' => $this->t('Blocked/Allowed'),
|
||||
'style_parent' => $this->t('Registered date'),
|
||||
'style' => $this->t('Beer style'),
|
||||
'details' => $this->t('Style details'),
|
||||
'style_parent' => $this->t('Parent style'),
|
||||
// These values are not currently migrated - it's OK to skip fields you
|
||||
// don't need.
|
||||
'region' => $this->t('Region the style is associated with'),
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ process:
|
||||
region: migrate_example_wine_regions
|
||||
variety: migrate_example_wine_varieties
|
||||
parent:
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
migration: wine_terms
|
||||
source: category_parent
|
||||
weight: ordering
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ process:
|
||||
name: category_name
|
||||
description: category_details
|
||||
parent:
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
migration: wine_terms
|
||||
source: category_parent
|
||||
destination:
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ process:
|
||||
name: category_name
|
||||
description: category_details
|
||||
parent:
|
||||
plugin: migration
|
||||
plugin: migration_lookup
|
||||
migration: wine_terms
|
||||
source: category_parent
|
||||
field_variety_attributes: category_attributes
|
||||
|
||||
+3
-3
@@ -8,8 +8,8 @@ dependencies:
|
||||
- migrate_plus:migrate_example_advanced_setup
|
||||
- migrate_plus:migrate_plus
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-05-10
|
||||
version: '8.x-4.0-beta1'
|
||||
# Information added by Drupal.org packaging script on 2017-12-12
|
||||
version: '8.x-4.0-beta2'
|
||||
core: '8.x'
|
||||
project: 'migrate_plus'
|
||||
datestamp: 1494450189
|
||||
datestamp: 1513088305
|
||||
|
||||
+3
-3
@@ -11,8 +11,8 @@ dependencies:
|
||||
- drupal:taxonomy
|
||||
- drupal:rest
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-05-10
|
||||
version: '8.x-4.0-beta1'
|
||||
# Information added by Drupal.org packaging script on 2017-12-12
|
||||
version: '8.x-4.0-beta2'
|
||||
core: '8.x'
|
||||
project: 'migrate_plus'
|
||||
datestamp: 1494450189
|
||||
datestamp: 1513088305
|
||||
|
||||
+330
-329
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -31,22 +31,22 @@ class VarietyItems extends ResourceBase {
|
||||
$varieties = [
|
||||
'retsina' => [
|
||||
'name' => 'Retsina',
|
||||
'parent' => 1, // categoryid for 'white'.
|
||||
'parent' => 1, // categoryid for 'white'.
|
||||
'details' => 'Greek',
|
||||
],
|
||||
'trebbiano' => [
|
||||
'name' => 'Trebbiano',
|
||||
'parent' => 1, // categoryid for 'white'.
|
||||
'parent' => 1, // categoryid for 'white'.
|
||||
'details' => 'Italian',
|
||||
],
|
||||
'valpolicella' => [
|
||||
'name' => 'Valpolicella',
|
||||
'parent' => 3, // categoryid for 'red'.
|
||||
'parent' => 3, // categoryid for 'red'.
|
||||
'details' => 'Italian Venoto region',
|
||||
],
|
||||
'bardolino' => [
|
||||
'name' => 'Bardolino',
|
||||
'parent' => 3, // categoryid for 'red'.
|
||||
'parent' => 3, // categoryid for 'red'.
|
||||
'details' => 'Italian Venoto region',
|
||||
],
|
||||
];
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@ class VarietyMultiFiles extends ResourceBase {
|
||||
if (strtolower($type) != 'white') {
|
||||
$data['variety'][] = [
|
||||
'name' => 'Amarone',
|
||||
'parent' => 3, // categoryid for 'red'.
|
||||
'parent' => 3, // categoryid for 'red'.
|
||||
'details' => 'Italian Venoto region',
|
||||
'attributes' => [
|
||||
'rich',
|
||||
@@ -41,7 +41,7 @@ class VarietyMultiFiles extends ResourceBase {
|
||||
];
|
||||
$data['variety'][] = [
|
||||
'name' => 'Barbaresco',
|
||||
'parent' => 3, // categoryid for 'red'.
|
||||
'parent' => 3, // categoryid for 'red'.
|
||||
'details' => 'Italian Piedmont region',
|
||||
'attributes' => [
|
||||
'smoky',
|
||||
@@ -52,13 +52,13 @@ class VarietyMultiFiles extends ResourceBase {
|
||||
if (strtolower($type) != 'red') {
|
||||
$data['variety'][] = [
|
||||
'name' => 'Kir',
|
||||
'parent' => 1, // categoryid for 'white'.
|
||||
'parent' => 1, // categoryid for 'white'.
|
||||
'details' => 'French Burgundy region',
|
||||
'attributes' => [],
|
||||
];
|
||||
$data['variety'][] = [
|
||||
'name' => 'Pinot Grigio',
|
||||
'parent' => 1, // categoryid for 'white'.
|
||||
'parent' => 1, // categoryid for 'white'.
|
||||
'details' => 'From the northeast of Italy',
|
||||
'attributes' => [
|
||||
'fruity',
|
||||
|
||||
@@ -6,8 +6,8 @@ package: Migration
|
||||
dependencies:
|
||||
- drupal:migrate (>=8.3)
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-05-10
|
||||
version: '8.x-4.0-beta1'
|
||||
# Information added by Drupal.org packaging script on 2017-12-12
|
||||
version: '8.x-4.0-beta2'
|
||||
core: '8.x'
|
||||
project: 'migrate_plus'
|
||||
datestamp: 1494450189
|
||||
datestamp: 1513088305
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ruleset name="drupal_core">
|
||||
<description>PHP CodeSniffer configuration</description>
|
||||
<file>.</file>
|
||||
<arg name="extensions" value="install,module,php"/>
|
||||
|
||||
<!--Exclude third party code.-->
|
||||
<exclude-pattern>./vendor/*</exclude-pattern>
|
||||
|
||||
<!-- Only include specific sniffs that pass. This ensures that, if new sniffs are added, HEAD does not fail.-->
|
||||
<!-- Drupal sniffs -->
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/ClassCreateInstanceSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/ClassDeclarationSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/FullyQualifiedNamespaceSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/UnusedUseStatementSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/UseLeadingBackslashSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/CSS/ColourDefinitionSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/ClassCommentSniff.php">
|
||||
<exclude name="Drupal.Commenting.ClassComment.Missing"/>
|
||||
</rule>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentSniff.php">
|
||||
<!-- Sniff for these errors: SpacingAfterTagGroup, WrongEnd, SpacingBetween,
|
||||
ContentAfterOpen, SpacingBeforeShort, TagValueIndent, ShortStartSpace,
|
||||
SpacingAfter -->
|
||||
<exclude name="Drupal.Commenting.DocComment.LongNotCapital"/>
|
||||
<!-- ParamNotFirst still not decided for PHPUnit-based tests.
|
||||
@see https://www.drupal.org/node/2253915 -->
|
||||
<exclude name="Drupal.Commenting.DocComment.ParamNotFirst"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.SpacingBeforeTags"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.LongFullStop"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.ShortNotCapital"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.ShortFullStop"/>
|
||||
<!-- TagsNotGrouped and ParamGroup have false-positives.
|
||||
@see https://www.drupal.org/node/2060925 -->
|
||||
<exclude name="Drupal.Commenting.DocComment.TagsNotGrouped"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.ParamGroup"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.ShortSingleLine"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.TagGroupSpacing"/>
|
||||
<exclude name="Drupal.Commenting.DocComment.MissingShort"/>
|
||||
</rule>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/DocCommentStarSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/FileCommentSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php">
|
||||
<exclude name="Drupal.Commenting.FunctionComment.IncorrectTypeHint"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.InvalidNoReturn"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.InvalidReturnNotVoid"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.InvalidTypeHint"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.Missing"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.MissingFile"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.MissingParamComment"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.MissingParamType"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.MissingReturnComment"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.MissingReturnType"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.ParamCommentFullStop"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.ParamCommentIndentation"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.ParamMissingDefinition"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.ParamNameNoMatch"/>
|
||||
<exclude name="Drupal.Commenting.FunctionComment.TypeHintMissing"/>
|
||||
</rule>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/ControlStructures/ElseIfSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/ControlStructures/ControlSignatureSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Files/TxtFileLineLengthSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Formatting/MultiLineAssignmentSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Formatting/SpaceInlineIfSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Formatting/SpaceUnaryOperatorSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Functions/DiscouragedFunctionsSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Functions/FunctionDeclarationSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/AutoAddedKeysSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/ClassFilesSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/RequiredSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/NamingConventions/ValidVariableNameSniff.php">
|
||||
<!-- Sniff for: LowerStart -->
|
||||
<exclude name="Drupal.NamingConventions.ValidVariableName.LowerCamelName"/>
|
||||
</rule>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Scope/MethodScopeSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/EmptyInstallSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/FunctionTSniff.php">
|
||||
<exclude name="Drupal.Semantics.FunctionT.BackslashSingleQuote"/>
|
||||
<exclude name="Drupal.Semantics.FunctionT.NotLiteralString"/>
|
||||
<exclude name="Drupal.Semantics.FunctionT.ConcatString"/>
|
||||
</rule>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/FunctionWatchdogSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/InstallHooksSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/LStringTranslatableSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/PregSecuritySniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/TInHookMenuSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/TInHookSchemaSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/CommaSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/OpenTagNewlineSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/OperatorSpacingSniff.php"/>
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/ScopeIndentSniff.php"/>
|
||||
|
||||
<!-- Drupal Practice sniffs -->
|
||||
<rule ref="vendor/drupal/coder/coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php"/>
|
||||
|
||||
<!-- Generic sniffs -->
|
||||
<rule ref="Generic.Files.LineEndings"/>
|
||||
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
|
||||
<rule ref="Generic.NamingConventions.ConstructorName" />
|
||||
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
|
||||
<rule ref="Generic.PHP.DeprecatedFunctions"/>
|
||||
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
|
||||
<rule ref="Generic.PHP.UpperCaseConstant"/>
|
||||
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
|
||||
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
|
||||
|
||||
<!-- PSR-2 sniffs -->
|
||||
<rule ref="PSR2.Classes.PropertyDeclaration">
|
||||
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
|
||||
</rule>
|
||||
|
||||
<!-- Squiz sniffs -->
|
||||
<rule ref="Squiz.Strings.ConcatenationSpacing">
|
||||
<properties>
|
||||
<property name="spacing" value="1"/>
|
||||
<property name="ignoreNewlines" value="true"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
</ruleset>
|
||||
@@ -64,7 +64,7 @@ class MigratePrepareRowEvent extends Event {
|
||||
/**
|
||||
* Gets the source plugin.
|
||||
*
|
||||
* @return \Drupal\migrate\Plugin\MigrateSourceInterface $source
|
||||
* @return \Drupal\migrate\Plugin\MigrateSourceInterface
|
||||
* The source plugin firing the event.
|
||||
*/
|
||||
public function getSource() {
|
||||
|
||||
+1
@@ -125,4 +125,5 @@ class Table extends DestinationBase implements ContainerFactoryPluginInterface {
|
||||
}
|
||||
$delete->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+51
-11
@@ -51,34 +51,74 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
*/
|
||||
class EntityLookup extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/** @var \Drupal\Core\Entity\EntityManagerInterface */
|
||||
/**
|
||||
* The entity manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/** @var \Drupal\migrate\Plugin\MigrationInterface */
|
||||
/**
|
||||
* The migration.
|
||||
*
|
||||
* @var \Drupal\migrate\Plugin\MigrationInterface
|
||||
*/
|
||||
protected $migration;
|
||||
|
||||
/** @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface */
|
||||
/**
|
||||
* The selection plugin.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManagerInterface
|
||||
*/
|
||||
protected $selectionPluginManager;
|
||||
|
||||
/** @var string */
|
||||
/**
|
||||
* The destination type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $destinationEntityType;
|
||||
|
||||
/** @var string|bool */
|
||||
/**
|
||||
* The destination bundle.
|
||||
*
|
||||
* @var string|bool
|
||||
*/
|
||||
protected $destinationBundleKey;
|
||||
|
||||
/** @var string */
|
||||
/**
|
||||
* The lookup value's key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $lookupValueKey;
|
||||
|
||||
/** @var string */
|
||||
/**
|
||||
* The lookup bundle's key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $lookupBundleKey;
|
||||
|
||||
/** @var string */
|
||||
/**
|
||||
* The lookup bundle.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $lookupBundle;
|
||||
|
||||
/** @var string */
|
||||
/**
|
||||
* The lookup entity type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $lookupEntityType;
|
||||
|
||||
/** @var string */
|
||||
/**
|
||||
* The destination property or field.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $destinationProperty;
|
||||
|
||||
/**
|
||||
@@ -178,7 +218,7 @@ class EntityLookup extends ProcessPluginBase implements ContainerFactoryPluginIn
|
||||
|
||||
default:
|
||||
throw new MigrateException('Destination field type ' .
|
||||
$fieldConfig->getType(). 'is not a recognized reference type.');
|
||||
$fieldConfig->getType() . 'is not a recognized reference type.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -39,9 +39,9 @@ class FileBlob extends ProcessPluginBase implements ContainerFactoryPluginInterf
|
||||
* The file system service.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, FileSystemInterface $file_system) {
|
||||
$configuration += array(
|
||||
$configuration += [
|
||||
'reuse' => FALSE,
|
||||
);
|
||||
];
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->fileSystem = $file_system;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ use Drupal\migrate\Row;
|
||||
* source: field_section
|
||||
* process:
|
||||
* target_id:
|
||||
* plugin: migration
|
||||
* plugin: migration_lookup
|
||||
* migration: field_collection_field_section_to_paragraph
|
||||
* source: value
|
||||
* temp_images:
|
||||
@@ -35,7 +35,7 @@ use Drupal\migrate\Row;
|
||||
* source: field_image
|
||||
* process
|
||||
* target_id:
|
||||
* plugin: migration
|
||||
* plugin: migration_lookup
|
||||
* migration: image_entities_to_paragraph
|
||||
* source: fid
|
||||
* paragraphs_field:
|
||||
@@ -56,7 +56,7 @@ class Merge extends ProcessPluginBase {
|
||||
throw new MigrateException('Input should be an array.');
|
||||
}
|
||||
$new_value = [];
|
||||
foreach($value as $item) {
|
||||
foreach ($value as $item) {
|
||||
if (!is_array($item)) {
|
||||
throw new MigrateException('One of the items is not an array that can be merged.');
|
||||
}
|
||||
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\migrate_plus\Plugin\migrate\process;
|
||||
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Uses the str_replace() method on a source string.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "str_replace"
|
||||
* )
|
||||
*
|
||||
* To do a simple hardcoded string replace use the following:
|
||||
*
|
||||
* @code
|
||||
* field_text:
|
||||
* plugin: str_replace
|
||||
* source: text
|
||||
* search: foo
|
||||
* replace: bar
|
||||
* @endcode
|
||||
*
|
||||
* If the value of text is "vero eos et accusam et justo vero"
|
||||
* in source, foo is "et" in search and bar is "that" in replace,
|
||||
* field_text will be "vero eos that accusam that justo vero".
|
||||
*
|
||||
* Case insensitive searches can be achieved using the following:
|
||||
* @code
|
||||
* field_text:
|
||||
* plugin: str_replace
|
||||
* case_insensitive: true
|
||||
* source: text
|
||||
* search: foo
|
||||
* replace: bar
|
||||
* @endcode
|
||||
*
|
||||
* If the value of text is "VERO eos et accusam et justo vero"
|
||||
* in source, foo is "vero" in search and bar is "that" in replace,
|
||||
* field_text will be "that eos et accusam et justo that".
|
||||
*
|
||||
* Also regular expressions can be matched using:
|
||||
* @code
|
||||
* field_text:
|
||||
* plugin: str_replace
|
||||
* regex: true
|
||||
* source: text
|
||||
* search: foo
|
||||
* replace: bar
|
||||
* @endcode
|
||||
*
|
||||
* If the value of text is "vero eos et 123 accusam et justo 123 duo"
|
||||
* in source, foo is "/[0-9]{3}/" in search and bar is "the" in replace,
|
||||
* field_text will be "vero eos et the accusam et justo the duo".
|
||||
*
|
||||
* All the rules for
|
||||
* @link http://php.net/manual/function.str-replace.php str_replace @endlink
|
||||
* apply. This means that you can provide arrays as values.
|
||||
*/
|
||||
class StrReplace extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* Flag indicating whether there are multiple values.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $multiple;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
if (!isset($this->configuration['search'])) {
|
||||
throw new MigrateException('"search" must be configured.');
|
||||
}
|
||||
if (!isset($this->configuration['replace'])) {
|
||||
throw new MigrateException('"replace" must be configured.');
|
||||
}
|
||||
$this->multiple = is_array($value);
|
||||
$this->configuration += [
|
||||
'case_insensitive' => FALSE,
|
||||
'regex' => FALSE,
|
||||
];
|
||||
$function = "str_replace";
|
||||
if ($this->configuration['case_insensitive']) {
|
||||
$function = 'str_ireplace';
|
||||
}
|
||||
if ($this->configuration['regex']) {
|
||||
$function = 'preg_replace';
|
||||
}
|
||||
return $function($this->configuration['search'], $this->configuration['replace'], $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function multiple() {
|
||||
return $this->multiple;
|
||||
}
|
||||
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\migrate_plus\Plugin\migrate\process;
|
||||
|
||||
use Drupal\Component\Transliteration\TransliterationInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Transliterates text from Unicode to US-ASCII
|
||||
*
|
||||
* The transliteration process plugin takes the source value and runs it through
|
||||
* the transliteration service. Letters will have language decorations and
|
||||
* accents removed.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* @code
|
||||
* process:
|
||||
* bar:
|
||||
* plugin: transliteration
|
||||
* source: foo
|
||||
* @endcode
|
||||
*
|
||||
* If the value of foo in the source is 'áéí!' then the destination value of bar
|
||||
* will be 'aei!'.
|
||||
*
|
||||
* @see \Drupal\migrate\Plugin\MigrateProcessInterface
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "transliteration"
|
||||
* )
|
||||
*/
|
||||
class Transliteration extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The transliteration service.
|
||||
*
|
||||
* @var \Drupal\Component\Transliteration\TransliterationInterface
|
||||
*/
|
||||
protected $transliteration;
|
||||
|
||||
/**
|
||||
* Constructs a Transliteration plugin.
|
||||
*
|
||||
* @param array $configuration
|
||||
* The plugin configuration.
|
||||
* @param string $plugin_id
|
||||
* The plugin ID.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin definition.
|
||||
* @param \Drupal\Component\Transliteration\TransliterationInterface $transliteration
|
||||
* The transliteration service.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, TransliterationInterface $transliteration) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->transliteration = $transliteration;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('transliteration')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
return $this->transliteration->transliterate($value, LanguageInterface::LANGCODE_DEFAULT, '_');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Drupal\migrate_plus\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate_plus\DataParserPluginInterface;
|
||||
|
||||
/**
|
||||
* Source plugin for retrieving data via URLs.
|
||||
@@ -38,15 +37,6 @@ class Url extends SourcePluginExtension {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
||||
|
||||
$this->sourceUrls = $configuration['urls'];
|
||||
|
||||
// Set a default Accept header.
|
||||
/* $this->headers = array_merge(['Accept' => 'application/json'],
|
||||
$configuration['headers'] ?: []);*/
|
||||
|
||||
// See if this is a paged response with next links. If so, add to the source_urls array.
|
||||
/* foreach ( (array) $configuration['urls'] as $url) {
|
||||
$this->sourceUrls += $this->getNextLinks($url);
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,55 +75,4 @@ class Url extends SourcePluginExtension {
|
||||
return $this->getDataParserPlugin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect an array of next links from a paged response.
|
||||
*/
|
||||
/* protected function getNextLinks($url) {
|
||||
$urls = array();
|
||||
$more = TRUE;
|
||||
while ($more == TRUE) {
|
||||
$response = $this->dataParserPlugin->getDataFetcher()->getResponse($url);
|
||||
if ($url = $this->getNextFromHeaders($response)) {
|
||||
$urls[] = $url;
|
||||
}
|
||||
elseif ($url = $this->getNextFromLinks($response)) {
|
||||
$urls[] = $url;
|
||||
}
|
||||
else {
|
||||
$more = FALSE;
|
||||
}
|
||||
}
|
||||
return $urls;
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* See if the next link is in a 'links' group in the response.
|
||||
*
|
||||
* @param \Psr\Http\Message\ResponseInterface $response
|
||||
*/
|
||||
/* protected function getNextFromLinks(ResponseInterface $response) {
|
||||
$body = json_decode($response->getBody(), TRUE);
|
||||
if (!empty($body['links']) && array_key_exists('next', $body['links'])) {
|
||||
return $body['links']['next'];
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* See if the next link is in the header.
|
||||
*
|
||||
* @param \Psr\Http\Message\ResponseInterface $response
|
||||
*/
|
||||
/* protected function getNextFromHeaders(ResponseInterface $response) {
|
||||
$headers = $response->getHeader('Link');
|
||||
foreach ($headers as $header) {
|
||||
$matches = array();
|
||||
preg_match('/^<(.*)>; rel="next"$/', $header, $matches);
|
||||
if (!empty($matches) && !empty($matches[1])) {
|
||||
return $matches[1];
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ class OAuth2 extends AuthenticationPluginBase implements ContainerFactoryPluginI
|
||||
public function getAuthenticationOptions() {
|
||||
$handlerStack = HandlerStack::create();
|
||||
$client = new Client([
|
||||
'handler'=> $handlerStack,
|
||||
'handler' => $handlerStack,
|
||||
'base_uri' => $this->configuration['base_uri'],
|
||||
'auth' => 'oauth2',
|
||||
]);
|
||||
@@ -55,7 +55,7 @@ class OAuth2 extends AuthenticationPluginBase implements ContainerFactoryPluginI
|
||||
break;
|
||||
default:
|
||||
throw new MigrateException("Unrecognized grant_type {$this->configuration['grant_type']}.");
|
||||
break;
|
||||
break;
|
||||
}
|
||||
$middleware = new OAuthMiddleware($client, $grant_type);
|
||||
|
||||
|
||||
+4
-4
@@ -34,10 +34,10 @@ class File extends DataFetcherPluginBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getResponse($url) {
|
||||
$response = file_get_contents($url);
|
||||
if ($response === FALSE) {
|
||||
throw new MigrateException('file parser plugin: could not retrieve data from ' . $url);
|
||||
}
|
||||
$response = file_get_contents($url);
|
||||
if ($response === FALSE) {
|
||||
throw new MigrateException('file parser plugin: could not retrieve data from ' . $url);
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
+16
-1
@@ -10,6 +10,19 @@ use GuzzleHttp\Exception\RequestException;
|
||||
/**
|
||||
* Retrieve data over an HTTP connection for migration.
|
||||
*
|
||||
* * Example:
|
||||
*
|
||||
* @code
|
||||
* source:
|
||||
* plugin: url
|
||||
* data_fetcher_plugin: http
|
||||
* headers:
|
||||
* Accept: application/json
|
||||
* User-Agent: Internet Explorer 6
|
||||
* Authorization-Key: secret
|
||||
* Arbitrary-Header: foobarbaz
|
||||
* @endcode
|
||||
*
|
||||
* @DataFetcher(
|
||||
* id = "http",
|
||||
* title = @Translation("HTTP")
|
||||
@@ -44,6 +57,8 @@ class Http extends DataFetcherPluginBase implements ContainerFactoryPluginInterf
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->httpClient = \Drupal::httpClient();
|
||||
|
||||
$this->setRequestHeaders($configuration['headers']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +103,7 @@ class Http extends DataFetcherPluginBase implements ContainerFactoryPluginInterf
|
||||
}
|
||||
}
|
||||
catch (RequestException $e) {
|
||||
throw new MigrateException('Error message: ' . $e->getMessage() . ' at ' . $url .'.');
|
||||
throw new MigrateException('Error message: ' . $e->getMessage() . ' at ' . $url . '.');
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ class Json extends DataParserPluginBase implements ContainerFactoryPluginInterfa
|
||||
// valid utf8 - see http://php.net/manual/en/function.json-decode.php#86997.
|
||||
if (is_null($source_data)) {
|
||||
$utf8response = utf8_encode($response);
|
||||
$source_data = json_decode($utf8response);
|
||||
$source_data = json_decode($utf8response, TRUE);
|
||||
}
|
||||
|
||||
// Backwards-compatibility for depth selection.
|
||||
|
||||
+8
-1
@@ -3,6 +3,7 @@
|
||||
namespace Drupal\migrate_plus\Plugin\migrate_plus\data_parser;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\migrate_plus\DataParserPluginBase;
|
||||
|
||||
@@ -46,8 +47,14 @@ class Soap extends DataParserPluginBase implements ContainerFactoryPluginInterfa
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws \Drupal\migrate\Exception\RequirementsException
|
||||
* If PHP SOAP extension is not installed.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
|
||||
if (!class_exists('\SoapClient')) {
|
||||
throw new RequirementsException('The PHP SOAP extension is not installed');
|
||||
}
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->function = $configuration['function'];
|
||||
$this->parameters = $configuration['parameters'];
|
||||
@@ -63,7 +70,7 @@ class Soap extends DataParserPluginBase implements ContainerFactoryPluginInterfa
|
||||
* If we can't resolve the SOAP function or its response property.
|
||||
*/
|
||||
protected function openSourceUrl($url) {
|
||||
// Will throw SoapFault if there's
|
||||
// Will throw SoapFault if there's an error in a SOAP call.
|
||||
$client = new \SoapClient($url);
|
||||
// Determine the response property name.
|
||||
$function_found = FALSE;
|
||||
|
||||
+1
-4
@@ -47,10 +47,7 @@ trait XmlTrait {
|
||||
}
|
||||
|
||||
return t(
|
||||
"@libxmlerrorcodename @libxmlerrorcode: @libxmlerrormessage\n" .
|
||||
"Line: @libxmlerrorline\n" .
|
||||
"Column: @libxmlerrorcolumn\n" .
|
||||
"File: @libxmlerrorfile",
|
||||
"@libxmlerrorcodename @libxmlerrorcode: @libxmlerrormessage\nLine: @libxmlerrorline\nColumn: @libxmlerrorcolumn\nFile: @libxmlerrorfile",
|
||||
[
|
||||
'@libxmlerrorcodename' => $error_code_name,
|
||||
'@libxmlerrorcode' => $error->code,
|
||||
|
||||
+1
-2
@@ -4,7 +4,6 @@ namespace Drupal\Tests\migrate_plus\Kernel;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\Tests\migrate\Kernel\MigrateTestBase;
|
||||
|
||||
/**
|
||||
@@ -110,7 +109,7 @@ class MigrateTableTest extends MigrateTestBase {
|
||||
public function testTableRollback() {
|
||||
$this->testTableDestination();
|
||||
|
||||
/** @var MigrationInterface $migration */
|
||||
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
|
||||
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($this->getTableDestinationMigration());
|
||||
$executable = new MigrateExecutable($migration, $this);
|
||||
$executable->import();
|
||||
|
||||
+6
-7
@@ -5,7 +5,6 @@ namespace Drupal\Tests\migrate_plus\Kernel;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\migrate_plus\Entity\Migration;
|
||||
use Drupal\migrate_plus\Entity\MigrationGroup;
|
||||
use Drupal\migrate_plus\Entity\MigrationGroupInterface;
|
||||
|
||||
/**
|
||||
* Test migration groups.
|
||||
@@ -22,14 +21,14 @@ class MigrationGroupTest extends KernelTestBase {
|
||||
public function testConfigurationMerge() {
|
||||
$group_id = 'test_group';
|
||||
|
||||
/** @var MigrationGroupInterface $migration_group */
|
||||
/** @var \Drupal\migrate_plus\Entity\MigrationGroupInterface $migration_group */
|
||||
$group_configuration = [
|
||||
'id' => $group_id,
|
||||
'shared_configuration' => [
|
||||
'migration_tags' => ['Drupal 6'], // In migration, so will be overridden.
|
||||
'source' => [
|
||||
'constants' => [
|
||||
'type' => 'image', // Not in migration, so will be added.
|
||||
'type' => 'image', // Not in migration, so will be added.
|
||||
'cardinality' => '1', // In migration, so will be overridden.
|
||||
],
|
||||
],
|
||||
@@ -53,10 +52,10 @@ class MigrationGroupTest extends KernelTestBase {
|
||||
'migration_dependencies' => [],
|
||||
]);
|
||||
$migration->set('source', [
|
||||
'plugin' => 'empty', // Not in group, persists.
|
||||
'plugin' => 'empty', // Not in group, persists.
|
||||
'constants' => [
|
||||
'entity_type' => 'user', // Not in group, persists.
|
||||
'cardinality' => '3', // Overrides group.
|
||||
'entity_type' => 'user', // Not in group, persists.
|
||||
'cardinality' => '3', // Overrides group.
|
||||
],
|
||||
]);
|
||||
$migration->save();
|
||||
@@ -88,7 +87,7 @@ class MigrationGroupTest extends KernelTestBase {
|
||||
* Test that deleting a group deletes its migrations.
|
||||
*/
|
||||
public function testDelete() {
|
||||
/** @var MigrationGroupInterface $migration_group */
|
||||
/** @var \Drupal\migrate_plus\Entity\MigrationGroupInterface $migration_group */
|
||||
$group_configuration = [
|
||||
'id' => 'test_group',
|
||||
];
|
||||
|
||||
+2
-3
@@ -8,7 +8,6 @@ use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate\MigrateMessageInterface;
|
||||
use Drupal\migrate\Plugin\Migration;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
||||
@@ -128,7 +127,7 @@ class EntityGenerateTest extends KernelTestBase implements MigrateMessageInterfa
|
||||
$entity->save();
|
||||
}
|
||||
|
||||
/** @var Migration $migration */
|
||||
/** @var \Drupal\migrate\Plugin\Migration $migration */
|
||||
$migration = $this->migrationPluginManager->createStubMigration($definition);
|
||||
/** @var EntityStorageBase $storage */
|
||||
$storage = $this->readAttribute($migration->getDestinationPlugin(), 'storage');
|
||||
@@ -153,7 +152,7 @@ class EntityGenerateTest extends KernelTestBase implements MigrateMessageInterfa
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->assertNotEmpty($entity, 'Entity with label ' . $row[$property] .' is empty');
|
||||
$this->assertNotEmpty($entity, 'Entity with label ' . $row[$property] . ' is empty');
|
||||
$this->assertEquals($row[$property], $entity->label());
|
||||
}
|
||||
}
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_plus\Kernel\Plugin\migrate_plus\data_fetcher;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Drupal\migrate_plus\Plugin\migrate_plus\data_fetcher\Http;
|
||||
use Drupal\Tests\Core\Test\KernelTestBaseTest;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* Class HttpTest
|
||||
*
|
||||
* @group migrate_plus
|
||||
* @package Drupal\Tests\migrate_plus\Unit\migrate_plus\data_fetcher
|
||||
*/
|
||||
class HttpTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* Test http headers option.
|
||||
*/
|
||||
function testHttpHeaders() {
|
||||
$expected = [
|
||||
'Accept' => 'application/json',
|
||||
'User-Agent' => 'Internet Explorer 6',
|
||||
'Authorization-Key' => 'secret',
|
||||
'Arbitrary-Header' => 'foobarbaz'
|
||||
];
|
||||
|
||||
$configuration = [
|
||||
'headers' => [
|
||||
'Accept' => 'application/json',
|
||||
'User-Agent' => 'Internet Explorer 6',
|
||||
'Authorization-Key' => 'secret',
|
||||
'Arbitrary-Header' => 'foobarbaz'
|
||||
]
|
||||
];
|
||||
|
||||
$http = new Http($configuration, 'http', []);
|
||||
|
||||
$this->assertEquals($expected, $http->getRequestHeaders());
|
||||
}
|
||||
}
|
||||
+8
-5
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Drupal\Tests\migrate_plus\Unit\process;
|
||||
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\migrate\MigrateSkipProcessException;
|
||||
use Drupal\migrate\MigrateSkipRowException;
|
||||
use Drupal\migrate_plus\Plugin\migrate\process\SkipOnValue;
|
||||
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
|
||||
|
||||
@@ -15,22 +18,22 @@ class SkipOnValueTest extends MigrateProcessTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::process
|
||||
* @expectedException \Drupal\migrate\MigrateSkipProcessException
|
||||
*/
|
||||
public function testProcessSkipsOnValue() {
|
||||
$configuration['method'] = 'process';
|
||||
$configuration['value'] = 86;
|
||||
$this->setExpectedException(MigrateSkipProcessException::class);
|
||||
(new SkipOnValue($configuration, 'skip_on_value', []))
|
||||
->transform('86', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::process
|
||||
* @expectedException \Drupal\migrate\MigrateSkipProcessException
|
||||
*/
|
||||
public function testProcessSkipsOnMultipleValue() {
|
||||
$configuration['method'] = 'process';
|
||||
$configuration['value'] = [1, 1, 2, 3, 5, 8];
|
||||
$this->setExpectedException(MigrateSkipProcessException::class);
|
||||
(new SkipOnValue($configuration, 'skip_on_value', []))
|
||||
->transform('5', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
}
|
||||
@@ -64,11 +67,11 @@ class SkipOnValueTest extends MigrateProcessTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::row
|
||||
* @expectedException \Drupal\migrate\MigrateSkipRowException
|
||||
*/
|
||||
public function testRowSkipsOnValue() {
|
||||
$configuration['method'] = 'row';
|
||||
$configuration['value'] = 86;
|
||||
$this->setExpectedException(MigrateSkipRowException::class);
|
||||
(new SkipOnValue($configuration, 'skip_on_value', []))
|
||||
->transform('86', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
}
|
||||
@@ -91,20 +94,20 @@ class SkipOnValueTest extends MigrateProcessTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::row
|
||||
* @expectedException \Drupal\migrate\MigrateException
|
||||
*/
|
||||
public function testRequiredRowConfiguration() {
|
||||
$configuration['method'] = 'row';
|
||||
$this->setExpectedException(MigrateException::class);
|
||||
(new SkipOnValue($configuration, 'skip_on_value', []))
|
||||
->transform('sourcevalue', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::process
|
||||
* @expectedException \Drupal\migrate\MigrateException
|
||||
*/
|
||||
public function testRequiredProcessConfiguration() {
|
||||
$configuration['method'] = 'process';
|
||||
$this->setExpectedException(MigrateException::class);
|
||||
(new SkipOnValue($configuration, 'skip_on_value', []))
|
||||
->transform('sourcevalue', $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
}
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_plus\Unit\process;
|
||||
|
||||
use Drupal\migrate_plus\Plugin\migrate\process\StrReplace;
|
||||
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
|
||||
|
||||
|
||||
/**
|
||||
* Tests the str replace process plugin.
|
||||
*
|
||||
* @group migrate
|
||||
* @coversDefaultClass \Drupal\migrate_plus\Plugin\migrate\process\StrReplace
|
||||
*/
|
||||
class StrReplaceTest extends MigrateProcessTestCase {
|
||||
|
||||
/**
|
||||
* Test for a simple str_replace string.
|
||||
*/
|
||||
public function testStrReplace() {
|
||||
$value = 'vero eos et accusam et justo vero';
|
||||
$configuration['search'] = 'et';
|
||||
$configuration['replace'] = 'that';
|
||||
$plugin = new StrReplace($configuration, 'str_replace', []);
|
||||
$actual = $plugin->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->assertSame('vero eos that accusam that justo vero', $actual);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for case insensitive searches.
|
||||
*/
|
||||
public function testStrIreplace() {
|
||||
$value = 'VERO eos et accusam et justo vero';
|
||||
$configuration['search'] = 'vero';
|
||||
$configuration['replace'] = 'that';
|
||||
$configuration['case_insensitive'] = TRUE;
|
||||
$plugin = new StrReplace($configuration, 'str_replace', []);
|
||||
$actual = $plugin->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->assertSame('that eos et accusam et justo that', $actual);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for regular expressions.
|
||||
*/
|
||||
public function testPregReplace() {
|
||||
$value = 'vero eos et 123 accusam et justo 123 duo';
|
||||
$configuration['search'] = '/[0-9]{3}/';
|
||||
$configuration['replace'] = 'the';
|
||||
$configuration['regex'] = TRUE;
|
||||
$plugin = new StrReplace($configuration, 'str_replace', []);
|
||||
$actual = $plugin->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->assertSame('vero eos et the accusam et justo the duo', $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for MigrateException for "search" configuration.
|
||||
*
|
||||
*/
|
||||
public function testSearchMigrateException() {
|
||||
$value = 'vero eos et accusam et justo vero';
|
||||
$configuration['replace'] = 'that';
|
||||
$plugin = new StrReplace($configuration, 'str_replace', []);
|
||||
$this->setExpectedException('\Drupal\migrate\MigrateException', '"search" must be configured.');
|
||||
$plugin->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for MigrateException for "replace" configuration.
|
||||
*/
|
||||
public function testReplaceMigrateException() {
|
||||
$value = 'vero eos et accusam et justo vero';
|
||||
$configuration['search'] = 'et';
|
||||
$plugin = new StrReplace($configuration, 'str_replace', []);
|
||||
$this->setExpectedException('\Drupal\migrate\MigrateException', '"replace" must be configured.');
|
||||
$plugin->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for multiple.
|
||||
*/
|
||||
public function testIsMultiple() {
|
||||
$value = [
|
||||
'vero eos et accusam et justo vero',
|
||||
'et eos vero accusam vero justo et',
|
||||
];
|
||||
|
||||
$expected = [
|
||||
'vero eos that accusam that justo vero',
|
||||
'that eos vero accusam vero justo that',
|
||||
];
|
||||
$configuration['search'] = 'et';
|
||||
$configuration['replace'] = 'that';
|
||||
$plugin = new StrReplace($configuration, 'str_replace', []);
|
||||
$actual = $plugin->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->assertArrayEquals($expected, $actual);
|
||||
|
||||
$this->assertTrue($plugin->multiple());
|
||||
}
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_plus\Unit\process;
|
||||
|
||||
use Drupal\Component\Transliteration\PhpTransliteration;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_plus\Plugin\migrate\process\Transliteration;
|
||||
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
|
||||
|
||||
/**
|
||||
* Tests the transliteration process plugin.
|
||||
*
|
||||
* @group migrate_plus
|
||||
*/
|
||||
class TransliterationTest extends MigrateProcessTestCase {
|
||||
|
||||
/**
|
||||
* A transliteration instance.
|
||||
*
|
||||
* @var \Drupal\Component\Transliteration\TransliterationInterface
|
||||
*/
|
||||
protected $transliteration;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->transliteration = new PhpTransliteration();
|
||||
$this->row = $this->getMockBuilder(Row::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->migrateExecutable = $this->getMockBuilder(MigrateExecutableInterface::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests transliteration transformation of non-alphanumeric characters.
|
||||
*/
|
||||
public function testTransform() {
|
||||
$actual = '9000004351_53494854_Spøgelsesjægerneáéö';
|
||||
$expected_result = '9000004351_53494854_Spogelsesjaegerneaeo';
|
||||
|
||||
$plugin = new Transliteration([], 'transliteration', [], $this->transliteration);
|
||||
$value = $plugin->transform($actual, $this->migrateExecutable, $this->row, 'destinationproperty');
|
||||
$this->assertEquals($expected_result, $value);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user