Update to Drupal 8.0.2. For more information, see https://www.drupal.org/drupal-8.0.2-release-notes
This commit is contained in:
parent
1a0e9d9fac
commit
a6b049dd05
538 changed files with 5247 additions and 1594 deletions
39
core/modules/action/migration_templates/d6_action.yml
Normal file
39
core/modules/action/migration_templates/d6_action.yml
Normal file
|
@ -0,0 +1,39 @@
|
|||
id: d6_action
|
||||
label: Actions
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: action
|
||||
process:
|
||||
id:
|
||||
-
|
||||
plugin: machine_name
|
||||
source: aid
|
||||
label: description
|
||||
type: type
|
||||
plugin:
|
||||
-
|
||||
plugin: static_map
|
||||
source: callback
|
||||
map:
|
||||
system_goto_action: action_goto_action
|
||||
system_send_email_action: action_send_email_action
|
||||
system_message_action: action_message_action
|
||||
user_block_ip_action: 0
|
||||
imagecache_flush_action: 0
|
||||
imagecache_generate_all_action: 0
|
||||
imagecache_generate_action: 0
|
||||
bypass: true
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
configuration:
|
||||
-
|
||||
plugin: default_value
|
||||
source: parameters
|
||||
default_value: "a:0:{}"
|
||||
-
|
||||
plugin: callback
|
||||
callable: unserialize
|
||||
destination:
|
||||
plugin: entity:action
|
36
core/modules/action/migration_templates/d7_action.yml
Normal file
36
core/modules/action/migration_templates/d7_action.yml
Normal file
|
@ -0,0 +1,36 @@
|
|||
id: d7_action
|
||||
label: Actions
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: action
|
||||
process:
|
||||
id:
|
||||
-
|
||||
plugin: machine_name
|
||||
source: aid
|
||||
label: label
|
||||
type: type
|
||||
plugin:
|
||||
-
|
||||
plugin: static_map
|
||||
source: callback
|
||||
map:
|
||||
system_goto_action: action_goto_action
|
||||
system_send_email_action: action_send_email_action
|
||||
system_message_action: action_message_action
|
||||
system_block_ip_action: 0
|
||||
bypass: true
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
configuration:
|
||||
-
|
||||
plugin: default_value
|
||||
source: parameters
|
||||
default_value: "a:0:{}"
|
||||
-
|
||||
plugin: callback
|
||||
callable: unserialize
|
||||
destination:
|
||||
plugin: entity:action
|
74
core/modules/action/src/Plugin/migrate/source/Action.php
Normal file
74
core/modules/action/src/Plugin/migrate/source/Action.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\action\Plugin\migrate\source\Action.
|
||||
*/
|
||||
|
||||
namespace Drupal\action\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Drupal action source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "action",
|
||||
* source_provider = "system"
|
||||
* )
|
||||
*/
|
||||
class Action extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('actions', 'a')
|
||||
->fields('a');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = array(
|
||||
'aid' => $this->t('Action ID'),
|
||||
'type' => $this->t('Module'),
|
||||
'callback' => $this->t('Callback function'),
|
||||
'parameters' => $this->t('Action configuration'),
|
||||
);
|
||||
if ($this->getModuleSchemaVersion('system') >= 7000) {
|
||||
$fields['label'] = $this->t('Label of the action');
|
||||
}
|
||||
else {
|
||||
$fields['description'] = $this->t('Action description');
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['aid']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$aid = $row->getSourceProperty('aid');
|
||||
if (is_numeric($aid)) {
|
||||
if ($this->getModuleSchemaVersion('system') >= 7000) {
|
||||
$label = $row->getSourceProperty('label');
|
||||
}
|
||||
else {
|
||||
$label = $row->getSourceProperty('description');
|
||||
}
|
||||
$row->setSourceProperty('aid', $label);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\action\Plugin\migrate\source\d6\Action.
|
||||
*/
|
||||
|
||||
namespace Drupal\action\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 action source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_action"
|
||||
* )
|
||||
*/
|
||||
class Action extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('actions', 'a')
|
||||
->fields('a', array(
|
||||
'aid',
|
||||
'type',
|
||||
'callback',
|
||||
'parameters',
|
||||
'description',
|
||||
)
|
||||
);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'aid' => $this->t('Action ID'),
|
||||
'type' => $this->t('Module'),
|
||||
'callback' => $this->t('Callback function'),
|
||||
'parameters' => $this->t('Action configuration'),
|
||||
'description' => $this->t('Action description'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['aid']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\action\Tests\Migrate\d6\MigrateActionsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\action\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\system\Entity\Action;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of action items.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateActionsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
public static $modules = ['action', 'comment', 'node'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d6_action');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Drupal 6 action migration to Drupal 8.
|
||||
*/
|
||||
public function testActions() {
|
||||
// Test default actions.
|
||||
$this->assertEntity('node_publish_action', 'Publish post', 'node', []);
|
||||
$this->assertEntity('node_make_sticky_action', 'Make post sticky', 'node', []);
|
||||
$this->assertEntity('user_block_user_action', 'Block current user', 'user', []);
|
||||
$this->assertEntity('comment_publish_action', 'Publish comment', 'comment', []);
|
||||
|
||||
// Test advanced actions.
|
||||
$this->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', ["keywords" => [0 => "drupal"]]);
|
||||
$this->assertEntity('change_the_author_of_a_post', 'Change the author of a post', 'node', ["owner_uid" => "2"]);
|
||||
$this->assertEntity('unpublish_post_containing_keyword_s_', 'Unpublish post containing keyword(s)', 'node', ["keywords" => [0 => "drupal"]]);
|
||||
$this->assertEntity('display_a_message_to_the_user', 'Display a message to the user', 'system', ["message" => "Drupal migration test"]);
|
||||
$this->assertEntity('send_e_mail', 'Send e-mail', 'system', [
|
||||
"recipient" => "test@example.com",
|
||||
"subject" => "Drupal migration test",
|
||||
"message" => "Drupal migration test"
|
||||
]);
|
||||
$this->assertEntity('redirect_to_url', 'Redirect to URL', 'system', ["url" => "https://www.drupal.org"]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts various aspects of an Action entity.
|
||||
*
|
||||
* @param string $id
|
||||
* The expected Action ID.
|
||||
* @param string $label
|
||||
* The expected Action label.
|
||||
* @param string $type
|
||||
* The expected Action type.
|
||||
* @param array $configuration
|
||||
* The expected Action configuration.
|
||||
*/
|
||||
protected function assertEntity($id, $label, $type, $configuration) {
|
||||
$action = Action::load($id);
|
||||
|
||||
$this->assertTrue($action instanceof Action);
|
||||
/** @var \Drupal\system\Entity\Action $action */
|
||||
$this->assertIdentical($id, $action->id());
|
||||
$this->assertIdentical($label, $action->label());
|
||||
$this->assertIdentical($type, $action->getType());
|
||||
$this->assertIdentical($configuration, $action->get('configuration'));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\action\Tests\Migrate\d7\MigrateActionsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\action\Tests\Migrate\d7;
|
||||
|
||||
use Drupal\system\Entity\Action;
|
||||
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of action items.
|
||||
*
|
||||
* @group action
|
||||
*/
|
||||
class MigrateActionsTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = ['action', 'comment', 'node'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d7_action');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Drupal 7 action migration to Drupal 8.
|
||||
*/
|
||||
public function testActions() {
|
||||
// Test default actions.
|
||||
$this->assertEntity('node_publish_action', 'Publish content', 'node', []);
|
||||
$this->assertEntity('node_make_sticky_action', 'Make content sticky', 'node', []);
|
||||
$this->assertEntity('user_block_user_action', 'Block current user', 'user', []);
|
||||
$this->assertEntity('comment_publish_action', 'Publish comment', 'comment', []);
|
||||
|
||||
// Test advanced actions.
|
||||
$this->assertEntity('unpublish_comment_containing_keyword_s_', 'Unpublish comment containing keyword(s)', 'comment', ["keywords" => [0 => "drupal"]]);
|
||||
$this->assertEntity('change_the_author_of_content', 'Change the author of content', 'node', ["owner_uid" => "2"]);
|
||||
$this->assertEntity('unpublish_content_containing_keyword_s_', 'Unpublish content containing keyword(s)', 'node', ["keywords" => [0 => "drupal"]]);
|
||||
$this->assertEntity('display_a_message_to_the_user', 'Display a message to the user', 'system', ["message" => "Drupal migration test"]);
|
||||
$this->assertEntity('send_e_mail', 'Send e-mail', 'system', [
|
||||
"recipient" => "test@example.com",
|
||||
"subject" => "Drupal migration test",
|
||||
"message" => "Drupal migration test"
|
||||
]);
|
||||
$this->assertEntity('redirect_to_url', 'Redirect to URL', 'system', ["url" => "https://www.drupal.org"]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts various aspects of an Action entity.
|
||||
*
|
||||
* @param string $id
|
||||
* The expected Action ID.
|
||||
* @param string $label
|
||||
* The expected Action label.
|
||||
* @param string $type
|
||||
* The expected Action type.
|
||||
* @param array $configuration
|
||||
* The expected Action configuration.
|
||||
*/
|
||||
protected function assertEntity($id, $label, $type, $configuration) {
|
||||
$action = Action::load($id);
|
||||
|
||||
$this->assertTrue($action instanceof Action);
|
||||
/** @var \Drupal\system\Entity\Action $action */
|
||||
$this->assertIdentical($id, $action->id());
|
||||
$this->assertIdentical($label, $action->label());
|
||||
$this->assertIdentical($type, $action->getType());
|
||||
$this->assertIdentical($configuration, $action->get('configuration'));
|
||||
}
|
||||
|
||||
}
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\action\Unit\Plugin\migrate\source\d6\ActionTest.
|
||||
* Contains \Drupal\Tests\action\Unit\Plugin\migrate\source\ActionTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\action\Unit\Plugin\migrate\source\d6;
|
||||
namespace Drupal\Tests\action\Unit\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 actions source plugin.
|
||||
* Tests actions source plugin.
|
||||
*
|
||||
* @group action
|
||||
*/
|
||||
|
@ -18,14 +18,14 @@ class ActionTest extends MigrateSqlSourceTestCase {
|
|||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\action\Plugin\migrate\source\d6\Action';
|
||||
const PLUGIN_CLASS = 'Drupal\action\Plugin\migrate\source\Action';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_action',
|
||||
'plugin' => 'action',
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -33,14 +33,14 @@ class ActionTest extends MigrateSqlSourceTestCase {
|
|||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'aid' => '1',
|
||||
'aid' => 'Redirect to node list page',
|
||||
'type' => 'system',
|
||||
'callback' => 'system_goto_action',
|
||||
'parameters' => 'a:1:{s:3:"url";s:4:"node";}',
|
||||
'description' => 'Redirect to node list page',
|
||||
),
|
||||
array(
|
||||
'aid' => '2',
|
||||
'aid' => 'Test notice email',
|
||||
'type' => 'system',
|
||||
'callback' => 'system_send_email_action',
|
||||
'parameters' => 'a:3:{s:9:"recipient";s:7:"%author";s:7:"subject";s:4:"Test";s:7:"message";s:4:"Test',
|
||||
|
@ -50,15 +50,15 @@ class ActionTest extends MigrateSqlSourceTestCase {
|
|||
'aid' => 'comment_publish_action',
|
||||
'type' => 'comment',
|
||||
'callback' => 'comment_publish_action',
|
||||
'parameters' => null,
|
||||
'description' => null,
|
||||
'parameters' => NULL,
|
||||
'description' => NULL,
|
||||
),
|
||||
array(
|
||||
'aid' => 'node_publish_action',
|
||||
'type' => 'comment',
|
||||
'callback' => 'node_publish_action',
|
||||
'parameters' => null,
|
||||
'description' => null,
|
||||
'parameters' => NULL,
|
||||
'description' => NULL,
|
||||
),
|
||||
);
|
||||
|
Reference in a new issue