Remove more spurious files that should not be in b15.
This commit is contained in:
parent
08dd73ad55
commit
efbcb71ec3
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="#ea2800"><path d="M8.002 1c-3.868 0-7.002 3.134-7.002 7s3.134 7 7.002 7c3.865 0 7-3.134 7-7s-3.135-7-7-7zm4.025 9.284c.062.063.1.149.1.239 0 .091-.037.177-.1.24l-1.262 1.262c-.064.062-.15.1-.24.1s-.176-.036-.24-.1l-2.283-2.283-2.286 2.283c-.064.062-.15.1-.24.1s-.176-.036-.24-.1l-1.261-1.262c-.063-.062-.1-.148-.1-.24 0-.088.036-.176.1-.238l2.283-2.285-2.283-2.284c-.063-.064-.1-.15-.1-.24s.036-.176.1-.24l1.262-1.262c.063-.063.149-.1.24-.1.089 0 .176.036.24.1l2.285 2.284 2.283-2.284c.064-.063.15-.1.24-.1s.176.036.24.1l1.262 1.262c.062.063.1.149.1.24 0 .089-.037.176-.1.24l-2.283 2.284 2.283 2.284z"/></svg>
|
Before Width: | Height: | Size: 678 B |
|
@ -1,48 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\locale\Tests\Migrate\d6\MigrateLocaleConfigsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\locale\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upgrade variables to locale.settings.yml.
|
||||
*
|
||||
* @group locale
|
||||
*/
|
||||
class MigrateLocaleConfigsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('locale', 'language');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->loadDumps(['Variable.php']);
|
||||
$this->executeMigration('d6_locale_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of locale variables to locale.settings.yml.
|
||||
*/
|
||||
public function testLocaleSettings() {
|
||||
$config = $this->config('locale.settings');
|
||||
$this->assertIdentical(TRUE, $config->get('cache_strings'));
|
||||
$this->assertIdentical('languages', $config->get('javascript.directory'));
|
||||
$this->assertConfigSchema(\Drupal::service('config.typed'), 'locale.settings', $config->get());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\menu_link_content\Plugin\migrate\source\d6\MenuLink.
|
||||
*/
|
||||
|
||||
namespace Drupal\menu_link_content\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Drupal 6 menu link source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_menu_link",
|
||||
* )
|
||||
*/
|
||||
class MenuLink extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('menu_links', 'ml')
|
||||
->fields('ml', array(
|
||||
'menu_name',
|
||||
'mlid',
|
||||
'plid',
|
||||
'link_path',
|
||||
'router_path',
|
||||
'link_title',
|
||||
'options',
|
||||
'module',
|
||||
'hidden',
|
||||
'external',
|
||||
'has_children',
|
||||
'expanded',
|
||||
'weight',
|
||||
'depth',
|
||||
'customized',
|
||||
'p1',
|
||||
'p2',
|
||||
'p3',
|
||||
'p4',
|
||||
'p5',
|
||||
'p6',
|
||||
'p7',
|
||||
'p8',
|
||||
'p9',
|
||||
'updated'
|
||||
))
|
||||
->condition('module', 'menu')
|
||||
->condition('customized', 1);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'menu_name' => t("The menu name. All links with the same menu name (such as 'navigation') are part of the same menu."),
|
||||
'mlid' => t('The menu link ID (mlid) is the integer primary key.'),
|
||||
'plid' => t('The parent link ID (plid) is the mlid of the link above in the hierarchy, or zero if the link is at the top level in its menu.'),
|
||||
'link_path' => t('The Drupal path or external path this link points to.'),
|
||||
'router_path' => t('For links corresponding to a Drupal path (external = 0), this connects the link to a {menu_router}.path for joins.'),
|
||||
'link_title' => t('The text displayed for the link, which may be modified by a title callback stored in {menu_router}.'),
|
||||
'options' => t('A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.'),
|
||||
'module' => t('The name of the module that generated this link.'),
|
||||
'hidden' => t('A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link)'),
|
||||
'external' => t('A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).'),
|
||||
'has_children' => t('Flag indicating whether any links have this link as a parent (1 = children exist, 0 = no children).'),
|
||||
'expanded' => t('Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)'),
|
||||
'weight' => t('Link weight among links in the same menu at the same depth.'),
|
||||
'depth' => t('The depth relative to the top level. A link with plid == 0 will have depth == 1.'),
|
||||
'customized' => t('A flag to indicate that the user has manually created or edited the link (1 = customized, 0 = not customized).'),
|
||||
'p1' => t('The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the plid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.'),
|
||||
'p2' => t('The second mlid in the materialized path. See p1.'),
|
||||
'p3' => t('The third mlid in the materialized path. See p1.'),
|
||||
'p4' => t('The fourth mlid in the materialized path. See p1.'),
|
||||
'p5' => t('The fifth mlid in the materialized path. See p1.'),
|
||||
'p6' => t('The sixth mlid in the materialized path. See p1.'),
|
||||
'p7' => t('The seventh mlid in the materialized path. See p1.'),
|
||||
'p8' => t('The eighth mlid in the materialized path. See p1.'),
|
||||
'p9' => t('The ninth mlid in the materialized path. See p1.'),
|
||||
'updated' => t('Flag that indicates that this link was generated during the update from Drupal 5.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('options', unserialize($row->getSourceProperty('options')));
|
||||
$row->setSourceProperty('enabled', !$row->getSourceProperty('hidden'));
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['mlid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\menu_link_content\Unit\Plugin\migrate\source\d6\MenuLinkSourceTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\menu_link_content\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 menu link source plugin.
|
||||
*
|
||||
* @group menu_link_content
|
||||
*/
|
||||
class MenuLinkSourceTest 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\menu_link_content\Plugin\migrate\source\d6\MenuLink';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'mlid',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
// This needs to be the identifier of the actual key: cid for comment, nid
|
||||
// for node and so on.
|
||||
'source' => array(
|
||||
'plugin' => 'drupal6_menu_link',
|
||||
),
|
||||
'sourceIds' => array(
|
||||
'mlid' => array(
|
||||
// This is where the field schema would go but for now we need to
|
||||
// specify the table alias for the key. Most likely this will be the
|
||||
// same as BASE_ALIAS.
|
||||
'alias' => 'ml',
|
||||
),
|
||||
),
|
||||
'destinationIds' => array(
|
||||
'mlid' => array(
|
||||
// This is where the field schema would go.
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 138,
|
||||
'plid' => 0,
|
||||
'link_path' => 'admin',
|
||||
'router_path' => 'admin',
|
||||
'link_title' => 'Test 1',
|
||||
'options' => array('attributes' => array('title' => 'Test menu link 1')),
|
||||
'module' => 'menu',
|
||||
'hidden' => 0,
|
||||
'external' => 0,
|
||||
'has_children' => 1,
|
||||
'expanded' => 0,
|
||||
'weight' => 15,
|
||||
'depth' => 1,
|
||||
'customized' => 1,
|
||||
'p1' => '138',
|
||||
'p2' => '0',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
),
|
||||
array(
|
||||
'menu_name' => 'menu-test-menu',
|
||||
'mlid' => 139,
|
||||
'plid' => 138,
|
||||
'link_path' => 'admin/modules',
|
||||
'router_path' => 'admin/modules',
|
||||
'link_title' => 'Test 2',
|
||||
'options' => array('attributes' => array('title' => 'Test menu link 2')),
|
||||
'module' => 'menu',
|
||||
'hidden' => 0,
|
||||
'external' => 0,
|
||||
'has_children' => 0,
|
||||
'expanded' => 0,
|
||||
'weight' => 12,
|
||||
'depth' => 2,
|
||||
'customized' => 1,
|
||||
'p1' => '138',
|
||||
'p2' => '139',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
// This array stores the database.
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
$this->databaseContents['menu_links'][$k] = $row;
|
||||
$this->databaseContents['menu_links'][$k]['options'] = serialize($this->databaseContents['menu_links'][$k]['options']);
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\menu_ui\Tests\Migrate\d6\MigrateMenuConfigsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\menu_ui\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upgrade variables to menu_ui.settings.yml.
|
||||
*
|
||||
* @group menu_ui
|
||||
*/
|
||||
class MigrateMenuConfigsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('menu_ui');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->loadDumps(['Variable.php']);
|
||||
$this->executeMigration('d6_menu_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of variables for the Menu UI module.
|
||||
*/
|
||||
public function testMenuSettings() {
|
||||
$config = $this->config('menu_ui.settings');
|
||||
$this->assertIdentical(FALSE, $config->get('override_parent_selector'));
|
||||
$this->assertConfigSchema(\Drupal::service('config.typed'), 'menu_ui.settings', $config->get());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
id: d6_cck_field_revision
|
||||
label: Drupal 6 field revisions
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
load:
|
||||
plugin: drupal_entity
|
||||
bundle_migration: d6_node_type
|
||||
source:
|
||||
plugin: d6_cck_field_revision
|
||||
process:
|
||||
vid: vid
|
||||
destination:
|
||||
plugin: entity_revision:node
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_cck_field_values
|
||||
- d6_node_revision
|
|
@ -1,21 +0,0 @@
|
|||
id: d6_cck_field_values
|
||||
label: Drupal 6 field values
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
load:
|
||||
plugin: drupal_entity
|
||||
bundle_migration: d6_node_type
|
||||
source:
|
||||
plugin: d6_cck_field_values
|
||||
process:
|
||||
nid:
|
||||
plugin: migration
|
||||
migration: d6_node
|
||||
source: nid
|
||||
destination:
|
||||
plugin: entity:node
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_node
|
||||
- d6_field_formatter_settings
|
||||
- d6_field_instance_widget_settings
|
|
@ -1,45 +0,0 @@
|
|||
id: d6_comment
|
||||
label: Drupal 6 comments
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_comment
|
||||
constants:
|
||||
entity_type: node
|
||||
process:
|
||||
cid: cid
|
||||
pid:
|
||||
plugin: migration
|
||||
migration: d6_comment
|
||||
source: pid
|
||||
entity_id: nid
|
||||
entity_type: 'constants/entity_type'
|
||||
# field_name & comment_type is calculated in
|
||||
# \Drupal\migrate_drupal\Plugin\migrate\source\d6\Comment::prepareRow()
|
||||
field_name: field_name
|
||||
comment_type: comment_type
|
||||
subject: subject
|
||||
uid: uid
|
||||
name: name
|
||||
mail: mail
|
||||
homepage: homepage
|
||||
hostname: hostname
|
||||
created: timestamp
|
||||
changed: timestamp
|
||||
status: status #In D6, published=0. We reverse the value in prepareRow.
|
||||
thread: thread
|
||||
'comment_body/value': comment
|
||||
'comment_body/format':
|
||||
plugin: migration
|
||||
migration: d6_filter_format
|
||||
source: format
|
||||
destination:
|
||||
plugin: entity:comment
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_node
|
||||
- d6_comment_type
|
||||
- d6_user
|
||||
- d6_comment_entity_display
|
||||
- d6_comment_entity_form_display
|
||||
- d6_filter_format
|
|
@ -1,26 +0,0 @@
|
|||
id: d6_comment_entity_display
|
||||
label: Drupal 6 comment display configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_comment_variable
|
||||
constants:
|
||||
entity_type: node
|
||||
field_name: comment
|
||||
view_mode: default
|
||||
options:
|
||||
label: hidden
|
||||
type: comment_default
|
||||
weight: 20
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
field_name: 'constants/field_name'
|
||||
view_mode: 'constants/view_mode'
|
||||
options: 'constants/options'
|
||||
|
||||
bundle: node_type
|
||||
destination:
|
||||
plugin: component_entity_display
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_comment_field_instance
|
|
@ -1,25 +0,0 @@
|
|||
id: d6_comment_entity_form_display
|
||||
label: Drupal 6 comment field form display configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_comment_variable
|
||||
constants:
|
||||
entity_type: node
|
||||
field_name: comment
|
||||
form_mode: default
|
||||
options:
|
||||
type: comment_default
|
||||
weight: 20
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
field_name: 'constants/field_name'
|
||||
form_mode: 'constants/form_mode'
|
||||
options: 'constants/options'
|
||||
|
||||
bundle: node_type
|
||||
destination:
|
||||
plugin: component_entity_form_display
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_comment_field_instance
|
|
@ -1,32 +0,0 @@
|
|||
id: d6_comment_entity_form_display_subject
|
||||
label: Drupal 6 comment subject form display configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_comment_variable_per_comment_type
|
||||
constants:
|
||||
entity_type: comment
|
||||
field_name: subject
|
||||
form_mode: default
|
||||
options:
|
||||
type: string_textfield
|
||||
weight: 10
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
field_name: 'constants/field_name'
|
||||
form_mode: 'constants/form_mode'
|
||||
options: 'constants/options'
|
||||
|
||||
hidden:
|
||||
plugin: static_map
|
||||
source: comment_type
|
||||
default_value: false
|
||||
map:
|
||||
comment_no_subject: true # Hide subject field
|
||||
comment: false
|
||||
bundle: comment_type
|
||||
destination:
|
||||
plugin: component_entity_form_display
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_comment_type
|
|
@ -1,19 +0,0 @@
|
|||
id: d6_comment_field
|
||||
label: Drupal 6 comment field configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_comment_variable_per_comment_type
|
||||
constants:
|
||||
entity_type: node
|
||||
type: comment
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
field_name: comment_type
|
||||
type: 'constants/type'
|
||||
'settings/comment_type': comment_type
|
||||
destination:
|
||||
plugin: md_entity:field_storage_config
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_comment_type
|
|
@ -1,34 +0,0 @@
|
|||
id: d6_comment_field_instance
|
||||
label: Drupal 6 comment field instance configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_comment_variable
|
||||
constants:
|
||||
entity_type: node
|
||||
label: Comments
|
||||
required: true
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
label: 'constants/label'
|
||||
required: 'constants/required'
|
||||
|
||||
field_name:
|
||||
plugin: static_map
|
||||
source: comment_subject_field
|
||||
default_value: comment
|
||||
map:
|
||||
0: comment_no_subject
|
||||
bundle: node_type
|
||||
'default_value/0/status': comment
|
||||
'settings/default_mode': comment_default_mode
|
||||
'settings/per_page': comment_default_per_page
|
||||
'settings/anonymous': comment_anonymous
|
||||
'settings/form_location': comment_form_location
|
||||
'settings/preview': comment_preview
|
||||
destination:
|
||||
plugin: entity:field_config
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_comment_field
|
||||
- d6_node_type
|
|
@ -1,15 +0,0 @@
|
|||
id: d6_comment_type
|
||||
label: Drupal 6 comment type
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_comment_variable_per_comment_type
|
||||
constants:
|
||||
entity_type: node
|
||||
process:
|
||||
target_entity_type_id: 'constants/entity_type'
|
||||
id: comment_type
|
||||
label: label
|
||||
description: description
|
||||
destination:
|
||||
plugin: entity:comment_type
|
|
@ -1,133 +0,0 @@
|
|||
id: d6_field
|
||||
label: Drupal 6 field configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_field
|
||||
constants:
|
||||
entity_type: node
|
||||
langcode: en
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
status: active
|
||||
langcode: 'constants/langcode'
|
||||
field_name: field_name
|
||||
type:
|
||||
-
|
||||
plugin: static_map
|
||||
source:
|
||||
- type
|
||||
- widget_type
|
||||
map:
|
||||
number_integer:
|
||||
number: integer
|
||||
optionwidgets_select: list_integer
|
||||
optionwidgets_buttons: list_integer
|
||||
optionwidgets_onoff: boolean
|
||||
number_decimal:
|
||||
number: decimal
|
||||
optionwidgets_select: list_float
|
||||
optionwidgets_buttons: list_float
|
||||
optionwidgets_onoff: boolean
|
||||
number_float:
|
||||
number: float
|
||||
optionwidgets_select: list_float
|
||||
optionwidgets_buttons: list_float
|
||||
optionwidgets_onoff: boolean
|
||||
text:
|
||||
optionwidgets_select: list_string
|
||||
optionwidgets_buttons: list_string
|
||||
optionwidgets_onoff: boolean
|
||||
text_textfield: text
|
||||
text_textarea: text_long
|
||||
email:
|
||||
email_textfield: email
|
||||
filefield:
|
||||
imagefield_widget: image
|
||||
filefield_widget: file
|
||||
date:
|
||||
date_select: datetime
|
||||
datestamp:
|
||||
date_select: datetime
|
||||
datetime:
|
||||
date_select: datetime
|
||||
fr_phone:
|
||||
phone_textfield: telephone
|
||||
be_phone:
|
||||
phone_textfield: telephone
|
||||
it_phone:
|
||||
phone_textfield: telephone
|
||||
el_phone:
|
||||
phone_textfield: telephone
|
||||
ch_phone:
|
||||
phone_textfield: telephone
|
||||
ca_phone:
|
||||
phone_textfield: telephone
|
||||
cr_phone:
|
||||
phone_textfield: telephone
|
||||
pa_phone:
|
||||
phone_textfield: telephone
|
||||
gb_phone:
|
||||
phone_textfield: telephone
|
||||
ru_phone:
|
||||
phone_textfield: telephone
|
||||
ua_phone:
|
||||
phone_textfield: telephone
|
||||
es_phone:
|
||||
phone_textfield: telephone
|
||||
au_phone:
|
||||
phone_textfield: telephone
|
||||
cs_phone:
|
||||
phone_textfield: telephone
|
||||
hu_phone:
|
||||
phone_textfield: telephone
|
||||
pl_phone:
|
||||
phone_textfield: telephone
|
||||
nl_phone:
|
||||
phone_textfield: telephone
|
||||
se_phone:
|
||||
phone_textfield: telephone
|
||||
za_phone:
|
||||
phone_textfield: telephone
|
||||
il_phone:
|
||||
phone_textfield: telephone
|
||||
nz_phone:
|
||||
phone_textfield: telephone
|
||||
br_phone:
|
||||
phone_textfield: telephone
|
||||
cl_phone:
|
||||
phone_textfield: telephone
|
||||
cn_phone:
|
||||
phone_textfield: telephone
|
||||
hk_phone:
|
||||
phone_textfield: telephone
|
||||
mo_phone:
|
||||
phone_textfield: telephone
|
||||
ph_phone:
|
||||
phone_textfield: telephone
|
||||
sg_phone:
|
||||
phone_textfield: telephone
|
||||
jo_phone:
|
||||
phone_textfield: telephone
|
||||
eg_phone:
|
||||
phone_textfield: telephone
|
||||
pk_phone:
|
||||
phone_textfield: telephone
|
||||
int_phone:
|
||||
phone_textfield: telephone
|
||||
cardinality:
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source: multiple
|
||||
map:
|
||||
0: 1
|
||||
1: -1
|
||||
settings:
|
||||
plugin: field_settings
|
||||
source:
|
||||
- @type
|
||||
- global_settings
|
||||
- widget_settings
|
||||
|
||||
destination:
|
||||
plugin: md_entity:field_storage_config
|
|
@ -1,252 +0,0 @@
|
|||
id: d6_field_formatter_settings
|
||||
label: Drupal 6 field formatter configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_field_instance_per_view_mode
|
||||
constants:
|
||||
entity_type: node
|
||||
third_party_settings: { }
|
||||
|
||||
process:
|
||||
# We skip field types that don't exist because they weren't migrated by the
|
||||
# field migration.
|
||||
field_type_exists:
|
||||
-
|
||||
plugin: migration
|
||||
migration: d6_field
|
||||
source:
|
||||
- field_name
|
||||
-
|
||||
plugin: extract
|
||||
index:
|
||||
- 1
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
entity_type: 'constants/entity_type'
|
||||
bundle: type_name
|
||||
view_mode:
|
||||
-
|
||||
plugin: migration
|
||||
migration: d6_view_modes
|
||||
source:
|
||||
- view_mode
|
||||
-
|
||||
plugin: extract
|
||||
index:
|
||||
- 1
|
||||
-
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
map:
|
||||
full: default
|
||||
field_name: field_name
|
||||
"options/label": label
|
||||
"options/weight": weight
|
||||
"options/type":
|
||||
-
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source:
|
||||
- type
|
||||
- 'display_settings/format'
|
||||
map:
|
||||
number_integer:
|
||||
default: number_integer
|
||||
us_0: number_integer
|
||||
be_0: number_integer
|
||||
fr_0: number_integer
|
||||
unformatted: number_unformatted
|
||||
number_float:
|
||||
default: number_decimal
|
||||
us_0: number_decimal
|
||||
us_1: number_decimal
|
||||
us_2: number_decimal
|
||||
be_0: number_decimal
|
||||
be_1: number_decimal
|
||||
be_2: number_decimal
|
||||
fr_0: number_decimal
|
||||
fr_1: number_decimal
|
||||
fr_2: number_decimal
|
||||
unformatted: number_unformatted
|
||||
number_decimal:
|
||||
default: number_decimal
|
||||
us_0: number_decimal
|
||||
us_1: number_decimal
|
||||
us_2: number_decimal
|
||||
be_0: number_decimal
|
||||
be_1: number_decimal
|
||||
be_2: number_decimal
|
||||
fr_0: number_decimal
|
||||
fr_1: number_decimal
|
||||
fr_2: number_decimal
|
||||
unformatted: number_unformatted
|
||||
email:
|
||||
default: email_mailto
|
||||
spamspan: email_mailto
|
||||
contact: email_mailto
|
||||
plain: basic_string
|
||||
fr_phone:
|
||||
default: basic_string
|
||||
be_phone:
|
||||
default: basic_string
|
||||
it_phone:
|
||||
default: basic_string
|
||||
el_phone:
|
||||
default: basic_string
|
||||
ch_phone:
|
||||
default: basic_string
|
||||
ca_phone:
|
||||
default: basic_string
|
||||
cr_phone:
|
||||
default: basic_string
|
||||
pa_phone:
|
||||
default: basic_string
|
||||
gb_phone:
|
||||
default: basic_string
|
||||
ru_phone:
|
||||
default: basic_string
|
||||
ua_phone:
|
||||
default: basic_string
|
||||
es_phone:
|
||||
default: basic_string
|
||||
au_phone:
|
||||
default: basic_string
|
||||
cs_phone:
|
||||
default: basic_string
|
||||
hu_phone:
|
||||
default: basic_string
|
||||
pl_phone:
|
||||
default: basic_string
|
||||
nl_phone:
|
||||
default: basic_string
|
||||
se_phone:
|
||||
default: basic_string
|
||||
za_phone:
|
||||
default: basic_string
|
||||
il_phone:
|
||||
default: basic_string
|
||||
nz_phone:
|
||||
default: basic_string
|
||||
br_phone:
|
||||
default: basic_string
|
||||
cl_phone:
|
||||
default: basic_string
|
||||
cn_phone:
|
||||
default: basic_string
|
||||
hk_phone:
|
||||
default: basic_string
|
||||
mo_phone:
|
||||
default: basic_string
|
||||
ph_phone:
|
||||
default: basic_string
|
||||
sg_phone:
|
||||
default: basic_string
|
||||
jo_phone:
|
||||
default: basic_string
|
||||
eg_phone:
|
||||
default: basic_string
|
||||
pk_phone:
|
||||
default: basic_string
|
||||
int_phone:
|
||||
default: basic_string
|
||||
-
|
||||
plugin: field_type_defaults
|
||||
"options/settings":
|
||||
-
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source:
|
||||
- module
|
||||
- 'display_settings/format'
|
||||
map:
|
||||
link:
|
||||
default:
|
||||
trim_length: '80'
|
||||
url_only: 0
|
||||
url_plain: 0
|
||||
rel: 0
|
||||
target: 0
|
||||
plain:
|
||||
trim_length: '80'
|
||||
url_only: 1
|
||||
url_plain: 1
|
||||
rel: 0
|
||||
target: 0
|
||||
absolute:
|
||||
trim_length: '80'
|
||||
url_only: 1
|
||||
url_plain: 1
|
||||
rel: 0
|
||||
target: 0
|
||||
title_plain: #can't support title as plain text.
|
||||
trim_length: '80'
|
||||
url_only: 1
|
||||
url_plain: 1
|
||||
rel: 0
|
||||
target: 0
|
||||
url:
|
||||
trim_length: '80'
|
||||
url_only: 1
|
||||
url_plain: 0
|
||||
rel: 0
|
||||
target: 0
|
||||
short: #can't support hardcoded link text?
|
||||
trim_length: '80'
|
||||
url_only: 0
|
||||
url_plain: 0
|
||||
rel: 0
|
||||
target: 0
|
||||
label: # can't support label as link text?
|
||||
trim_length: '80'
|
||||
url_only: 0
|
||||
url_plain: 0
|
||||
rel: 0
|
||||
target: 0
|
||||
separate:
|
||||
trim_length: '80'
|
||||
rel: 0
|
||||
target: 0
|
||||
filefield:
|
||||
image_plain:
|
||||
image_style: ''
|
||||
image_link: ''
|
||||
image_nodelink:
|
||||
image_style: ''
|
||||
image_link: content
|
||||
image_imagelink:
|
||||
image_style: ''
|
||||
image_link: file
|
||||
date:
|
||||
default:
|
||||
format_type: fallback
|
||||
timezone_override: ''
|
||||
format_interval:
|
||||
format_type: fallback
|
||||
timezone_override: ''
|
||||
long:
|
||||
format_type: long
|
||||
timezone_override: ''
|
||||
medium:
|
||||
format_type: medium
|
||||
timezone_override: ''
|
||||
short:
|
||||
format_type: short
|
||||
timezone_override: ''
|
||||
text:
|
||||
trimmed:
|
||||
trim_length: 600
|
||||
string:
|
||||
default:
|
||||
link_to_entity: false
|
||||
-
|
||||
plugin: field_formatter_settings_defaults
|
||||
"options/third_party_settings": 'constants/third_party_settings'
|
||||
|
||||
destination:
|
||||
plugin: component_entity_display
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_field_instance
|
||||
- d6_view_modes
|
|
@ -1,52 +0,0 @@
|
|||
id: d6_field_instance
|
||||
label: Drupal 6 field instance configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_field_instance
|
||||
constants:
|
||||
entity_type: node
|
||||
|
||||
process:
|
||||
# We skip field types that don't exist because they weren't migrated by the
|
||||
# field migration.
|
||||
field_type_exists:
|
||||
-
|
||||
plugin: migration
|
||||
migration: d6_field
|
||||
source:
|
||||
- field_name
|
||||
-
|
||||
plugin: extract
|
||||
index:
|
||||
- 1
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
entity_type: 'constants/entity_type'
|
||||
field_name: field_name
|
||||
bundle: type_name
|
||||
label: label
|
||||
description: description
|
||||
required: required
|
||||
status: active
|
||||
settings:
|
||||
plugin: d6_field_field_settings
|
||||
source:
|
||||
- widget_type
|
||||
- widget_settings
|
||||
- global_settings
|
||||
|
||||
default_value_callback: ''
|
||||
default_value:
|
||||
plugin: d6_field_instance_defaults
|
||||
source:
|
||||
- widget_type
|
||||
- widget_settings
|
||||
|
||||
destination:
|
||||
plugin: entity:field_config
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_node_type
|
||||
- d6_field
|
|
@ -1,60 +0,0 @@
|
|||
id: d6_field_instance_widget_settings
|
||||
label: Drupal 6 field instance widget configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_field_instance_per_form_display
|
||||
constants:
|
||||
entity_type: node
|
||||
form_mode: default
|
||||
third_party_settings: { }
|
||||
|
||||
process:
|
||||
# We skip field types that don't exist because they weren't migrated by the
|
||||
# field migration.
|
||||
field_type_exists:
|
||||
-
|
||||
plugin: migration
|
||||
migration: d6_field
|
||||
source:
|
||||
- field_name
|
||||
-
|
||||
plugin: extract
|
||||
index:
|
||||
- 1
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
bundle: type_name
|
||||
form_mode: 'constants/form_mode'
|
||||
field_name: field_name
|
||||
entity_type: 'constants/entity_type'
|
||||
'options/weight': weight
|
||||
'options/type':
|
||||
type:
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source: widget_type
|
||||
map:
|
||||
number: number
|
||||
email_textfield: email_default
|
||||
date_select: datetime_default
|
||||
date_text: datetime_default
|
||||
imagefield_widget: image_image
|
||||
phone_textfield: telephone_default
|
||||
optionwidgets_onoff: boolean_checkbox
|
||||
optionwidgets_buttons: options_buttons
|
||||
optionwidgets_select: options_select
|
||||
'options/settings':
|
||||
-
|
||||
plugin: field_instance_widget_settings
|
||||
source:
|
||||
- widget_type
|
||||
- widget_settings
|
||||
'options/third_party_settings': 'constants/third_party_settings'
|
||||
|
||||
destination:
|
||||
plugin: component_entity_form_display
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_field_instance
|
|
@ -1,25 +0,0 @@
|
|||
# Every migration that saves into {file_managed} must have the d6_file
|
||||
# migration as an optional dependency to ensure d6_file runs first.
|
||||
id: d6_file
|
||||
label: Drupal 6 files
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_file
|
||||
process:
|
||||
fid: fid
|
||||
filename: filename
|
||||
uri:
|
||||
plugin: file_uri
|
||||
source:
|
||||
- filepath
|
||||
- file_directory_path
|
||||
- temp_directory_path
|
||||
- is_public
|
||||
filemime: filemime
|
||||
filesize: filesize
|
||||
status: status
|
||||
changed: timestamp
|
||||
uid: uid
|
||||
destination:
|
||||
plugin: entity:file
|
|
@ -1,17 +0,0 @@
|
|||
id: d6_file_settings
|
||||
label: Drupal 6 file configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- file_description_type
|
||||
- file_description_length
|
||||
- file_icon_directory
|
||||
process:
|
||||
'description/type': file_description_type
|
||||
'description/length': file_description_length
|
||||
'icon/directory': file_icon_directory
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: file.settings
|
|
@ -1,18 +0,0 @@
|
|||
id: d6_profile_values
|
||||
label: Drupal 6 profile values
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_profile_field_values
|
||||
load:
|
||||
plugin: drupal_entity
|
||||
process:
|
||||
uid: uid
|
||||
destination:
|
||||
plugin: entity:user
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_user
|
||||
- d6_user_profile_field_instance
|
||||
- d6_user_profile_entity_display
|
||||
- d6_user_profile_entity_form_display
|
|
@ -1,27 +0,0 @@
|
|||
id: d6_upload
|
||||
label: Drupal 6 file uploads
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_upload
|
||||
|
||||
process:
|
||||
nid: nid
|
||||
vid: vid
|
||||
type: type
|
||||
upload:
|
||||
plugin: iterator
|
||||
source: upload
|
||||
process:
|
||||
target_id:
|
||||
plugin: migration
|
||||
migration: d6_file
|
||||
source: fid
|
||||
display: list
|
||||
description: description
|
||||
destination:
|
||||
plugin: entity:node
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_file
|
||||
- d6_node
|
|
@ -1,27 +0,0 @@
|
|||
id: d6_upload_entity_display
|
||||
label: Drupal 6 upload display configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_upload_instance
|
||||
constants:
|
||||
entity_type: node
|
||||
view_mode: default
|
||||
name: upload
|
||||
type: file_default
|
||||
options:
|
||||
label: hidden
|
||||
settings: {}
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
bundle: node_type
|
||||
view_mode: 'constants/view_mode'
|
||||
field_name: 'constants/name'
|
||||
type: 'constants/type'
|
||||
options: 'constants/options'
|
||||
'options/type': @type
|
||||
destination:
|
||||
plugin: component_entity_display
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_upload_field_instance
|
|
@ -1,28 +0,0 @@
|
|||
id: d6_upload_entity_form_display
|
||||
label: Drupal 6 upload form display configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_upload_instance
|
||||
constants:
|
||||
empty: {}
|
||||
entity_type: node
|
||||
form_mode: default
|
||||
name: upload
|
||||
type: file_generic
|
||||
options:
|
||||
settings:
|
||||
progress_indicator: throbber
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
bundle: node_type
|
||||
field_name: 'constants/name'
|
||||
form_mode: 'constants/form_mode'
|
||||
type: 'constants/type'
|
||||
options: 'constants/options'
|
||||
'options/type': @type
|
||||
destination:
|
||||
plugin: component_entity_form_display
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_upload_field_instance
|
|
@ -1,23 +0,0 @@
|
|||
id: d6_upload_field
|
||||
label: Drupal 6 upload field configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
# We do an empty source and a proper destination to have an idmap for
|
||||
# migration_dependencies.
|
||||
plugin: md_empty
|
||||
provider: upload
|
||||
constants:
|
||||
entity_type: node
|
||||
type: file
|
||||
name: upload
|
||||
cardinality: -1
|
||||
display_field: true
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
field_name: 'constants/name'
|
||||
type: 'constants/type'
|
||||
cardinality: 'constants/cardinality'
|
||||
'settings/display_field': 'constants/display_field'
|
||||
destination:
|
||||
plugin: md_entity:field_storage_config
|
|
@ -1,24 +0,0 @@
|
|||
id: d6_upload_field_instance
|
||||
label: Drupal 6 upload field instance configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_upload_instance
|
||||
constants:
|
||||
entity_type: node
|
||||
name: upload
|
||||
settings:
|
||||
description_field: 1
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
bundle: node_type
|
||||
field_name: 'constants/name'
|
||||
settings: 'constants/settings'
|
||||
'settings/file_extensions': file_extensions
|
||||
'settings/max_filesize': max_filesize
|
||||
destination:
|
||||
plugin: entity:field_config
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_upload_field
|
||||
- d6_node_type
|
|
@ -1,37 +0,0 @@
|
|||
id: d6_user
|
||||
label: Drupal 6 user accounts
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_user
|
||||
process:
|
||||
uid: uid
|
||||
name: name
|
||||
pass: pass
|
||||
mail: mail
|
||||
created: created
|
||||
access: access
|
||||
login: login
|
||||
status: status
|
||||
timezone:
|
||||
plugin: user_update_7002
|
||||
source: timezone
|
||||
preferred_langcode: language
|
||||
init: init
|
||||
roles:
|
||||
plugin: migration
|
||||
migration: d6_user_role
|
||||
source: roles
|
||||
user_picture:
|
||||
plugin: d6_user_picture
|
||||
source: uid
|
||||
destination:
|
||||
plugin: entity:user
|
||||
md5_passwords: true
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_user_role
|
||||
optional:
|
||||
- d6_user_picture_file
|
||||
- d6_user_picture_entity_display
|
||||
- d6_user_picture_entity_form_display
|
|
@ -1,23 +0,0 @@
|
|||
id: d6_user_contact_settings
|
||||
label: Drupal 6 user contact settings
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_user
|
||||
constants:
|
||||
key: contact
|
||||
module: contact
|
||||
process:
|
||||
uid: uid
|
||||
key: 'constants/key'
|
||||
module: 'constants/module'
|
||||
settings:
|
||||
plugin: skip_row_if_not_set
|
||||
index: contact
|
||||
source: data
|
||||
|
||||
destination:
|
||||
plugin: user_data
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_user
|
|
@ -1,39 +0,0 @@
|
|||
id: d6_user_mail
|
||||
label: Drupal 6 user mail configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- user_mail_status_activated_subject
|
||||
- user_mail_status_activated_body
|
||||
- user_mail_password_reset_subject
|
||||
- user_mail_password_reset_body
|
||||
- user_mail_status_deleted_subject
|
||||
- user_mail_status_deleted_body
|
||||
- user_mail_register_admin_created_subject
|
||||
- user_mail_register_admin_created_body
|
||||
- user_mail_register_no_approval_required_subject
|
||||
- user_mail_register_no_approval_required_body
|
||||
- user_mail_user_mail_register_pending_approval_subject
|
||||
- user_mail_user_mail_register_pending_approval_body
|
||||
- user_mail_status_blocked_subject
|
||||
- user_mail_status_blocked_body
|
||||
process:
|
||||
'status_activated/subject': user_mail_status_activated_subject
|
||||
'status_activated/body': user_mail_status_activated_body
|
||||
'password_reset/subject': user_mail_password_reset_subject
|
||||
'password_reset/body': user_mail_password_reset_body
|
||||
'cancel_confirm/subject': user_mail_status_deleted_subject
|
||||
'cancel_confirm/body': user_mail_status_deleted_body
|
||||
'register_admin_created/subject': user_mail_register_admin_created_subject
|
||||
'register_admin_created/body': user_mail_register_admin_created_body
|
||||
'register_no_approval_required/subject': user_mail_register_no_approval_required_subject
|
||||
'register_no_approval_required/body': user_mail_register_no_approval_required_body
|
||||
'register_pending_approval/subject': user_mail_user_mail_register_pending_approval_subject
|
||||
'register_pending_approval/body': user_mail_user_mail_register_pending_approval_body
|
||||
'status_blocked/subject': user_mail_status_blocked_subject
|
||||
'status_blocked/body': user_mail_status_blocked_body
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: user.mail
|
|
@ -1,30 +0,0 @@
|
|||
id: d6_user_picture_entity_display
|
||||
label: Drupal 6 user picture display configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_user_picture_instance
|
||||
constants:
|
||||
entity_type: user
|
||||
bundle: user
|
||||
view_mode: default
|
||||
name: user_picture
|
||||
type: image
|
||||
options:
|
||||
label: hidden
|
||||
settings:
|
||||
image_style: ''
|
||||
image_link: content
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
bundle: 'constants/bundle'
|
||||
view_mode: 'constants/view_mode'
|
||||
field_name: 'constants/name'
|
||||
type: 'constants/type'
|
||||
options: 'constants/options'
|
||||
'options/type': @type
|
||||
destination:
|
||||
plugin: component_entity_display
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_user_picture_field_instance
|
|
@ -1,29 +0,0 @@
|
|||
id: d6_user_picture_entity_form_display
|
||||
label: Drupal 6 user picture form display configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_user_picture_instance
|
||||
constants:
|
||||
entity_type: user
|
||||
bundle: user
|
||||
form_mode: default
|
||||
name: user_picture
|
||||
type: image_image
|
||||
options:
|
||||
settings:
|
||||
progress_indicator: throbber
|
||||
preview_image_style: thumbnail
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
bundle: 'constants/bundle'
|
||||
field_name: 'constants/name'
|
||||
form_mode: 'constants/form_mode'
|
||||
type: 'constants/type'
|
||||
options: 'constants/options'
|
||||
'options/type': @type
|
||||
destination:
|
||||
plugin: component_entity_form_display
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_user_picture_field_instance
|
|
@ -1,20 +0,0 @@
|
|||
id: d6_user_picture_field
|
||||
label: Drupal 6 user picture field configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
# We do an empty source and a proper destination to have an idmap for
|
||||
# dependencies.
|
||||
plugin: md_empty
|
||||
constants:
|
||||
entity_type: user
|
||||
type: image
|
||||
name: user_picture
|
||||
cardinality: 1
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
field_name: 'constants/name'
|
||||
type: 'constants/type'
|
||||
cardinality: 'constants/cardinality'
|
||||
destination:
|
||||
plugin: md_entity:field_storage_config
|
|
@ -1,30 +0,0 @@
|
|||
id: d6_user_picture_field_instance
|
||||
label: Drupal 6 user picture field instance configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_user_picture_instance
|
||||
constants:
|
||||
entity_type: user
|
||||
bundle: user
|
||||
name: user_picture
|
||||
settings:
|
||||
file_extensions: 'png gif jpg jpeg'
|
||||
alt_field: false
|
||||
title_field: false
|
||||
min_resolution: ''
|
||||
alt_field_required: false
|
||||
title_field_required: false
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
bundle: 'constants/bundle'
|
||||
field_name: 'constants/name'
|
||||
settings: 'constants/settings'
|
||||
'settings/file_directory': file_directory
|
||||
'settings/max_filesize': max_filesize
|
||||
'settings/max_resolution': max_resolution
|
||||
destination:
|
||||
plugin: entity:field_config
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_user_picture_field
|
|
@ -1,26 +0,0 @@
|
|||
id: d6_user_picture_file
|
||||
label: Drupal 6 user pictures
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_user_picture_file
|
||||
constants:
|
||||
is_public: true
|
||||
process:
|
||||
filename: filename
|
||||
uid: uid
|
||||
uri:
|
||||
plugin: file_uri
|
||||
source:
|
||||
- picture
|
||||
- file_directory_path
|
||||
- temp_directory_path
|
||||
- 'constants/is_public'
|
||||
destination:
|
||||
plugin: entity:file
|
||||
source_path_property: picture
|
||||
migration_dependencies:
|
||||
# Every migration that saves into {file_managed} must have the d6_file
|
||||
# migration as an optional dependency to ensure it runs first.
|
||||
optional:
|
||||
- d6_file
|
|
@ -1,40 +0,0 @@
|
|||
id: d6_user_profile_entity_display
|
||||
label: Drupal 6 user profile display configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_profile_field
|
||||
constants:
|
||||
entity_type: user
|
||||
bundle: user
|
||||
view_mode: default
|
||||
options:
|
||||
label: hidden
|
||||
settings: {}
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
bundle: 'constants/bundle'
|
||||
view_mode: 'constants/view_mode'
|
||||
field_name: name
|
||||
type:
|
||||
plugin: static_map
|
||||
source: type
|
||||
map:
|
||||
checkbox: list_default
|
||||
date: datetime_default
|
||||
list: text_default
|
||||
selection: list_default
|
||||
textfield: text_default
|
||||
textarea: text_default
|
||||
url: link_default
|
||||
options: 'constants/options'
|
||||
'options/type': @type
|
||||
hidden:
|
||||
plugin: static_map
|
||||
source: visibility
|
||||
default_value: false
|
||||
map:
|
||||
1: true # PROFILE_PRIVATE
|
||||
4: true # PROFILE_HIDDEN
|
||||
destination:
|
||||
plugin: component_entity_display
|
|
@ -1,49 +0,0 @@
|
|||
id: d6_user_profile_entity_form_display
|
||||
label: Drupal 6 user profile form display configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_profile_field
|
||||
constants:
|
||||
empty: {}
|
||||
entity_type: user
|
||||
bundle: user
|
||||
form_mode: default
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
bundle: 'constants/bundle'
|
||||
field_name: name
|
||||
form_mode: 'constants/form_mode'
|
||||
type:
|
||||
plugin: static_map
|
||||
source: type
|
||||
map:
|
||||
checkbox: boolean_checkbox
|
||||
date: datetime_default
|
||||
list: text_textfield
|
||||
selection: options_select
|
||||
textfield: text_textfield
|
||||
textarea: text_textarea
|
||||
url: link_default
|
||||
options: 'constants/options'
|
||||
'options/type': @type
|
||||
'options/settings':
|
||||
plugin: field_instance_widget_settings
|
||||
source:
|
||||
- @type
|
||||
- 'constants/empty' # we don't have any settings.
|
||||
'options/settings/display_label': # Single on/off checkboxes need to have display_label = true otherwise their label doesn't show.
|
||||
plugin: static_map
|
||||
default_value: false
|
||||
source: type
|
||||
map:
|
||||
checkbox: true
|
||||
hidden:
|
||||
plugin: static_map
|
||||
source: visibility
|
||||
default_value: false
|
||||
map:
|
||||
1: true # PROFILE_PRIVATE
|
||||
4: true # PROFILE_HIDDEN
|
||||
destination:
|
||||
plugin: component_entity_form_display
|
|
@ -1,34 +0,0 @@
|
|||
id: d6_user_profile_field
|
||||
label: Drupal 6 user profile field configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_profile_field
|
||||
constants:
|
||||
entity_type: user
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
field_name: name
|
||||
type:
|
||||
plugin: static_map
|
||||
source: type
|
||||
map:
|
||||
checkbox: boolean
|
||||
date: datetime
|
||||
list: text
|
||||
selection: list_string
|
||||
textfield: text
|
||||
textarea: text_long
|
||||
url: link
|
||||
settings:
|
||||
plugin: d6_profile_field_settings
|
||||
source: type
|
||||
'settings/allowed_values': options
|
||||
cardinality:
|
||||
plugin: static_map
|
||||
default_value: 1
|
||||
source: type
|
||||
map:
|
||||
list: -1
|
||||
destination:
|
||||
plugin: md_entity:field_storage_config
|
|
@ -1,21 +0,0 @@
|
|||
id: d6_user_profile_field_instance
|
||||
label: Drupal 6 user profile field instance configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_profile_field
|
||||
constants:
|
||||
entity_type: user
|
||||
bundle: user
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
bundle: 'constants/bundle'
|
||||
label: title
|
||||
description: explanation
|
||||
field_name: name
|
||||
required: required
|
||||
destination:
|
||||
plugin: entity:field_config
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_user_profile_field
|
|
@ -1,46 +0,0 @@
|
|||
id: d6_user_role
|
||||
label: Drupal 6 user roles
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: d6_user_role
|
||||
process:
|
||||
id:
|
||||
-
|
||||
plugin: machine_name
|
||||
source: name
|
||||
-
|
||||
plugin: dedupe_entity
|
||||
entity_type: user_role
|
||||
field: id
|
||||
length: 32
|
||||
-
|
||||
plugin: user_update_8002
|
||||
label: name
|
||||
permissions:
|
||||
-
|
||||
plugin: static_map
|
||||
source: permissions
|
||||
bypass: true
|
||||
map:
|
||||
'use PHP for block visibility': 'use PHP for settings'
|
||||
'administer site-wide contact form': 'administer contact forms'
|
||||
'post comments without approval': 'skip comment approval'
|
||||
'edit own blog entries' : 'edit own blog content'
|
||||
'edit any blog entry' : 'edit any blog content'
|
||||
'delete own blog entries' : 'delete own blog content'
|
||||
'delete any blog entry' : 'delete any blog content'
|
||||
'create forum topics' : 'create forum content'
|
||||
'delete any forum topic' : 'delete any forum content'
|
||||
'delete own forum topics' : 'delete own forum content'
|
||||
'edit any forum topic' : 'edit any forum content'
|
||||
'edit own forum topics' : 'edit own forum content'
|
||||
- plugin: system_update_7000
|
||||
- plugin: node_update_7008
|
||||
- plugin: flatten
|
||||
- plugin: filter_format_permission
|
||||
destination:
|
||||
plugin: entity:user_role
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_filter_format
|
|
@ -1,28 +0,0 @@
|
|||
id: d6_user_settings
|
||||
label: Drupal 6 user configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- user_mail_status_blocked_notify
|
||||
- user_mail_status_activated_notify
|
||||
- user_email_verification
|
||||
- user_register
|
||||
- anonymous
|
||||
process:
|
||||
'notify/status_blocked': user_mail_status_blocked_notify
|
||||
'notify/status_activated': user_mail_status_activated_notify
|
||||
verify_mail: user_email_verification
|
||||
register:
|
||||
plugin: static_map
|
||||
source: user_register
|
||||
default_value: visitors_admin_approval
|
||||
map:
|
||||
2: visitors_admin_approval
|
||||
1: user_register
|
||||
0: admin_only
|
||||
anonymous: anonymous
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: user.settings
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Entity\Migration.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Entity;
|
||||
|
||||
use Drupal\migrate\Entity\Migration as BaseMigration;
|
||||
|
||||
class Migration extends BaseMigration implements MigrationInterface {
|
||||
|
||||
/**
|
||||
* The load plugin configuration, if any.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $load = array();
|
||||
|
||||
/**
|
||||
* The load plugin.
|
||||
*
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateLoadInterface|false
|
||||
*/
|
||||
protected $loadPlugin = FALSE;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLoadPlugin() {
|
||||
if ($this->load && !$this->loadPlugin) {
|
||||
$this->loadPlugin = \Drupal::service('plugin.manager.migrate.load')->createInstance($this->load['plugin'], $this->load, $this);
|
||||
}
|
||||
return $this->loadPlugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Entity\MigrationInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Entity;
|
||||
|
||||
use Drupal\migrate\Entity\MigrationInterface as BaseMigrationInterface;
|
||||
|
||||
interface MigrationInterface extends BaseMigrationInterface {
|
||||
|
||||
/**
|
||||
* Returns the initialized load plugin if there's one.
|
||||
*
|
||||
* @return \Drupal\migrate_drupal\Plugin\MigrateLoadInterface|false
|
||||
*/
|
||||
public function getLoadPlugin();
|
||||
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\load;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Plugin\PluginBase;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\migrate\Plugin\SourceEntityInterface;
|
||||
use Drupal\migrate_drupal\Plugin\MigrateLoadInterface;
|
||||
use Drupal\migrate_drupal\Plugin\CckFieldMigrateSourceInterface;
|
||||
|
||||
/**
|
||||
* Base class for entity load plugins.
|
||||
*
|
||||
* @ingroup migration
|
||||
*
|
||||
* @PluginID("drupal_entity")
|
||||
*/
|
||||
class LoadEntity extends PluginBase implements MigrateLoadInterface {
|
||||
|
||||
/**
|
||||
* The list of bundles being loaded.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $bundles;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
||||
$this->migration = $migration;
|
||||
$source_plugin = $this->migration->getSourcePlugin();
|
||||
if (!$source_plugin instanceof SourceEntityInterface) {
|
||||
throw new MigrateException('Migrations with a load plugin using LoadEntity should have an entity as source.');
|
||||
}
|
||||
if ($source_plugin->bundleMigrationRequired() && empty($configuration['bundle_migration'])) {
|
||||
throw new MigrateException("Source plugin '{$source_plugin->getPluginId()}' requires the bundle_migration key to be set.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(EntityStorageInterface $storage, $sub_id) {
|
||||
$entities = $this->loadMultiple($storage, array($sub_id));
|
||||
return isset($entities[$sub_id]) ? $entities[$sub_id] : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = NULL) {
|
||||
if (isset($this->configuration['bundle_migration'])) {
|
||||
/** @var \Drupal\migrate\Entity\MigrationInterface $bundle_migration */
|
||||
$bundle_migration = $storage->load($this->configuration['bundle_migration']);
|
||||
$source_id = array_keys($bundle_migration->getSourcePlugin()->getIds())[0];
|
||||
$this->bundles = array();
|
||||
foreach ($bundle_migration->getSourcePlugin()->getIterator() as $row) {
|
||||
$this->bundles[] = $row[$source_id];
|
||||
}
|
||||
}
|
||||
else {
|
||||
// This entity type has no bundles ('user', 'feed', etc).
|
||||
$this->bundles = array($this->migration->getSourcePlugin()->entityTypeId());
|
||||
}
|
||||
$sub_ids_to_load = isset($sub_ids) ? array_intersect($this->bundles, $sub_ids) : $this->bundles;
|
||||
$migrations = array();
|
||||
foreach ($sub_ids_to_load as $id) {
|
||||
$values = $this->migration->toArray();
|
||||
$values['id'] = $this->migration->id() . ':' . $id;
|
||||
$values['source']['bundle'] = $id;
|
||||
/** @var \Drupal\migrate_drupal\Entity\MigrationInterface $migration */
|
||||
$migration = $storage->create($values);
|
||||
try {
|
||||
$migration->getSourcePlugin()->checkRequirements();
|
||||
$source_plugin = $migration->getSourcePlugin();
|
||||
|
||||
if ($source_plugin instanceof CckFieldMigrateSourceInterface) {
|
||||
foreach ($source_plugin->fieldData() as $field_name => $data) {
|
||||
$migration->setProcessOfProperty($field_name, $field_name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$fields = array_keys($migration->getSourcePlugin()->fields());
|
||||
$migration->setProcess($migration->getProcess() + array_combine($fields, $fields));
|
||||
}
|
||||
$migrations[$migration->id()] = $migration;
|
||||
}
|
||||
catch (RequirementsException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $migrations;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\CckFile.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate\Plugin\migrate\process\Route;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_cck_file"
|
||||
* )
|
||||
*/
|
||||
class CckFile extends Route implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($fid, $list, $data) = $value;
|
||||
|
||||
// If $fid is still an array at this point, that's because we have a file
|
||||
// attachment as per D6 core. If not, then we have a filefield from contrib.
|
||||
if (is_array($fid)) {
|
||||
$list = $fid['list'];
|
||||
$fid = $fid['fid'];
|
||||
}
|
||||
else {
|
||||
$options = unserialize($data);
|
||||
}
|
||||
|
||||
$file = [
|
||||
'target_id' => $fid,
|
||||
'display' => isset($list) ? $list : 0,
|
||||
'description' => isset($options['description']) ? $options['description'] : '',
|
||||
];
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\CckLink.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate\Plugin\migrate\process\Route;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_cck_link"
|
||||
* )
|
||||
*/
|
||||
class CckLink extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->migration = $migration;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($url, $title, $attributes) = $value;
|
||||
|
||||
// Drupal 6 link attributes are double serialized.
|
||||
$attributes = unserialize(unserialize($attributes));
|
||||
|
||||
// Massage the values into the correct form for the link.
|
||||
$route['uri'] = $url;
|
||||
$route['options']['attributes'] = $attributes;
|
||||
$route['title'] = $title;
|
||||
return $route;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,138 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldFormatterSettingsDefaults.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Set the default field settings.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "field_formatter_settings_defaults"
|
||||
* )
|
||||
*/
|
||||
class FieldFormatterSettingsDefaults extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set field formatter settings when the map didn't map: for date
|
||||
* formatters, the fallback format, for everything else, empty array.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
// If the 1 index is set then the map missed.
|
||||
if (isset($value[1])) {
|
||||
$module = $row->getSourceProperty('module');
|
||||
if ($module === 'date') {
|
||||
$value = array('format_type' => 'fallback');
|
||||
}
|
||||
elseif ($module === 'number') {
|
||||
// We have to do the lookup here in the process plugin because for
|
||||
// number we need to calculated the settings based on the type not just
|
||||
// the module which works well for other field types.
|
||||
return $this->numberSettings($row->getDestinationProperty('options/type'), $value[1]);
|
||||
}
|
||||
else {
|
||||
$value = array();
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* The field type.
|
||||
* @param $format
|
||||
* The format selected for the field on the display.
|
||||
*
|
||||
* @return array
|
||||
* The correct default settings.
|
||||
*
|
||||
* @throws \Drupal\migrate\MigrateException
|
||||
*/
|
||||
protected function numberSettings($type, $format) {
|
||||
$map = [
|
||||
'number_decimal' => [
|
||||
'us_0' => [
|
||||
'scale' => 0,
|
||||
'decimal_separator' => '.',
|
||||
'thousand_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'us_1' => [
|
||||
'scale' => 1,
|
||||
'decimal_separator' => '.',
|
||||
'thousand_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'us_2' => [
|
||||
'scale' => 2,
|
||||
'decimal_separator' => '.',
|
||||
'thousand_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'be_0' => [
|
||||
'scale' => 0,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'be_1' => [
|
||||
'scale' => 1,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'be_2' => [
|
||||
'scale' => 2,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'fr_0' => [
|
||||
'scale' => 0,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => ' ',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'fr_1' => [
|
||||
'scale' => 1,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => ' ',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'fr_2' => [
|
||||
'scale' => 2,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => ' ',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
],
|
||||
'number_integer' => [
|
||||
'us_0' => [
|
||||
'thousand_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'be_0' => [
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'fr_0' => [
|
||||
'thousand_separator' => ' ',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return isset($map[$type][$format]) ? $map[$type][$format] : [];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldIdGenerator.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Generate the file name for field config entities.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "field_id_generator"
|
||||
* )
|
||||
*/
|
||||
class FieldIdGenerator extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
return $value[0] . "." . $value[1];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldInstanceDefaults.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_field_instance_defaults"
|
||||
* )
|
||||
*/
|
||||
class FieldInstanceDefaults extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the field instance defaults.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($widget_type, $widget_settings) = $value;
|
||||
$default = array();
|
||||
|
||||
switch ($widget_type) {
|
||||
case 'text_textfield':
|
||||
case 'number':
|
||||
case 'phone_textfield':
|
||||
if (!empty($widget_settings['default_value'][0]['value'])) {
|
||||
$default['value'] = $widget_settings['default_value'][0]['value'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'imagefield_widget':
|
||||
// @todo, load the image and populate the defaults.
|
||||
// $default['default_image'] = $widget_settings['default_image'];
|
||||
break;
|
||||
|
||||
case 'date_select':
|
||||
if (!empty($widget_settings['default_value'])) {
|
||||
$default['default_date_type'] = 'relative';
|
||||
$default['default_date'] = $widget_settings['default_value'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'email_textfield':
|
||||
if (!empty($widget_settings['default_value'][0]['email'])) {
|
||||
$default['value'] = $widget_settings['default_value'][0]['email'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'link':
|
||||
if (!empty($widget_settings['default_value'][0]['url'])) {
|
||||
$default['title'] = $widget_settings['default_value'][0]['title'];
|
||||
$default['url'] = $widget_settings['default_value'][0]['url'];
|
||||
$default['options'] = ['attributes' => []];
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!empty($default)) {
|
||||
$default = array($default);
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldInstanceSettings.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_field_field_settings"
|
||||
* )
|
||||
*/
|
||||
class FieldInstanceSettings extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the field instance defaults.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($widget_type, $widget_settings, $field_settings) = $value;
|
||||
$settings = array();
|
||||
switch ($widget_type) {
|
||||
case 'number':
|
||||
$settings['min'] = $field_settings['min'];
|
||||
$settings['max'] = $field_settings['max'];
|
||||
$settings['prefix'] = $field_settings['prefix'];
|
||||
$settings['suffix'] = $field_settings['suffix'];
|
||||
break;
|
||||
|
||||
case 'link':
|
||||
// $settings['url'] = $widget_settings['default_value'][0]['url'];
|
||||
// D6 has optional, required, value and none. D8 only has disabled (0)
|
||||
// optional (1) and required (2).
|
||||
$map = array('disabled' => 0, 'optional' => 1, 'required' => 2);
|
||||
$settings['title'] = $map[$field_settings['title']];
|
||||
break;
|
||||
|
||||
case 'filefield_widget':
|
||||
$settings['file_extensions'] = $widget_settings['file_extensions'];
|
||||
$settings['file_directory'] = $widget_settings['file_path'];
|
||||
$settings['description_field'] = $field_settings['description_field'];
|
||||
$settings['max_filesize'] = $this->convertSizeUnit($widget_settings['max_filesize_per_file']);
|
||||
break;
|
||||
|
||||
case 'imagefield_widget':
|
||||
$settings['file_extensions'] = $widget_settings['file_extensions'];
|
||||
$settings['file_directory'] = 'public://';
|
||||
$settings['max_filesize'] = $this->convertSizeUnit($widget_settings['max_filesize_per_file']);
|
||||
$settings['alt_field'] = $widget_settings['alt'];
|
||||
$settings['alt_field_required'] = $widget_settings['custom_alt'];
|
||||
$settings['title_field'] = $widget_settings['title'];
|
||||
$settings['title_field_required'] = $widget_settings['custom_title'];
|
||||
$settings['max_resolution'] = $widget_settings['max_resolution'];
|
||||
$settings['min_resolution'] = $widget_settings['min_resolution'];
|
||||
break;
|
||||
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert file size strings into their D8 format.
|
||||
*
|
||||
* D6 stores file size using a "K" for kilobytes and "M" for megabytes where
|
||||
* as D8 uses "KB" and "MB" respectively.
|
||||
*
|
||||
* @param string $size_string
|
||||
* The size string, eg 10M
|
||||
*
|
||||
* @return string
|
||||
* The D8 version of the size string.
|
||||
*/
|
||||
protected function convertSizeUnit($size_string) {
|
||||
$size_unit = substr($size_string, strlen($size_string) - 1);
|
||||
if ($size_unit == "M" || $size_unit == "K") {
|
||||
return $size_string . "B";
|
||||
}
|
||||
return $size_string;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldInstanceWidgetSettings.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Get the field instance widget settings.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "field_instance_widget_settings"
|
||||
* )
|
||||
*/
|
||||
class FieldInstanceWidgetSettings extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Get the field instance default/mapped widget settings.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($widget_type, $widget_settings) = $value;
|
||||
return $this->getSettings($widget_type, $widget_settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the default D8 and specified D6 settings for a widget type.
|
||||
*
|
||||
* @param string $widget_type
|
||||
* The widget type.
|
||||
* @param array $widget_settings
|
||||
* The widget settings from D6 for this widget.
|
||||
*
|
||||
* @return array
|
||||
* A valid array of settings.
|
||||
*/
|
||||
public function getSettings($widget_type, $widget_settings) {
|
||||
$progress = isset($widget_settings['progress_indicator']) ? $widget_settings['progress_indicator'] : 'throbber';
|
||||
$size = isset($widget_settings['size']) ? $widget_settings['size'] : 60;
|
||||
$rows = isset($widget_settings['rows']) ? $widget_settings['rows'] : 5;
|
||||
|
||||
$settings = array(
|
||||
'text_textfield' => array(
|
||||
'size' => $size,
|
||||
'placeholder' => '',
|
||||
),
|
||||
'text_textarea' => array(
|
||||
'rows' => $rows,
|
||||
'placeholder' => '',
|
||||
),
|
||||
'number' => array(
|
||||
'placeholder' => '',
|
||||
),
|
||||
'email_textfield' => array(
|
||||
'placeholder' => '',
|
||||
),
|
||||
'link' => array(
|
||||
'placeholder_url' => '',
|
||||
'placeholder_title' => '',
|
||||
),
|
||||
'filefield_widget' => array(
|
||||
'progress_indicator' => $progress,
|
||||
),
|
||||
'imagefield_widget' => array(
|
||||
'progress_indicator' => $progress,
|
||||
'preview_image_style' => 'thumbnail',
|
||||
),
|
||||
'optionwidgets_onoff' => array(
|
||||
'display_label' => FALSE,
|
||||
),
|
||||
'phone_textfield' => array(
|
||||
'placeholder' => '',
|
||||
),
|
||||
);
|
||||
|
||||
return isset($settings[$widget_type]) ? $settings[$widget_type] : array();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldSettings.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Get the field settings.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "field_settings"
|
||||
* )
|
||||
*/
|
||||
class FieldSettings extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Get the field default/mapped settings.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($field_type, $global_settings, $widget_settings) = $value;
|
||||
return $this->getSettings($field_type, $global_settings, $widget_settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the default D8 and specified D6 settings.
|
||||
*
|
||||
* @param string $field_type
|
||||
* The field type.
|
||||
* @param array $global_settings
|
||||
* The field settings.
|
||||
* @param array $widget_settings
|
||||
* The widget settings needed for some settings.
|
||||
*
|
||||
* @return array
|
||||
* A valid array of settings.
|
||||
*/
|
||||
public function getSettings($field_type, $global_settings, $widget_settings) {
|
||||
$max_length = isset($global_settings['max_length']) ? $global_settings['max_length'] : '';
|
||||
$max_length = empty($max_length) ? 255 : $max_length;
|
||||
if (isset($global_settings['allowed_values'])) {
|
||||
$list = explode("\n", $global_settings['allowed_values']);
|
||||
$list = array_map('trim', $list);
|
||||
$list = array_filter($list, 'strlen');
|
||||
switch ($field_type) {
|
||||
case 'list_string':
|
||||
case 'list_integer':
|
||||
case 'list_float':
|
||||
foreach ($list as $value) {
|
||||
$value = explode("|", $value);
|
||||
$allowed_values[$value[0]] = isset($value[1]) ? $value[1] : $value[0];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$allowed_values = $list;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$allowed_values = '';
|
||||
}
|
||||
|
||||
$settings = array(
|
||||
'text' => array(
|
||||
'max_length' => $max_length,
|
||||
),
|
||||
'datetime' => array('datetime_type' => 'datetime'),
|
||||
'list_string' => array(
|
||||
'allowed_values' => $allowed_values,
|
||||
),
|
||||
'list_integer' => array(
|
||||
'allowed_values' => $allowed_values,
|
||||
),
|
||||
'list_float' => array(
|
||||
'allowed_values' => $allowed_values,
|
||||
),
|
||||
'boolean' => array(
|
||||
'allowed_values' => $allowed_values,
|
||||
),
|
||||
);
|
||||
|
||||
return isset($settings[$field_type]) ? $settings[$field_type] : array();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldTypeDefaults.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Gives us a change to set per field defaults.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "field_type_defaults"
|
||||
* )
|
||||
*/
|
||||
class FieldTypeDefaults extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
if (is_array($value)) {
|
||||
if ($row->getSourceProperty('module') == 'date') {
|
||||
$value = 'datetime_default';
|
||||
}
|
||||
else {
|
||||
throw new MigrateException(sprintf('Failed to lookup %s in the static map.', var_export($value, TRUE)));
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FileUri.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Process the file url into a D8 compatible URL.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "file_uri"
|
||||
* )
|
||||
*/
|
||||
class FileUri extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
|
||||
list($filepath, $file_directory_path, $temp_directory_path, $is_public) = $value;
|
||||
|
||||
// Specific handling using $temp_directory_path for temporary files.
|
||||
if (substr($filepath, 0, strlen($temp_directory_path)) === $temp_directory_path) {
|
||||
$uri = preg_replace('/^' . preg_quote($temp_directory_path, '/') . '/', '', $filepath);
|
||||
return "temporary://$uri";
|
||||
}
|
||||
|
||||
// Strip the files path from the uri instead of using basename
|
||||
// so any additional folders in the path are preserved.
|
||||
$uri = preg_replace('/^' . preg_quote($file_directory_path, '/') . '/', '', $filepath);
|
||||
|
||||
return $is_public ? "public://$uri" : "private://$uri";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FilterFormatPermission.
|
||||
*/
|
||||
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Plugin\MigrateProcessInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Migrate filter format serial to string id in permission name.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "filter_format_permission",
|
||||
* handle_multiples = TRUE
|
||||
* )
|
||||
*/
|
||||
class FilterFormatPermission extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The migration plugin.
|
||||
*
|
||||
* @var \Drupal\migrate\Plugin\MigrateProcessInterface
|
||||
*/
|
||||
protected $migrationPlugin;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MigrateProcessInterface $migration_plugin) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->migration = $migration;
|
||||
$this->migrationPlugin = $migration_plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('plugin.manager.migrate.process')->createInstance('migration', array('migration' => 'd6_filter_format'), $migration)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Migrate filter format serial to string id in permission name.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$rid = $row->getSourceProperty('rid');
|
||||
if ($formats = $row->getSourceProperty("filter_permissions:$rid")) {
|
||||
foreach ($formats as $format) {
|
||||
$new_id = $this->migrationPlugin->transform($format, $migrate_executable, $row, $destination_property);
|
||||
if ($new_id) {
|
||||
$value[] = 'use text format ' . $new_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\InternalUri.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Process a path into an 'internal:' URI.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "internal_uri"
|
||||
* )
|
||||
*/
|
||||
class InternalUri extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($path) = $value;
|
||||
|
||||
if (parse_url($path, PHP_URL_SCHEME) === NULL) {
|
||||
return 'internal:/' . $path;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\ProfileFieldSettings.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_profile_field_settings"
|
||||
* )
|
||||
*/
|
||||
class ProfileFieldSettings extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the profile field settings configuration.
|
||||
*/
|
||||
public function transform($type, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$settings = array();
|
||||
switch ($type) {
|
||||
case 'date':
|
||||
$settings['datetime_type'] = 'date';
|
||||
break;
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\UserPicture.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Plugin\MigrateProcessInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* The user picture process plugin.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_user_picture"
|
||||
* )
|
||||
*/
|
||||
class UserPicture extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The migration plugin.
|
||||
*
|
||||
* @var \Drupal\migrate\Plugin\MigrateProcessInterface
|
||||
*/
|
||||
protected $migrationPlugin;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration, MigrateProcessInterface $migration_plugin) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->migration = $migration;
|
||||
$this->migrationPlugin = $migration_plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('plugin.manager.migrate.process')->createInstance('migration', array('migration' => 'd6_user_picture_file'), $migration)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
return $row->getSourceProperty('picture') ? $this->migrationPlugin->transform($value, $migrate_executable, $row, $destination_property) : NULL;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\UserUpdate7002.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Converts user time zones from time zone offsets to time zone names.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "user_update_7002"
|
||||
* )
|
||||
*/
|
||||
class UserUpdate7002 extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* System timezones.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $timezones;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
if (!isset(static::$timezones)) {
|
||||
static::$timezones = system_time_zones();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$timezone = NULL;
|
||||
|
||||
if ($row->hasSourceProperty('timezone_name')) {
|
||||
if (isset(static::$timezones[$row->getSourceProperty('timezone_name')])) {
|
||||
$timezone = $row->getSourceProperty('timezone_name');
|
||||
}
|
||||
}
|
||||
if (!$timezone && $row->hasSourceProperty('event_timezone')) {
|
||||
if (isset(static::$timezones[$row->getSourceProperty('event_timezone')])) {
|
||||
$timezone = $row->getSourceProperty('event_timezone');
|
||||
}
|
||||
}
|
||||
|
||||
return $timezone;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\UserUpdate8002.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Keep the predefined roles for rid 1 and 2.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "user_update_8002"
|
||||
* )
|
||||
*/
|
||||
class UserUpdate8002 extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Keep the predefined roles for rid 1 and 2.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$rid = $row->getSourceProperty('rid');
|
||||
$map = array(
|
||||
1 => 'anonymous',
|
||||
2 => 'authenticated',
|
||||
);
|
||||
return isset($map[$rid]) ? $map[$rid] : $value;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\CckFieldRevision.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
* Drupal 6 cck field revision source.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_cck_field_revision"
|
||||
* )
|
||||
*/
|
||||
class CckFieldRevision extends CckFieldValues {
|
||||
|
||||
/**
|
||||
* The join options between the node and the node_revisions_table.
|
||||
*/
|
||||
const JOIN = 'n.nid = nr.nid AND n.vid <> nr.vid';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
// Use all the node fields plus the vid that identifies the version.
|
||||
return parent::fields() + array('vid' => t('The primary identifier for this version.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['vid']['type'] = 'integer';
|
||||
$ids['vid']['alias'] = 'nr';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,318 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\CckFieldValues.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Plugin\SourceEntityInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate_drupal\Plugin\CckFieldMigrateSourceInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Drupal 6 cck field source.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_cck_field_values"
|
||||
* )
|
||||
*/
|
||||
class CckFieldValues extends DrupalSqlBase implements SourceEntityInterface, CckFieldMigrateSourceInterface {
|
||||
|
||||
/**
|
||||
* The join options between the node and the node_revisions table.
|
||||
*/
|
||||
const JOIN = 'n.vid = nr.vid';
|
||||
|
||||
/**
|
||||
* The source field information for complex node fields.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $sourceFieldInfo;
|
||||
|
||||
/**
|
||||
* Information on which tables exist.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $tables;
|
||||
|
||||
/**
|
||||
* TRUE when CCK is enabled and the schema is correct.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $cckSchemaCorrect;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Select node in its last revision.
|
||||
$query = $this->select('node_revisions', 'nr')
|
||||
->fields('n', array(
|
||||
'nid',
|
||||
'type',
|
||||
))
|
||||
->fields('nr', array(
|
||||
'vid',
|
||||
))
|
||||
->condition('type', $this->configuration['bundle']);
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$bundle = $row->getSourceProperty('type');
|
||||
// Pick up simple CCK fields.
|
||||
$cck_table = "content_type_$bundle";
|
||||
if ($this->tableExists($cck_table)) {
|
||||
$query = $this->select($cck_table, 'f')->condition('vid', $row->getSourceProperty('vid'));
|
||||
// The main column for the field should be rendered with the field name,
|
||||
// not the column name (e.g., field_foo rather than field_foo_value).
|
||||
$field_info = $this->getSourceFieldInfo($bundle);
|
||||
foreach ($field_info as $field_name => $info) {
|
||||
if (isset($info['columns']) && !$info['multiple'] && $info['db_storage']) {
|
||||
$i = 0;
|
||||
$data = FALSE;
|
||||
foreach ($info['columns'] as $display_name => $column_name) {
|
||||
if ($i++ == 0) {
|
||||
$query->addField('f', $column_name, $field_name);
|
||||
}
|
||||
else {
|
||||
// The database API won't allow colons in column aliases, so we
|
||||
// will accept the default alias, and fix up the field names later.
|
||||
// Remember how to translate the field names.
|
||||
if ($info['type'] == 'filefield' &&
|
||||
(strpos($display_name, ':list') || strpos($display_name, ':description'))) {
|
||||
if (!$data) {
|
||||
//$this->fileDataFields[] = $field_name . '_data';
|
||||
$query->addField('f', $field_name . '_data');
|
||||
$data = TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$query->addField('f', $column_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The $query only contains single value CCK fields and so when the only
|
||||
// CCK field attached to a content type is a multi-valued CCK field then
|
||||
// this query would be invalid. Checking the count tells us if any single
|
||||
// fields have been added the query.
|
||||
if (count($query->getFields())) {
|
||||
if ($results = $query->execute()->fetchAssoc()) {
|
||||
$source = $row->getSource();
|
||||
// We diff the results with the source to find any field columns
|
||||
// in the content type's main table.
|
||||
$new_fields = array_diff_key($results, $source);
|
||||
foreach ($new_fields as $key => $value) {
|
||||
$row->setSourceProperty($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle fields that have their own table.
|
||||
foreach ($this->getSourceFieldInfo($bundle) as $field_name => $field_info) {
|
||||
if ($field_info['multiple'] || !$field_info['db_storage']) {
|
||||
// Select the data.
|
||||
$table = "content_$field_name";
|
||||
$field_query = $this
|
||||
->select($table, 't')
|
||||
->condition('vid', $row->getSourceProperty('vid'));
|
||||
if ($field_info['multiple']) {
|
||||
$field_query->addField('t', 'delta');
|
||||
}
|
||||
$data = FALSE;
|
||||
foreach ($field_info['columns'] as $display_name => $column_name) {
|
||||
// The database API won't allow colons in column aliases, so we
|
||||
// will accept the default alias, and fix up the field names later.
|
||||
// Remember how to translate the field names.
|
||||
if ($field_info['type'] == 'filefield' &&
|
||||
(strpos($display_name, ':list') || strpos($display_name, ':description'))) {
|
||||
if (!$data) {
|
||||
//$this->fileDataFields[] = $field_name . '_data';
|
||||
$field_query->addField('t', $field_name . '_data');
|
||||
$data = TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$field_query->addField('t', $column_name);
|
||||
}
|
||||
}
|
||||
|
||||
if ($field_info['multiple']) {
|
||||
foreach ($field_query->execute() as $field_row) {
|
||||
foreach ($field_info['columns'] as $display_name => $column_name) {
|
||||
list ( , $column) = explode(':', $display_name);
|
||||
$property_path = $field_name . Row::PROPERTY_SEPARATOR . $field_row['delta'] . Row::PROPERTY_SEPARATOR . $column;
|
||||
$row->setSourceProperty($property_path, $field_row[$column_name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($field_row = $field_query->execute()->fetchAssoc()) {
|
||||
foreach ($field_info['columns'] as $display_name => $column_name) {
|
||||
$row->setSourceProperty(str_replace(':', Row::PROPERTY_SEPARATOR, $display_name), $field_row[$column_name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the complex field info.
|
||||
*
|
||||
* @param string $bundle
|
||||
* The bundle for which fields we want.
|
||||
*
|
||||
* @return array
|
||||
* An array of field info keyed by field name.
|
||||
*/
|
||||
protected function getSourceFieldInfo($bundle) {
|
||||
if (!isset($this->sourceFieldInfo)) {
|
||||
$this->sourceFieldInfo = array();
|
||||
if ($this->tableExists('content_node_field_instance')) {
|
||||
// Get each field attached to this type.
|
||||
$query = $this->select('content_node_field_instance', 'i')
|
||||
->fields('i', array(
|
||||
'label',
|
||||
'widget_settings',
|
||||
'field_name',
|
||||
))
|
||||
->condition('type_name', $bundle);
|
||||
|
||||
$query->innerJoin('content_node_field', 'f', 'i.field_name = f.field_name');
|
||||
$query->fields('f', array(
|
||||
'field_name',
|
||||
'type',
|
||||
'db_columns',
|
||||
'global_settings',
|
||||
'multiple',
|
||||
'db_storage')
|
||||
);
|
||||
|
||||
$results = $query->execute();
|
||||
foreach ($results as $row) {
|
||||
$field_name = trim($row['field_name']);
|
||||
$db_columns = $db_columns = !empty($row['db_columns']) ? unserialize($row['db_columns']) : array();
|
||||
$columns = array();
|
||||
foreach ($db_columns as $column_name => $column_info) {
|
||||
// Special handling for the stuff packed into filefield's "data"
|
||||
if ($row['type'] == 'filefield' && $column_name == 'data') {
|
||||
$widget_settings = unserialize($row['widget_settings']);
|
||||
$global_settings = unserialize($row['global_settings']);
|
||||
|
||||
if (!empty($widget_settings['custom_alt'])) {
|
||||
$columns[$field_name . ':alt'] = $field_name . '_alt';
|
||||
}
|
||||
if (!empty($widget_settings['custom_title'])) {
|
||||
$columns[$field_name . ':title'] = $field_name . '_title';
|
||||
}
|
||||
if (!empty($global_settings['description_field'])) {
|
||||
$columns[$field_name . ':description'] = $field_name . '_description';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$display_name = $field_name . ':' . $column_name;
|
||||
$column_name = $field_name . '_' . $column_name;
|
||||
$columns[$display_name] = $column_name;
|
||||
}
|
||||
}
|
||||
$this->sourceFieldInfo[$field_name] = array(
|
||||
'label' => $row['label'],
|
||||
'type' => $row['type'],
|
||||
'columns' => $columns,
|
||||
'multiple' => $row['multiple'],
|
||||
'db_storage' => $row['db_storage'],
|
||||
'bundle' => $bundle,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->sourceFieldInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = array(
|
||||
'nid' => $this->t('Node ID'),
|
||||
'type' => $this->t('Type'),
|
||||
);
|
||||
foreach ($this->getSourceFieldInfo($this->configuration['bundle']) as $field_name => $field_data) {
|
||||
$fields[$field_name] = $field_data['label'];
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fieldData() {
|
||||
$field_info = $this->getSourceFieldInfo($this->configuration['bundle']);
|
||||
$field_info['nid'] = ['type' => 'number'];
|
||||
$field_info['type'] = ['type' => 'varchar'];
|
||||
return $field_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['nid']['type'] = 'integer';
|
||||
$ids['nid']['alias'] = 'n';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bundleMigrationRequired() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityTypeId() {
|
||||
return 'node';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a specific CCK table exists.
|
||||
*/
|
||||
protected function tableExists($table) {
|
||||
if (!isset($this->tables[$table])) {
|
||||
$this->tables[$table] = $this->cckSchemaCorrect() && $this->getDatabase()->schema()->tableExists($table);
|
||||
}
|
||||
return $this->tables[$table];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether CCK is enabled and is using the right schema.
|
||||
*/
|
||||
protected function cckSchemaCorrect() {
|
||||
if (!isset($this->cckSchemaCorrect)) {
|
||||
$this->cckSchemaCorrect = $this->moduleExists('content') && $this->getModuleSchemaVersion('content') >= 6001;
|
||||
}
|
||||
return $this->cckSchemaCorrect;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Comment.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 comment source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_comment",
|
||||
* source_provider = "comment"
|
||||
* )
|
||||
*/
|
||||
class Comment extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('comments', 'c')
|
||||
->fields('c', array('cid', 'pid', 'nid', 'uid', 'subject',
|
||||
'comment', 'hostname', 'timestamp', 'status', 'thread', 'name',
|
||||
'mail', 'homepage', 'format'));
|
||||
$query->innerJoin('node', 'n', 'c.nid = n.nid');
|
||||
$query->fields('n', array('type'));
|
||||
$query->orderBy('c.timestamp');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
if ($this->variableGet('comment_subject_field_' . $row->getSourceProperty('type'), 1)) {
|
||||
// Comment subject visible.
|
||||
$row->setSourceProperty('field_name', 'comment');
|
||||
$row->setSourceProperty('comment_type', 'comment');
|
||||
}
|
||||
else {
|
||||
$row->setSourceProperty('field_name', 'comment_no_subject');
|
||||
$row->setSourceProperty('comment_type', 'comment_no_subject');
|
||||
}
|
||||
// In D6, status=0 means published, while in D8 means the opposite.
|
||||
// See https://www.drupal.org/node/237636.
|
||||
$row->setSourceProperty('status', !$row->getSourceProperty('status'));
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'cid' => $this->t('Comment ID.'),
|
||||
'pid' => $this->t('Parent comment ID. If set to 0, this comment is not a reply to an existing comment.'),
|
||||
'nid' => $this->t('The {node}.nid to which this comment is a reply.'),
|
||||
'uid' => $this->t('The {users}.uid who authored the comment. If set to 0, this comment was created by an anonymous user.'),
|
||||
'subject' => $this->t('The comment title.'),
|
||||
'comment' => $this->t('The comment body.'),
|
||||
'hostname' => $this->t("The author's host name."),
|
||||
'timestamp' => $this->t('The time that the comment was created, or last edited by its author, as a Unix timestamp.'),
|
||||
'status' => $this->t('The published status of a comment. (0 = Published, 1 = Not Published)'),
|
||||
'format' => $this->t('The {filter_formats}.format of the comment body.'),
|
||||
'thread' => $this->t("The vancode representation of the comment's place in a thread."),
|
||||
'name' => $this->t("The comment author's name. Uses {users}.name if the user is logged in, otherwise uses the value typed into the comment form."),
|
||||
'mail' => $this->t("The comment author's email address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
|
||||
'homepage' => $this->t("The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
|
||||
'type' => $this->t("The {node}.type to which this comment is a reply."),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['cid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\CommentVariable.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Plugin\migrate\source\DummyQueryTrait;
|
||||
|
||||
/**
|
||||
* @MigrateSource(
|
||||
* id = "d6_comment_variable"
|
||||
* )
|
||||
*/
|
||||
class CommentVariable extends DrupalSqlBase {
|
||||
|
||||
use DummyQueryTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
return new \ArrayIterator($this->getCommentVariables());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->getCommentVariables());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the values of the comment variables grouped by node type.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getCommentVariables() {
|
||||
$comment_prefixes = array_keys($this->commentPrefixes());
|
||||
$variables = array();
|
||||
$node_types = $this->getDatabase()->query('SELECT type FROM {node_type}')->fetchCol();
|
||||
foreach ($node_types as $node_type) {
|
||||
foreach ($comment_prefixes as $prefix) {
|
||||
$variables[] = $prefix . '_' . $node_type;
|
||||
}
|
||||
}
|
||||
$return = array();
|
||||
$values = $this->getDatabase()->query('SELECT name, value FROM {variable} WHERE name IN ( :name[] )', array(':name[]' => $variables))->fetchAllKeyed();
|
||||
foreach ($node_types as $node_type) {
|
||||
foreach ($comment_prefixes as $prefix) {
|
||||
$name = $prefix . '_' . $node_type;
|
||||
if (isset($values[$name])) {
|
||||
$return[$node_type][$prefix] = unserialize($values[$name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// The return key will not be used so move it inside the row. This could
|
||||
// not be done sooner because otherwise empty rows would be created with
|
||||
// just the node type in it.
|
||||
foreach ($return as $node_type => $data) {
|
||||
$return[$node_type]['node_type'] = $node_type;
|
||||
$return[$node_type]['comment_type'] = empty($data['comment_subject_field']) ?
|
||||
'comment_no_subject' : 'comment';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return $this->commentPrefixes() + array(
|
||||
'node_type' => $this->t('The node type'),
|
||||
'comment_type' => $this->t('The comment type'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comment related data for fields.
|
||||
*/
|
||||
protected function commentPrefixes() {
|
||||
return array(
|
||||
'comment' => $this->t('Default comment setting'),
|
||||
'comment_default_mode' => $this->t('Default display mode'),
|
||||
'comment_default_order' => $this->t('Default display order'),
|
||||
'comment_default_per_page' => $this->t('Default comments per page'),
|
||||
'comment_controls' => $this->t('Comment controls'),
|
||||
'comment_anonymous' => $this->t('Anonymous commenting'),
|
||||
'comment_subject_field' => $this->t('Comment subject field'),
|
||||
'comment_preview' => $this->t('Preview comment'),
|
||||
'comment_form_location' => $this->t('Location of comment submission form'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['node_type']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\CommentVariablePerCommentType.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
* @MigrateSource(
|
||||
* id = "d6_comment_variable_per_comment_type"
|
||||
* )
|
||||
*/
|
||||
class CommentVariablePerCommentType extends CommentVariable {
|
||||
|
||||
/**
|
||||
* Retrieves the values of the comment variables grouped by comment type.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getCommentVariables() {
|
||||
$node_types = parent::getCommentVariables();
|
||||
// The return key used to separate comment types with hidden subject field.
|
||||
$return = array();
|
||||
foreach ($node_types as $node_type => $data) {
|
||||
// Only 2 comment types depending on subject field visibility.
|
||||
if (empty($data['comment_subject_field'])) {
|
||||
// Default label and description should be set in migration.
|
||||
$return['comment'] = array(
|
||||
'comment_type' => 'comment',
|
||||
'label' => $this->t('Default comments'),
|
||||
'description' => $this->t('Allows commenting on content')
|
||||
);
|
||||
}
|
||||
else {
|
||||
// Provide a special comment type with hidden subject field.
|
||||
$return['comment_no_subject'] = array(
|
||||
'comment_type' => 'comment_no_subject',
|
||||
'label' => $this->t('Comments without subject field'),
|
||||
'description' => $this->t('Allows commenting on content, comments without subject field')
|
||||
);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'comment_type' => $this->t('The comment type'),
|
||||
'label' => $this->t('The comment type label'),
|
||||
'description' => $this->t('The comment type description'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['comment_type']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Field.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 field source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_field",
|
||||
* source_provider = "content"
|
||||
* )
|
||||
*/
|
||||
class Field extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('content_node_field', 'cnf')
|
||||
->fields('cnf', array(
|
||||
'field_name',
|
||||
'type',
|
||||
'global_settings',
|
||||
'required',
|
||||
'multiple',
|
||||
'db_storage',
|
||||
'module',
|
||||
'db_columns',
|
||||
'active',
|
||||
'locked',
|
||||
))
|
||||
->fields('cnfi', array(
|
||||
'widget_type',
|
||||
'widget_settings',
|
||||
));
|
||||
$query->join('content_node_field_instance', 'cnfi', 'cnfi.field_name = cnf.field_name');
|
||||
$query->orderBy('field_name');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'field_name' => $this->t('Field name'),
|
||||
'type' => $this->t('Type (text, integer, ....)'),
|
||||
'global_settings' => $this->t('Global settings. Shared with every field instance.'),
|
||||
'required' => $this->t('Required'),
|
||||
'multiple' => $this->t('Multiple'),
|
||||
'db_storage' => $this->t('DB storage'),
|
||||
'module' => $this->t('Module'),
|
||||
'db_columns' => $this->t('DB Columns'),
|
||||
'active' => $this->t('Active'),
|
||||
'locked' => $this->t('Locked'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// Unserialize data.
|
||||
$global_settings = unserialize($row->getSourceProperty('global_settings'));
|
||||
$widget_settings = unserialize($row->getSourceProperty('widget_settings'));
|
||||
$db_columns = unserialize($row->getSourceProperty('db_columns'));
|
||||
$row->setSourceProperty('global_settings', $global_settings);
|
||||
$row->setSourceProperty('widget_settings', $widget_settings);
|
||||
$row->setSourceProperty('db_columns', $db_columns);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['field_name'] = array(
|
||||
'type' => 'string',
|
||||
'alias' => 'cnf',
|
||||
);
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\FieldInstance.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 field instances source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_field_instance",
|
||||
* source_provider = "content"
|
||||
* )
|
||||
*/
|
||||
class FieldInstance extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('content_node_field_instance', 'cnfi')
|
||||
->fields('cnfi', array(
|
||||
'field_name',
|
||||
'type_name',
|
||||
'weight',
|
||||
'label',
|
||||
'widget_type',
|
||||
'widget_settings',
|
||||
'display_settings',
|
||||
'description',
|
||||
'widget_module',
|
||||
'widget_active',
|
||||
'description',
|
||||
))
|
||||
->fields('cnf', array(
|
||||
'required',
|
||||
'active',
|
||||
'global_settings',
|
||||
));
|
||||
|
||||
$query->join('content_node_field', 'cnf', 'cnf.field_name = cnfi.field_name');
|
||||
$query->orderBy('weight');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'field_name' => $this->t('The machine name of field.'),
|
||||
'type_name' => $this->t('Content type where is used this field.'),
|
||||
'weight' => $this->t('Weight.'),
|
||||
'label' => $this->t('A name to show.'),
|
||||
'widget_type' => $this->t('Widget type.'),
|
||||
'widget_settings' => $this->t('Serialize data with widget settings.'),
|
||||
'display_settings' => $this->t('Serialize data with display settings.'),
|
||||
'description' => $this->t('A description of field.'),
|
||||
'widget_module' => $this->t('Module that implements widget.'),
|
||||
'widget_active' => $this->t('Status of widget'),
|
||||
'module' => $this->t('The module that provides the field.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// Unserialize data.
|
||||
$widget_settings = unserialize($row->getSourceProperty('widget_settings'));
|
||||
$display_settings = unserialize($row->getSourceProperty('display_settings'));
|
||||
$global_settings = unserialize($row->getSourceProperty('global_settings'));
|
||||
$row->setSourceProperty('widget_settings', $widget_settings);
|
||||
$row->setSourceProperty('display_settings', $display_settings);
|
||||
$row->setSourceProperty('global_settings', $global_settings);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids = array(
|
||||
'field_name' => array(
|
||||
'type' => 'string',
|
||||
'alias' => 'cnfi',
|
||||
),
|
||||
'type_name' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
);
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\FieldInstancePerFormDisplay.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* The field instance per form display source class.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_field_instance_per_form_display"
|
||||
* )
|
||||
*/
|
||||
class FieldInstancePerFormDisplay extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$rows = array();
|
||||
$result = $this->prepareQuery()->execute();
|
||||
while ($field_row = $result->fetchAssoc()) {
|
||||
$field_row['display_settings'] = unserialize($field_row['display_settings']);
|
||||
$field_row['widget_settings'] = unserialize($field_row['widget_settings']);
|
||||
$bundle = $field_row['type_name'];
|
||||
$field_name = $field_row['field_name'];
|
||||
|
||||
$index = "$bundle.$field_name";
|
||||
$rows[$index]['type_name'] = $bundle;
|
||||
$rows[$index]['widget_active'] = (bool) $field_row['widget_active'];
|
||||
$rows[$index]['field_name'] = $field_name;
|
||||
$rows[$index]['type'] = $field_row['type'];
|
||||
$rows[$index]['module'] = $field_row['module'];
|
||||
$rows[$index]['weight'] = $field_row['weight'];
|
||||
$rows[$index]['widget_type'] = $field_row['widget_type'];
|
||||
$rows[$index]['widget_settings'] = $field_row['widget_settings'];
|
||||
}
|
||||
|
||||
return new \ArrayIterator($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('content_node_field_instance', 'cnfi')
|
||||
->fields('cnfi', array(
|
||||
'field_name',
|
||||
'type_name',
|
||||
'weight',
|
||||
'label',
|
||||
'widget_type',
|
||||
'widget_settings',
|
||||
'display_settings',
|
||||
'description',
|
||||
'widget_module',
|
||||
'widget_active',
|
||||
))
|
||||
->fields('cnf', array(
|
||||
'type',
|
||||
'module',
|
||||
));
|
||||
$query->join('content_node_field', 'cnf', 'cnfi.field_name = cnf.field_name');
|
||||
$query->orderBy('weight');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'field_name' => $this->t('The machine name of field.'),
|
||||
'type_name' => $this->t('Content type where this field is used.'),
|
||||
'weight' => $this->t('Weight.'),
|
||||
'label' => $this->t('A name to show.'),
|
||||
'widget_type' => $this->t('Widget type.'),
|
||||
'widget_settings' => $this->t('Serialize data with widget settings.'),
|
||||
'display_settings' => $this->t('Serialize data with display settings.'),
|
||||
'description' => $this->t('A description of field.'),
|
||||
'widget_module' => $this->t('Module that implements widget.'),
|
||||
'widget_active' => $this->t('Status of widget'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['type_name']['type'] = 'string';
|
||||
$ids['field_name']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\FieldInstancePerViewMode.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\node\Plugin\migrate\source\d6\ViewModeBase;
|
||||
|
||||
/**
|
||||
* The field instance per view mode source class.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_field_instance_per_view_mode",
|
||||
* source_provider = "content"
|
||||
* )
|
||||
*/
|
||||
class FieldInstancePerViewMode extends ViewModeBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$rows = array();
|
||||
$result = $this->prepareQuery()->execute();
|
||||
while ($field_row = $result->fetchAssoc()) {
|
||||
// These are added to every view mode row.
|
||||
$field_row['display_settings'] = unserialize($field_row['display_settings']);
|
||||
$field_row['widget_settings'] = unserialize($field_row['widget_settings']);
|
||||
$bundle = $field_row['type_name'];
|
||||
$field_name = $field_row['field_name'];
|
||||
|
||||
foreach ($this->getViewModes() as $view_mode) {
|
||||
if (isset($field_row['display_settings'][$view_mode]) && empty($field_row['display_settings'][$view_mode]['exclude'])) {
|
||||
$index = $view_mode . "." . $bundle . "." . $field_name;
|
||||
$rows[$index]['entity_type'] = 'node';
|
||||
$rows[$index]['view_mode'] = $view_mode;
|
||||
$rows[$index]['type_name'] = $bundle;
|
||||
$rows[$index]['field_name'] = $field_name;
|
||||
$rows[$index]['type'] = $field_row['type'];
|
||||
$rows[$index]['module'] = $field_row['module'];
|
||||
$rows[$index]['weight'] = $field_row['weight'];
|
||||
$rows[$index]['label'] = $field_row['display_settings']['label']['format'];
|
||||
$rows[$index]['display_settings'] = $field_row['display_settings'][$view_mode];
|
||||
$rows[$index]['widget_settings'] = $field_row['widget_settings'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new \ArrayIterator($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('content_node_field_instance', 'cnfi')
|
||||
->fields('cnfi', array(
|
||||
'field_name',
|
||||
'type_name',
|
||||
'weight',
|
||||
'label',
|
||||
'display_settings',
|
||||
'widget_settings',
|
||||
))
|
||||
->fields('cnf', array(
|
||||
'type',
|
||||
'module',
|
||||
));
|
||||
$query->join('content_node_field', 'cnf', 'cnfi.field_name = cnf.field_name');
|
||||
$query->orderBy('weight');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'field_name' => $this->t('The machine name of field.'),
|
||||
'type_name' => $this->t('Content type where this field is used.'),
|
||||
'weight' => $this->t('Weight.'),
|
||||
'label' => $this->t('A name to show.'),
|
||||
'widget_type' => $this->t('Widget type.'),
|
||||
'widget_settings' => $this->t('Serialize data with widget settings.'),
|
||||
'display_settings' => $this->t('Serialize data with display settings.'),
|
||||
'description' => $this->t('A description of field.'),
|
||||
'widget_module' => $this->t('Module that implements widget.'),
|
||||
'widget_active' => $this->t('Status of widget'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['type_name']['type'] = 'string';
|
||||
$ids['view_mode']['type'] = 'string';
|
||||
$ids['entity_type']['type'] = 'string';
|
||||
$ids['field_name']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\File.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 file source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_file"
|
||||
* )
|
||||
*/
|
||||
class File extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* The file directory path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $filePath;
|
||||
|
||||
/**
|
||||
* The temporary file path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tempFilePath;
|
||||
|
||||
/**
|
||||
* Flag for private or public file storage.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $isPublic;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('files', 'f')->fields('f', array(
|
||||
'fid',
|
||||
'uid',
|
||||
'filename',
|
||||
'filepath',
|
||||
'filemime',
|
||||
'filesize',
|
||||
'status',
|
||||
'timestamp',
|
||||
));
|
||||
$query->orderBy('timestamp');
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$site_path = isset($this->configuration['site_path']) ? $this->configuration['site_path'] : 'sites/default';
|
||||
$this->filePath = $this->variableGet('file_directory_path', $site_path . '/files') . '/';
|
||||
$this->tempFilePath = $this->variableGet('file_directory_temp', '/tmp') . '/';
|
||||
|
||||
// FILE_DOWNLOADS_PUBLIC == 1 and FILE_DOWNLOADS_PRIVATE == 2.
|
||||
$this->isPublic = $this->variableGet('file_downloads', 1) == 1;
|
||||
return parent::initializeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('file_directory_path', $this->filePath);
|
||||
$row->setSourceProperty('temp_directory_path', $this->tempFilePath);
|
||||
$row->setSourceProperty('is_public', $this->isPublic);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'fid' => $this->t('File ID'),
|
||||
'uid' => $this->t('The {users}.uid who added the file. If set to 0, this file was added by an anonymous user.'),
|
||||
'filename' => $this->t('File name'),
|
||||
'filepath' => $this->t('File path'),
|
||||
'filemime' => $this->t('File Mime Type'),
|
||||
'status' => $this->t('The published status of a file.'),
|
||||
'timestamp' => $this->t('The time that the file was added.'),
|
||||
'file_directory_path' => $this->t('The Drupal files path.'),
|
||||
'is_public' => $this->t('TRUE if the files directory is public otherwise FALSE.'),
|
||||
);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['fid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\ProfileField.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Drupal 6 profile fields source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_profile_field",
|
||||
* source_provider = "profile"
|
||||
* )
|
||||
*/
|
||||
class ProfileField extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('profile_fields', 'pf')
|
||||
->fields('pf', array(
|
||||
'fid',
|
||||
'title',
|
||||
'name',
|
||||
'explanation',
|
||||
'category',
|
||||
'page',
|
||||
'type',
|
||||
'weight',
|
||||
'required',
|
||||
'register',
|
||||
'visibility',
|
||||
'autocomplete',
|
||||
'options',
|
||||
));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
if ($row->getSourceProperty('type') == 'selection') {
|
||||
// Get the current options.
|
||||
$current_options = preg_split("/[\r\n]+/", $row->getSourceProperty('options'));
|
||||
// Select the list values from the profile_values table to ensure we get
|
||||
// them all since they can get out of sync with profile_fields.
|
||||
$options = $this->getDatabase()->query('SELECT DISTINCT value FROM {profile_values} WHERE fid = :fid', array(':fid' => $row->getSourceProperty('fid')))->fetchCol();
|
||||
$options = array_merge($current_options, $options);
|
||||
// array_combine() takes care of any duplicates options.
|
||||
$row->setSourceProperty('options', array_combine($options, $options));
|
||||
}
|
||||
|
||||
if ($row->getSourceProperty('type') == 'checkbox') {
|
||||
// D6 profile checkboxes values are always 0 or 1 (with no labels), so we
|
||||
// need to create two label-less options that will get 0 and 1 for their
|
||||
// keys.
|
||||
$row->setSourceProperty('options', array(NULL, NULL));
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'fid' => $this->t('Primary Key: Unique profile field ID.'),
|
||||
'title' => $this->t('Title of the field shown to the end user.'),
|
||||
'name' => $this->t('Internal name of the field used in the form HTML and URLs.'),
|
||||
'explanation' => $this->t('Explanation of the field to end users.'),
|
||||
'category' => $this->t('Profile category that the field will be grouped under.'),
|
||||
'page' => $this->t("Title of page used for browsing by the field's value"),
|
||||
'type' => $this->t('Type of form field.'),
|
||||
'weight' => $this->t('Weight of field in relation to other profile fields.'),
|
||||
'required' => $this->t('Whether the user is required to enter a value. (0 = no, 1 = yes)'),
|
||||
'register' => $this->t('Whether the field is visible in the user registration form. (1 = yes, 0 = no)'),
|
||||
'visibility' => $this->t('The level of visibility for the field. (0 = hidden, 1 = private, 2 = public on profile but not member list pages, 3 = public on profile and list pages)'),
|
||||
'autocomplete' => $this->t('Whether form auto-completion is enabled. (0 = disabled, 1 = enabled)'),
|
||||
'options' => $this->t('List of options to be used in a list selection field.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['fid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\ProfileFieldValues.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate\Plugin\SourceEntityInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
|
||||
/**
|
||||
* Drupal 6 profile fields values source.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_profile_field_values",
|
||||
* source_provider = "profile"
|
||||
* )
|
||||
*/
|
||||
class ProfileFieldValues extends DrupalSqlBase implements SourceEntityInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('profile_values', 'pv')
|
||||
->distinct()
|
||||
->fields('pv', array('fid', 'uid'));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// Find profile values for this row.
|
||||
$query = $this->select('profile_values', 'pv')
|
||||
->fields('pv', array('fid', 'value'));
|
||||
$query->leftJoin('profile_fields', 'pf', 'pf.fid=pv.fid');
|
||||
$query->fields('pf', array('name', 'type'));
|
||||
$query->condition('uid', $row->getSourceProperty('uid'));
|
||||
$results = $query->execute();
|
||||
|
||||
foreach ($results as $profile_value) {
|
||||
// Check special case for date. We need to unserialize.
|
||||
if ($profile_value['type'] == 'date') {
|
||||
$date = unserialize($profile_value['value']);
|
||||
$date = date('Y-m-d', mktime(0, 0, 0, $date['month'], $date['day'], $date['year']));
|
||||
$row->setSourceProperty($profile_value['name'], array('value' => $date));
|
||||
}
|
||||
elseif ($profile_value['type'] == 'list') {
|
||||
// Explode by newline and comma.
|
||||
$row->setSourceProperty($profile_value['name'], preg_split("/[\r\n,]+/", $profile_value['value']));
|
||||
}
|
||||
else {
|
||||
$row->setSourceProperty($profile_value['name'], array($profile_value['value']));
|
||||
}
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = array(
|
||||
'fid' => $this->t('Unique profile field ID.'),
|
||||
'uid' => $this->t('The user Id.'),
|
||||
'value' => $this->t('The value for this field.'),
|
||||
);
|
||||
|
||||
$query = $this->select('profile_values', 'pv')
|
||||
->fields('pv', array('fid', 'value'));
|
||||
$query->leftJoin('profile_fields', 'pf', 'pf.fid=pv.fid');
|
||||
$query->fields('pf', array('name', 'title'));
|
||||
$results = $query->execute();
|
||||
foreach ($results as $profile) {
|
||||
$fields[$profile['name']] = $this->t($profile['title']);
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return array(
|
||||
'uid' => array(
|
||||
'type' => 'integer',
|
||||
'alias' => 'pv',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bundleMigrationRequired() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityTypeId() {
|
||||
return 'user';
|
||||
}
|
||||
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Role.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 role source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_user_role"
|
||||
* )
|
||||
*/
|
||||
class Role extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* List of filter IDs per role IDs.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $filterPermissions = array();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('role', 'r')
|
||||
->fields('r', array('rid', 'name'))
|
||||
->orderBy('rid');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'rid' => $this->t('Role ID.'),
|
||||
'name' => $this->t('The name of the user role.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$filter_roles = $this->select('filter_formats', 'f')
|
||||
->fields('f', array('format', 'roles'))
|
||||
->execute()
|
||||
->fetchAllKeyed();
|
||||
foreach ($filter_roles as $format => $roles) {
|
||||
// Drupal 6 code: $roles = ','. implode(',', $roles) .',';
|
||||
// Remove the beginning and ending comma.
|
||||
foreach (explode(',', trim($roles, ',')) as $rid) {
|
||||
$this->filterPermissions[$rid][] = $format;
|
||||
}
|
||||
}
|
||||
return parent::initializeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$rid = $row->getSourceProperty('rid');
|
||||
$permissions = $this->select('permission', 'p')
|
||||
->fields('p', array('perm'))
|
||||
->condition('rid', $rid)
|
||||
->execute()
|
||||
->fetchField();
|
||||
$row->setSourceProperty('permissions', explode(', ', $permissions));
|
||||
if (isset($this->filterPermissions[$rid])) {
|
||||
$row->setSourceProperty("filter_permissions:$rid", $this->filterPermissions[$rid]);
|
||||
}
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['rid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Upload.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 upload source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_upload",
|
||||
* source_provider = "upload"
|
||||
* )
|
||||
*/
|
||||
class Upload extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* The join options between the node and the upload table.
|
||||
*/
|
||||
const JOIN = 'n.nid = u.nid AND n.vid = u.vid';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('upload', 'u')
|
||||
->distinct()
|
||||
->fields('u', array('nid', 'vid'));
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
$query->addField('n', 'type');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$query = $this->select('upload', 'u')
|
||||
->fields('u', array('fid', 'description', 'list'))
|
||||
->condition('u.nid', $row->getSourceProperty('nid'))
|
||||
->orderBy('u.weight');
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
$row->setSourceProperty('upload', $query->execute()->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'fid' => $this->t('The file Id.'),
|
||||
'nid' => $this->t('The node Id.'),
|
||||
'vid' => $this->t('The version Id.'),
|
||||
'type' => $this->t('The node type'),
|
||||
'description' => $this->t('The file description.'),
|
||||
'list' => $this->t('Whether the list should be visible on the node page.'),
|
||||
'weight' => $this->t('The file weight.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['vid']['type'] = 'integer';
|
||||
$ids['vid']['alias'] = 'u';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\UploadInstance.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Plugin\migrate\source\DummyQueryTrait;
|
||||
|
||||
/**
|
||||
* Drupal 6 upload instance source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_upload_instance",
|
||||
* source_provider = "upload"
|
||||
* )
|
||||
*/
|
||||
class UploadInstance extends DrupalSqlBase {
|
||||
|
||||
use DummyQueryTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$prefix = 'upload';
|
||||
$node_types = $this->getDatabase()->query('SELECT type FROM {node_type}')->fetchCol();
|
||||
foreach ($node_types as $node_type) {
|
||||
$variables[] = $prefix . '_' . $node_type;
|
||||
}
|
||||
|
||||
$max_filesize = $this->variableGet('upload_uploadsize_default', 1);
|
||||
$max_filesize = $max_filesize ? $max_filesize . 'MB' : '';
|
||||
$file_extensions = $this->variableGet('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');
|
||||
$return = array();
|
||||
$values = $this->getDatabase()->query('SELECT name, value FROM {variable} WHERE name IN ( :name[] )', array(':name[]' => $variables))->fetchAllKeyed();
|
||||
foreach ($node_types as $node_type) {
|
||||
$name = $prefix . '_' . $node_type;
|
||||
if (isset($values[$name])) {
|
||||
$enabled = unserialize($values[$name]);
|
||||
if ($enabled) {
|
||||
$return[$node_type]['node_type'] = $node_type;
|
||||
$return[$node_type]['max_filesize'] = $max_filesize;
|
||||
$return[$node_type]['file_extensions'] = $file_extensions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new \ArrayIterator($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return array(
|
||||
'node_type' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'node_type' => $this->t('Node type'),
|
||||
'max_filesize' => $this->t('Max filesize'),
|
||||
'file_extensions' => $this->t('File extensions'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->initializeIterator());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\User.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Plugin\SourceEntityInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 user source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_user"
|
||||
* )
|
||||
*/
|
||||
class User extends DrupalSqlBase implements SourceEntityInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('users', 'u')
|
||||
->fields('u', array_keys($this->baseFields()))
|
||||
->condition('uid', 1, '>');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = $this->baseFields();
|
||||
|
||||
// Add roles field.
|
||||
$fields['roles'] = $this->t('Roles');
|
||||
|
||||
// Profile fields.
|
||||
if ($this->moduleExists('profile')) {
|
||||
$fields += $this->select('profile_fields', 'pf')
|
||||
->fields('pf', array('name', 'title'))
|
||||
->execute()
|
||||
->fetchAllKeyed();
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// User roles.
|
||||
$roles = $this->select('users_roles', 'ur')
|
||||
->fields('ur', array('rid'))
|
||||
->condition('ur.uid', $row->getSourceProperty('uid'))
|
||||
->execute()
|
||||
->fetchCol();
|
||||
$row->setSourceProperty('roles', $roles);
|
||||
|
||||
// We are adding here the Event contributed module column.
|
||||
// @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
|
||||
if ($row->hasSourceProperty('timezone_id') && $row->getSourceProperty('timezone_id')) {
|
||||
if ($this->getDatabase()->schema()->tableExists('event_timezones')) {
|
||||
$event_timezone = $this->select('event_timezones', 'e')
|
||||
->fields('e', array('name'))
|
||||
->condition('e.timezone', $row->getSourceProperty('timezone_id'))
|
||||
->execute()
|
||||
->fetchField();
|
||||
if ($event_timezone) {
|
||||
$row->setSourceProperty('event_timezone', $event_timezone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Unserialize Data.
|
||||
$row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return array(
|
||||
'uid' => array(
|
||||
'type' => 'integer',
|
||||
'alias' => 'u',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user base fields to be migrated.
|
||||
*
|
||||
* @return array
|
||||
* Associative array having field name as key and description as value.
|
||||
*/
|
||||
protected function baseFields() {
|
||||
$fields = array(
|
||||
'uid' => $this->t('User ID'),
|
||||
'name' => $this->t('Username'),
|
||||
'pass' => $this->t('Password'),
|
||||
'mail' => $this->t('Email address'),
|
||||
'signature' => $this->t('Signature'),
|
||||
'signature_format' => $this->t('Signature format'),
|
||||
'created' => $this->t('Registered timestamp'),
|
||||
'access' => $this->t('Last access timestamp'),
|
||||
'login' => $this->t('Last login timestamp'),
|
||||
'status' => $this->t('Status'),
|
||||
'timezone' => $this->t('Timezone'),
|
||||
'language' => $this->t('Language'),
|
||||
'picture' => $this->t('Picture'),
|
||||
'init' => $this->t('Init'),
|
||||
'data' => $this->t('User data'),
|
||||
);
|
||||
|
||||
// Possible field added by Date contributed module.
|
||||
// @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
|
||||
if ($this->getDatabase()->schema()->fieldExists('users', 'timezone_name')) {
|
||||
$fields['timezone_name'] = $this->t('Timezone (Date)');
|
||||
}
|
||||
|
||||
// Possible field added by Event contributed module.
|
||||
// @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
|
||||
if ($this->getDatabase()->schema()->fieldExists('users', 'timezone_id')) {
|
||||
$fields['timezone_id'] = $this->t('Timezone (Event)');
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bundleMigrationRequired() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityTypeId() {
|
||||
return 'user';
|
||||
}
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\UserPicture.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 user picture source from database.
|
||||
*
|
||||
* @todo Support default picture?
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_user_picture"
|
||||
* )
|
||||
*/
|
||||
class UserPicture extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('users', 'u')
|
||||
->condition('picture', '', '<>')
|
||||
->fields('u', array('uid', 'access', 'picture'))
|
||||
->orderBy('access');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'uid' => 'Primary Key: Unique user ID.',
|
||||
'access' => 'Timestamp for previous time user accessed the site.',
|
||||
'picture' => "Path to the user's uploaded picture.",
|
||||
);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['uid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\UserPictureFile.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Drupal 6 user picture source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_user_picture_file"
|
||||
* )
|
||||
*/
|
||||
class UserPictureFile extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* The file directory path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $filePath;
|
||||
|
||||
/**
|
||||
* The temporary file path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tempFilePath;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('users', 'u')
|
||||
->condition('picture', '', '<>')
|
||||
->fields('u', array('uid', 'picture'));
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function initializeIterator() {
|
||||
$site_path = isset($this->configuration['site_path']) ? $this->configuration['site_path'] : 'sites/default';
|
||||
$this->filePath = $this->variableGet('file_directory_path', $site_path . '/files') . '/';
|
||||
$this->tempFilePath = $this->variableGet('file_directory_temp', '/tmp') . '/';
|
||||
return parent::initializeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('filename', basename($row->getSourceProperty('picture')));
|
||||
$row->setSourceProperty('file_directory_path', $this->filePath);
|
||||
$row->setSourceProperty('temp_directory_path', $this->tempFilePath);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'picture' => "Path to the user's uploaded picture.",
|
||||
'filename' => 'The picture filename.',
|
||||
);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['uid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\UserPictureInstance.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Plugin\migrate\source\DummyQueryTrait;
|
||||
|
||||
/**
|
||||
* Drupal 6 user picture field instance source.
|
||||
*
|
||||
* @todo Support default picture?
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_user_picture_instance"
|
||||
* )
|
||||
*/
|
||||
class UserPictureInstance extends DrupalSqlBase {
|
||||
|
||||
use DummyQueryTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function initializeIterator() {
|
||||
return new \ArrayIterator(array(
|
||||
array(
|
||||
'id' => '',
|
||||
'file_directory' => $this->variableGet('user_picture_path', 'pictures'),
|
||||
'max_filesize' => $this->variableGet('user_picture_file_size', '30') . 'KB',
|
||||
'max_resolution' => $this->variableGet('user_picture_dimensions', '85x85'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function count() {
|
||||
// This source provides a single row, corresponding to a single picture
|
||||
// field to be added to the user entity.
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'file_directory' => 'The directory to store images..',
|
||||
'max_filesize' => 'The maximum allowed file size in KBs.',
|
||||
'max_resolution' => "The maximum resolution.",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['id']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\system\Plugin\migrate\source\d6\Menu.
|
||||
*/
|
||||
|
||||
namespace Drupal\system\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 menu source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_menu",
|
||||
* source_provider = "menu"
|
||||
* )
|
||||
*/
|
||||
class Menu extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('menu_custom', 'm')
|
||||
->fields('m', array('menu_name', 'title', 'description'));
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'menu_name' => $this->t('The menu name. Primary key.'),
|
||||
'title' => $this->t('The human-readable name of the menu.'),
|
||||
'description' => $this->t('A description of the menu'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['menu_name']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\system\Tests\PhpStorage\PhpStorageFactoryTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\system\Tests\PhpStorage;
|
||||
|
||||
use Drupal\Component\PhpStorage\MTimeProtectedFileStorage;
|
||||
use Drupal\Core\PhpStorage\PhpStorageFactory;
|
||||
use Drupal\Core\Site\Settings;
|
||||
use Drupal\Core\StreamWrapper\PublicStream;
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
use Drupal\system\PhpStorage\MockPhpStorage;
|
||||
|
||||
/**
|
||||
* Tests the PHP storage factory.
|
||||
*
|
||||
* @group PhpStorage
|
||||
* @see \Drupal\Core\PhpStorage\PhpStorageFactory
|
||||
*/
|
||||
class PhpStorageFactoryTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* Tests the get() method with no settings.
|
||||
*/
|
||||
public function testGetNoSettings() {
|
||||
$php = PhpStorageFactory::get('test');
|
||||
// This should be the default class used.
|
||||
$this->assertTrue($php instanceof MTimeProtectedFileStorage, 'An MTimeProtectedFileStorage instance was returned with no settings.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the get() method using the 'default' settings.
|
||||
*/
|
||||
public function testGetDefault() {
|
||||
$this->setSettings();
|
||||
$php = PhpStorageFactory::get('test');
|
||||
$this->assertTrue($php instanceof MockPhpStorage, 'A FileReadOnlyStorage instance was returned with default settings.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the get() method with overridden settings.
|
||||
*/
|
||||
public function testGetOverride() {
|
||||
$this->setSettings('test');
|
||||
$php = PhpStorageFactory::get('test');
|
||||
// The FileReadOnlyStorage should be used from settings.
|
||||
$this->assertTrue($php instanceof MockPhpStorage, 'A MockPhpStorage instance was returned from overridden settings.');
|
||||
|
||||
// Test that the name is used for the bin when it is NULL.
|
||||
$this->setSettings('test', array('bin' => NULL));
|
||||
$php = PhpStorageFactory::get('test');
|
||||
$this->assertTrue($php instanceof MockPhpStorage, 'An MockPhpStorage instance was returned from overridden settings.');
|
||||
$this->assertIdentical('test', $php->getConfigurationValue('bin'), 'Name value was used for bin.');
|
||||
|
||||
// Test that a default directory is set if it's empty.
|
||||
$this->setSettings('test', array('directory' => NULL));
|
||||
$php = PhpStorageFactory::get('test');
|
||||
$this->assertTrue($php instanceof MockPhpStorage, 'An MockPhpStorage instance was returned from overridden settings.');
|
||||
$this->assertIdentical(\Drupal::root() . '/' . PublicStream::basePath() . '/php', $php->getConfigurationValue('directory'), 'Default file directory was used.');
|
||||
|
||||
// Test that a default storage class is set if it's empty.
|
||||
$this->setSettings('test', array('class' => NULL));
|
||||
$php = PhpStorageFactory::get('test');
|
||||
$this->assertTrue($php instanceof MTimeProtectedFileStorage, 'An MTimeProtectedFileStorage instance was returned from overridden settings with no class.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Settings() singleton.
|
||||
*
|
||||
* @param string $name
|
||||
* The storage bin name to set.
|
||||
* @param array $configuration
|
||||
* An array of configuration to set. Will be merged with default values.
|
||||
*/
|
||||
protected function setSettings($name = 'default', array $configuration = array()) {
|
||||
$settings['php_storage'][$name] = $configuration + array(
|
||||
'class' => 'Drupal\system\PhpStorage\MockPhpStorage',
|
||||
'directory' => 'tmp://',
|
||||
'secret' => $this->randomString(),
|
||||
'bin' => 'test',
|
||||
);
|
||||
new Settings($settings);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\system\Unit\Migrate\source\d6\MenuTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\system\Unit\Migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 menu source plugin.
|
||||
*
|
||||
* @group system
|
||||
*/
|
||||
class MenuTest 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\system\Plugin\migrate\source\d6\Menu';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
// This needs to be the identifier of the actual key: cid for comment, nid
|
||||
// for node and so on.
|
||||
'source' => array(
|
||||
'plugin' => 'd6_menu',
|
||||
),
|
||||
);
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'menu_name' => 'menu-name-1',
|
||||
'title' => 'menu custom value 1',
|
||||
'description' => 'menu custom description value 1',
|
||||
),
|
||||
array(
|
||||
'menu_name' => 'menu-name-2',
|
||||
'title' => 'menu custom value 2',
|
||||
'description' => 'menu custom description value 2',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
// This array stores the database.
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
$this->databaseContents['menu_custom'][$k] = $row;
|
||||
}
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\taxonomy\Plugin\migrate\load\d6\LoadTermNode.
|
||||
*/
|
||||
|
||||
namespace Drupal\taxonomy\Plugin\migrate\load\d6;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate\MigrateMessage;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity;
|
||||
|
||||
/**
|
||||
* @PluginID("d6_term_node")
|
||||
*/
|
||||
class LoadTermNode extends LoadEntity {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration) {
|
||||
$configuration['bundle_migration'] = 'd6_taxonomy_vocabulary';
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = NULL) {
|
||||
/** @var \Drupal\migrate\Entity\MigrationInterface $bundle_migration */
|
||||
$bundle_migration = $storage->load('d6_taxonomy_vocabulary');
|
||||
$migrate_executable = new MigrateExecutable($bundle_migration, new MigrateMessage());
|
||||
$process = array_intersect_key($bundle_migration->get('process'), $bundle_migration->getDestinationPlugin()->getIds());
|
||||
$migrations = array();
|
||||
$vid_map = array();
|
||||
foreach ($bundle_migration->getIdMap() as $key => $value) {
|
||||
$old_vid = unserialize($key)['sourceid1'];
|
||||
$new_vid = $value['destid1'];
|
||||
$vid_map[$old_vid] = $new_vid;
|
||||
}
|
||||
foreach ($bundle_migration->getSourcePlugin()->getIterator() as $source_row) {
|
||||
$row = new Row($source_row, $source_row);
|
||||
$migrate_executable->processRow($row, $process);
|
||||
$old_vid = $source_row['vid'];
|
||||
$new_vid = $row->getDestinationProperty('vid');
|
||||
$vid_map[$old_vid] = $new_vid;
|
||||
}
|
||||
foreach ($vid_map as $old_vid => $new_vid) {
|
||||
$values = $this->migration->toArray();
|
||||
$migration_id = $this->migration->id() . ':' . $old_vid;
|
||||
$values['id'] = $migration_id;
|
||||
$values['source']['vid'] = $old_vid;
|
||||
$values['process'][$new_vid] = 'tid';
|
||||
$migrations[$migration_id] = $storage->create($values);;
|
||||
}
|
||||
|
||||
return $migrations;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\text\Tests\Migrate\d6\MigrateTextConfigsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\text\Tests\Migrate\d6;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upgrade variables to text.settings.yml.
|
||||
*
|
||||
* @group text
|
||||
*/
|
||||
class MigrateTextConfigsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('text');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->loadDumps(['Variable.php']);
|
||||
$this->executeMigration('d6_text_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of text variables to text.settings.yml.
|
||||
*/
|
||||
public function testTextSettings() {
|
||||
$config = $this->config('text.settings');
|
||||
$this->assertIdentical(456, $config->get('default_summary_length'));
|
||||
$this->assertConfigSchema(\Drupal::service('config.typed'), 'text.settings', $config->get());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,165 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\Standards\DrupalStandardsListener.
|
||||
*
|
||||
* Listener for PHPUnit tests, to enforce various coding standards within test
|
||||
* runs.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\Standards;
|
||||
|
||||
/**
|
||||
* Listens for PHPUnit tests and fails those with invalid coverage annotations.
|
||||
*/
|
||||
class DrupalStandardsListener extends \PHPUnit_Framework_BaseTestListener {
|
||||
|
||||
/**
|
||||
* Signals a coding standards failure to the user.
|
||||
*
|
||||
* @param \PHPUnit_Framework_TestCase $test
|
||||
* The test where we should insert our test failure.
|
||||
* @param string $message
|
||||
* The message to add to the failure notice. The test class name and test
|
||||
* name will be appended to this message automatically.
|
||||
*/
|
||||
protected function fail(\PHPUnit_Framework_TestCase $test, $message) {
|
||||
// Add the report to the test's results.
|
||||
$message .= ': ' . get_class($test) . '::' . $test->getName();
|
||||
$fail = new \PHPUnit_Framework_AssertionFailedError($message);
|
||||
$result = $test->getTestResultObject();
|
||||
$result->addFailure($test, $fail, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to check if a string names a valid class or trait.
|
||||
*
|
||||
* @param string $class
|
||||
* Name of the class to check.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the class exists, FALSE otherwise.
|
||||
*/
|
||||
protected function classExists($class) {
|
||||
return class_exists($class, TRUE) || trait_exists($class, TRUE) || interface_exists($class, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check an individual test run for valid @covers annotation.
|
||||
*
|
||||
* This method is called from $this::endTest().
|
||||
*
|
||||
* @param \PHPUnit_Framework_TestCase $test
|
||||
* The test to examine.
|
||||
*/
|
||||
public function checkValidCoversForTest(\PHPUnit_Framework_TestCase $test) {
|
||||
// If we're generating a coverage report already, don't do anything here.
|
||||
if ($test->getTestResultObject() && $test->getTestResultObject()->getCollectCodeCoverageInformation()) {
|
||||
return;
|
||||
}
|
||||
// Gather our annotations.
|
||||
$annotations = $test->getAnnotations();
|
||||
// Glean the @coversDefaultClass annotation.
|
||||
$default_class = '';
|
||||
$valid_default_class = FALSE;
|
||||
if (isset($annotations['class']['coversDefaultClass'])) {
|
||||
if (count($annotations['class']['coversDefaultClass']) > 1) {
|
||||
$this->fail($test, '@coversDefaultClass has too many values');
|
||||
}
|
||||
// Grab the first one.
|
||||
$default_class = reset($annotations['class']['coversDefaultClass']);
|
||||
// Check whether the default class exists.
|
||||
$valid_default_class = $this->classExists($default_class);
|
||||
if (!$valid_default_class) {
|
||||
$this->fail($test, "@coversDefaultClass does not exist '$default_class'");
|
||||
}
|
||||
}
|
||||
// Glean @covers annotation.
|
||||
if (isset($annotations['method']['covers'])) {
|
||||
// Drupal allows multiple @covers per test method, so we have to check
|
||||
// them all.
|
||||
foreach ($annotations['method']['covers'] as $covers) {
|
||||
// Ensure the annotation isn't empty.
|
||||
if (trim($covers) === '') {
|
||||
$this->fail($test, '@covers should not be empty');
|
||||
// If @covers is empty, we can't proceed.
|
||||
return;
|
||||
}
|
||||
// Ensure we don't have ().
|
||||
if (strpos($covers, '()') !== FALSE) {
|
||||
$this->fail($test, "@covers invalid syntax: Do not use '()'");
|
||||
}
|
||||
// Glean the class and method from @covers.
|
||||
$class = $covers;
|
||||
$method = '';
|
||||
if (strpos($covers, '::') !== FALSE) {
|
||||
list($class, $method) = explode('::', $covers);
|
||||
}
|
||||
// Check for the existence of the class if it's specified by @covers.
|
||||
if (!empty($class)) {
|
||||
// If the class doesn't exist we have either a bad classname or
|
||||
// are missing the :: for a method. Either way we can't proceed.
|
||||
if (!$this->classExists($class)) {
|
||||
if (empty($method)) {
|
||||
$this->fail($test, "@covers invalid syntax: Needs '::' or class does not exist in $covers");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$this->fail($test, '@covers class does not exist ' . $class);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// The class isn't specified and we have the ::, so therefore this
|
||||
// test either covers a function, or relies on a default class.
|
||||
if (empty($default_class)) {
|
||||
// If there's no default class, then we need to check if the global
|
||||
// function exists. Since this listener should always be listening
|
||||
// for endTest(), the function should have already been loaded from
|
||||
// its .module or .inc file.
|
||||
if (!function_exists($method)) {
|
||||
$this->fail($test, '@covers global method does not exist ' . $method);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// We have a default class and this annotation doesn't act like a
|
||||
// global function, so we should use the default class if it's
|
||||
// valid.
|
||||
if ($valid_default_class) {
|
||||
$class = $default_class;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Finally, after all that, let's see if the method exists.
|
||||
if (!empty($class) && !empty($method)) {
|
||||
$ref_class = new \ReflectionClass($class);
|
||||
if (!$ref_class->hasMethod($method)) {
|
||||
$this->fail($test, '@covers method does not exist ' . $class . '::' . $method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function endTest(\PHPUnit_Framework_Test $test, $time) {
|
||||
// \PHPUnit_Framework_Test does not have any useful methods of its own for
|
||||
// our purpose, so we have to distinguish between the different known
|
||||
// subclasses.
|
||||
if ($test instanceof \PHPUnit_Framework_TestCase) {
|
||||
$this->checkValidCoversForTest($test);
|
||||
}
|
||||
elseif ($test instanceof \PHPUnit_Framework_TestSuite) {
|
||||
foreach ($test->getGroupDetails() as $tests) {
|
||||
foreach ($tests as $test) {
|
||||
$this->endTest($test, $time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue