Update to Drupal 8.0.0-rc3. For more information, see https://www.drupal.org/node/2608078
This commit is contained in:
parent
6419a031d7
commit
4afb23bbd3
762 changed files with 20080 additions and 6368 deletions
|
@ -17,7 +17,7 @@ process:
|
|||
field_name: field_name
|
||||
type:
|
||||
-
|
||||
plugin: static_map
|
||||
plugin: field_type
|
||||
source:
|
||||
- type
|
||||
- widget_type
|
||||
|
@ -37,12 +37,6 @@ process:
|
|||
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:
|
||||
|
@ -118,6 +112,9 @@ process:
|
|||
phone_textfield: telephone
|
||||
int_phone:
|
||||
phone_textfield: telephone
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
cardinality:
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\field\Plugin\migrate\process\d6\FieldIdGenerator.
|
||||
*/
|
||||
|
||||
namespace Drupal\field\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];
|
||||
}
|
||||
|
||||
}
|
|
@ -44,6 +44,7 @@ class FieldSettings extends ProcessPluginBase {
|
|||
public function getSettings($field_type, $global_settings) {
|
||||
$max_length = isset($global_settings['max_length']) ? $global_settings['max_length'] : '';
|
||||
$max_length = empty($max_length) ? 255 : $max_length;
|
||||
$allowed_values = [];
|
||||
if (isset($global_settings['allowed_values'])) {
|
||||
$list = explode("\n", $global_settings['allowed_values']);
|
||||
$list = array_map('trim', $list);
|
||||
|
@ -62,9 +63,6 @@ class FieldSettings extends ProcessPluginBase {
|
|||
$allowed_values = $list;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$allowed_values = '';
|
||||
}
|
||||
|
||||
$settings = array(
|
||||
'text' => array(
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\field\Plugin\migrate\process\d6\FieldType.
|
||||
*/
|
||||
|
||||
namespace Drupal\field\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
|
||||
use Drupal\Component\Plugin\PluginManagerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Plugin\migrate\process\StaticMap;
|
||||
use Drupal\migrate\Row;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "field_type"
|
||||
* )
|
||||
*/
|
||||
class FieldType extends StaticMap implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The cckfield plugin manager.
|
||||
*
|
||||
* @var \Drupal\Component\Plugin\PluginManagerInterface
|
||||
*/
|
||||
protected $cckPluginManager;
|
||||
|
||||
/**
|
||||
* Constructs a FieldType plugin.
|
||||
*
|
||||
* @param array $configuration
|
||||
* The plugin configuration.
|
||||
* @param string $plugin_id
|
||||
* The plugin ID.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin definition.
|
||||
* @param \Drupal\Component\Plugin\PluginManagerInterface $cck_plugin_manager
|
||||
* The cckfield plugin manager.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, PluginManagerInterface $cck_plugin_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->cckPluginManager = $cck_plugin_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('plugin.manager.migrate.cckfield')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list ($field_type, $widget_type) = $value;
|
||||
|
||||
try {
|
||||
return $this->cckPluginManager->createInstance($field_type)
|
||||
->getFieldType($row);
|
||||
}
|
||||
catch (PluginNotFoundException $e) {
|
||||
return parent::transform($value, $migrate_executable, $row, $destination_property);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains Drupal\field\ProxyClass\FieldUninstallValidator.
|
||||
* Contains \Drupal\field\ProxyClass\FieldUninstallValidator.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -140,9 +140,26 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests if the translated entity is displayed in an entity reference field.
|
||||
* Tests if the entity is displayed in an entity reference field.
|
||||
*/
|
||||
public function testTranslatedEntityReferenceDisplay() {
|
||||
public function testEntityReferenceDisplay() {
|
||||
// Create a translated referrer entity.
|
||||
$this->referrerEntity = $this->createReferrerEntity();
|
||||
$this->assertEntityReferenceDisplay();
|
||||
|
||||
// Disable translation for referrer content type.
|
||||
$this->drupalLogin($this->rootUser);
|
||||
$this->drupalPostForm('admin/config/regional/content-language', ['settings[node][referrer][translatable]' => FALSE], t('Save configuration'));
|
||||
|
||||
// Create a referrer entity without translation.
|
||||
$this->referrerEntity = $this->createReferrerEntity(FALSE);
|
||||
$this->assertEntityReferenceDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert entity reference display.
|
||||
*/
|
||||
protected function assertEntityReferenceDisplay() {
|
||||
$url = $this->referrerEntity->urlInfo();
|
||||
$translation_url = $this->referrerEntity->urlInfo('canonical', ['language' => ConfigurableLanguage::load($this->translateToLangcode)]);
|
||||
|
||||
|
@ -169,7 +186,6 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends WebTestBase {
|
|||
protected function createContent() {
|
||||
$this->referencedEntityWithTranslation = $this->createReferencedEntityWithTranslation();
|
||||
$this->referencedEntityWithoutTranslation = $this->createNotTranslatedReferencedEntity();
|
||||
$this->referrerEntity = $this->createReferrerEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -283,7 +299,7 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends WebTestBase {
|
|||
/**
|
||||
* Create the referrer entity.
|
||||
*/
|
||||
protected function createReferrerEntity() {
|
||||
protected function createReferrerEntity($translatable = TRUE) {
|
||||
/** @var \Drupal\node\Entity\Node $node */
|
||||
$node = entity_create($this->testEntityTypeName, array(
|
||||
'title' => $this->randomMachineName(),
|
||||
|
@ -298,8 +314,9 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends WebTestBase {
|
|||
),
|
||||
'langcode' => $this->baseLangcode,
|
||||
));
|
||||
$node->save();
|
||||
$node->addTranslation($this->translateToLangcode, $node->toArray());
|
||||
if ($translatable) {
|
||||
$node->addTranslation($this->translateToLangcode, $node->toArray());
|
||||
}
|
||||
$node->save();
|
||||
|
||||
return $node;
|
||||
|
|
|
@ -27,10 +27,11 @@ class MigrateFieldInstanceTest extends MigrateDrupal6TestBase {
|
|||
|
||||
$entity = Node::create(['type' => 'story']);
|
||||
// Test a text field.
|
||||
/** @var \Drupal\field\FieldConfigInterface $field */
|
||||
$field = FieldConfig::load('node.story.field_test');
|
||||
$this->assertIdentical('Text Field', $field->label());
|
||||
$expected = array('max_length' => 255);
|
||||
$this->assertIdentical($expected, $field->getSettings());
|
||||
// field_test is a text_long field, which have no settings.
|
||||
$this->assertIdentical([], $field->getSettings());
|
||||
$this->assertIdentical('text for default value', $entity->field_test->value);
|
||||
|
||||
// Test a number field.
|
||||
|
|
|
@ -33,9 +33,9 @@ class MigrateFieldTest extends MigrateDrupal6TestBase {
|
|||
// Text field.
|
||||
/** @var \Drupal\field\Entity\FieldStorageConfig $field_storage */
|
||||
$field_storage = FieldStorageConfig::load('node.field_test');
|
||||
$expected = array('max_length' => 255);
|
||||
$this->assertIdentical("text", $field_storage->getType(), t('Field type is @fieldtype. It should be text.', array('@fieldtype' => $field_storage->getType())));
|
||||
$this->assertIdentical($expected, $field_storage->getSettings(), "Field type text settings are correct");
|
||||
$this->assertIdentical('text_long', $field_storage->getType());
|
||||
// text_long fields do not have settings.
|
||||
$this->assertIdentical([], $field_storage->getSettings());
|
||||
|
||||
// Integer field.
|
||||
$field_storage = FieldStorageConfig::load('node.field_test_two');
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\process\d6\FieldSettingsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\field\Unit\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\field\Plugin\migrate\process\d6\FieldSettings;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\field\Plugin\migrate\process\d6\FieldSettings
|
||||
* @group field
|
||||
*/
|
||||
class FieldSettingsTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::getSettings
|
||||
*
|
||||
* @dataProvider getSettingsProvider
|
||||
*/
|
||||
public function testGetSettings($field_type, $field_settings, $allowed_values) {
|
||||
$migration = $this->getMock(MigrationInterface::class);
|
||||
$plugin = new FieldSettings([], 'd6_field_settings', [], $migration);
|
||||
|
||||
$executable = $this->getMock(MigrateExecutableInterface::class);
|
||||
$row = $this->getMockBuilder(Row::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$result = $plugin->transform([$field_type, $field_settings], $executable, $row, 'foo');
|
||||
$this->assertSame($allowed_values, $result['allowed_values']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides field settings for testGetSettings().
|
||||
*/
|
||||
public function getSettingsProvider() {
|
||||
return array(
|
||||
array(
|
||||
'list_integer',
|
||||
array('allowed_values' => "1|One\n2|Two\n3"),
|
||||
array(
|
||||
'1' => 'One',
|
||||
'2' => 'Two',
|
||||
'3' => '3',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'list_string',
|
||||
array('allowed_values' => NULL),
|
||||
array(),
|
||||
),
|
||||
array(
|
||||
'list_float',
|
||||
array('allowed_values' => ""),
|
||||
array(),
|
||||
),
|
||||
array(
|
||||
'boolean',
|
||||
array(),
|
||||
array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\source\d6\FieldInstancePerViewModeTest.
|
||||
* Contains \Drupal\Tests\field\Unit\Plugin\migrate\source\d6\FieldInstancePerFormDisplayTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\field\Unit\Plugin\migrate\source\d6;
|
||||
|
|
Reference in a new issue