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
|
@ -8,10 +8,13 @@
|
|||
namespace Drupal\text\Plugin\migrate\cckfield;
|
||||
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
|
||||
|
||||
/**
|
||||
* @PluginID("text")
|
||||
* @MigrateCckField(
|
||||
* id = "text"
|
||||
* )
|
||||
*/
|
||||
class TextField extends CckFieldPluginBase {
|
||||
|
||||
|
@ -91,4 +94,33 @@ class TextField extends CckFieldPluginBase {
|
|||
$migration->setProcessOfProperty($field_name, $process);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldType(Row $row) {
|
||||
$widget_type = $row->getSourceProperty('widget_type');
|
||||
|
||||
if ($widget_type == 'text_textfield') {
|
||||
$settings = $row->getSourceProperty('global_settings');
|
||||
$field_type = $settings['text_processing'] ? 'text' : 'string';
|
||||
if (empty($settings['max_length']) || $settings['max_length'] > 255) {
|
||||
$field_type .= '_long';
|
||||
}
|
||||
return $field_type;
|
||||
}
|
||||
else {
|
||||
switch ($widget_type) {
|
||||
case 'optionwidgets_buttons':
|
||||
case 'optionwidgets_select':
|
||||
return 'list_string';
|
||||
case 'optionwidgets_onoff':
|
||||
return 'boolean';
|
||||
case 'text_textarea':
|
||||
return 'text_long';
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class TextProcessed extends TypedData {
|
|||
protected $processed = NULL;
|
||||
|
||||
/**
|
||||
* Overrides TypedData::__construct().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(DataDefinitionInterface $definition, $name = NULL, TypedDataInterface $parent = NULL) {
|
||||
parent::__construct($definition, $name, $parent);
|
||||
|
@ -38,7 +38,7 @@ class TextProcessed extends TypedData {
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Core\TypedData\TypedDataInterface::getValue().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getValue() {
|
||||
if ($this->processed !== NULL) {
|
||||
|
@ -59,7 +59,7 @@ class TextProcessed extends TypedData {
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Core\TypedData\TypedDataInterface::setValue().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setValue($value, $notify = TRUE) {
|
||||
$this->processed = $value;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Drupal\Tests\text\Unit\Migrate;
|
||||
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\text\Plugin\migrate\cckfield\TextField;
|
||||
use Prophecy\Argument;
|
||||
|
@ -121,4 +122,49 @@ class TextFieldTest extends UnitTestCase {
|
|||
$this->assertSame($expected, $this->migration->getProcess()['process']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testGetFieldType().
|
||||
*/
|
||||
public function getFieldTypeProvider() {
|
||||
return array(
|
||||
array('string_long', 'text_textfield', array(
|
||||
'text_processing' => FALSE,
|
||||
)),
|
||||
array('string', 'text_textfield', array(
|
||||
'text_processing' => FALSE,
|
||||
'max_length' => 128,
|
||||
)),
|
||||
array('string_long', 'text_textfield', array(
|
||||
'text_processing' => FALSE,
|
||||
'max_length' => 4096,
|
||||
)),
|
||||
array('text_long', 'text_textfield', array(
|
||||
'text_processing' => TRUE,
|
||||
)),
|
||||
array('text', 'text_textfield', array(
|
||||
'text_processing' => TRUE,
|
||||
'max_length' => 128,
|
||||
)),
|
||||
array('text_long', 'text_textfield', array(
|
||||
'text_processing' => TRUE,
|
||||
'max_length' => 4096,
|
||||
)),
|
||||
array('list_string', 'optionwidgets_buttons'),
|
||||
array('list_string', 'optionwidgets_select'),
|
||||
array('boolean', 'optionwidgets_onoff'),
|
||||
array('text_long', 'text_textarea'),
|
||||
array(NULL, 'undefined'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::getFieldType
|
||||
* @dataProvider getFieldTypeProvider
|
||||
*/
|
||||
public function testGetFieldType($expected_type, $widget_type, array $settings = array()) {
|
||||
$row = new Row(array('widget_type' => $widget_type), array('widget_type' => array()));
|
||||
$row->setSourceProperty('global_settings', $settings);
|
||||
$this->assertSame($expected_type, $this->plugin->getFieldType($row));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue