Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -31,7 +31,7 @@ class TextDefaultFormatter extends FormatterBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function viewElements(FieldItemListInterface $items) {
|
||||
public function viewElements(FieldItemListInterface $items, $langcode) {
|
||||
$elements = array();
|
||||
|
||||
// The ProcessedText element already handles cache context & tag bubbling.
|
||||
|
|
|
@ -70,7 +70,7 @@ class TextTrimmedFormatter extends FormatterBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function viewElements(FieldItemListInterface $items) {
|
||||
public function viewElements(FieldItemListInterface $items, $langcode) {
|
||||
$elements = array();
|
||||
|
||||
$render_as_summary = function (&$element) {
|
||||
|
|
|
@ -43,7 +43,6 @@ abstract class TextItemBase extends FieldItemBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function applyDefaultValue($notify = TRUE) {
|
||||
// Default to a simple \Drupal\Component\Utility\SafeMarkup::checkPlain().
|
||||
// @todo: Add in the filter default format here.
|
||||
$this->setValue(array('format' => NULL), $notify);
|
||||
return $this;
|
||||
|
|
|
@ -57,7 +57,7 @@ class TextareaWithSummaryWidget extends TextareaWidget {
|
|||
public function settingsSummary() {
|
||||
$summary = parent::settingsSummary();
|
||||
|
||||
$summary[] = t('Number of summary rows: !rows', array('!rows' => $this->getSetting('summary_rows')));
|
||||
$summary[] = t('Number of summary rows: @rows', array('@rows' => $this->getSetting('summary_rows')));
|
||||
|
||||
return $summary;
|
||||
}
|
||||
|
@ -92,7 +92,15 @@ class TextareaWithSummaryWidget extends TextareaWidget {
|
|||
*/
|
||||
public function errorElement(array $element, ConstraintViolationInterface $violation, array $form, FormStateInterface $form_state) {
|
||||
$element = parent::errorElement($element, $violation, $form, $form_state);
|
||||
return ($element === FALSE) ? FALSE : $element[$violation->arrayPropertyPath[0]];
|
||||
if ($element === FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
elseif (isset($violation->arrayPropertyPath[0])) {
|
||||
return $element[$violation->arrayPropertyPath[0]];
|
||||
}
|
||||
else {
|
||||
return $element;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,13 +19,6 @@ class MigrateTextConfigsTest extends MigrateDrupal6TestBase {
|
|||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('text');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -67,6 +67,65 @@ class TextFieldTest extends StringFieldTest {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test required long text with file upload.
|
||||
*/
|
||||
function testRequiredLongTextWithFileUpload() {
|
||||
// Create a text field.
|
||||
$text_field_name = 'text_long';
|
||||
$field_storage = entity_create('field_storage_config', array(
|
||||
'field_name' => $text_field_name,
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'text_with_summary',
|
||||
));
|
||||
$field_storage->save();
|
||||
entity_create('field_config', array(
|
||||
'field_storage' => $field_storage,
|
||||
'bundle' => 'entity_test',
|
||||
'label' => $this->randomMachineName() . '_label',
|
||||
'required' => TRUE,
|
||||
))->save();
|
||||
|
||||
// Create a file field.
|
||||
$file_field_name = 'file_field';
|
||||
$field_storage = entity_create('field_storage_config', array(
|
||||
'field_name' => $file_field_name,
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'file'
|
||||
));
|
||||
$field_storage->save();
|
||||
entity_create('field_config', array(
|
||||
'field_storage' => $field_storage,
|
||||
'bundle' => 'entity_test',
|
||||
'label' => $this->randomMachineName() . '_label',
|
||||
))->save();
|
||||
|
||||
entity_get_form_display('entity_test', 'entity_test', 'default')
|
||||
->setComponent($text_field_name, array(
|
||||
'type' => 'text_textarea_with_summary',
|
||||
))
|
||||
->setComponent($file_field_name, array(
|
||||
'type' => 'file_generic',
|
||||
))
|
||||
->save();
|
||||
entity_get_display('entity_test', 'entity_test', 'full')
|
||||
->setComponent($text_field_name)
|
||||
->setComponent($file_field_name)
|
||||
->save();
|
||||
|
||||
$test_file = current($this->drupalGetTestFiles('text'));
|
||||
$edit['files[file_field_0]'] = drupal_realpath($test_file->uri);
|
||||
$this->drupalPostForm('entity_test/add', $edit, 'Upload');
|
||||
$this->assertResponse(200);
|
||||
$edit = array(
|
||||
'text_long[0][value]' => 'Long text'
|
||||
);
|
||||
$this->drupalPostForm(NULL, $edit, 'Save');
|
||||
$this->assertResponse(200);
|
||||
$this->drupalGet('entity_test/1');
|
||||
$this->assertText('Long text');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test widgets.
|
||||
*/
|
||||
|
|
|
@ -41,7 +41,7 @@ class TextProcessed extends TypedData {
|
|||
/**
|
||||
* Implements \Drupal\Core\TypedData\TypedDataInterface::getValue().
|
||||
*/
|
||||
public function getValue($langcode = NULL) {
|
||||
public function getValue() {
|
||||
if ($this->processed !== NULL) {
|
||||
return $this->processed;
|
||||
}
|
||||
|
@ -49,8 +49,7 @@ class TextProcessed extends TypedData {
|
|||
$item = $this->getParent();
|
||||
$text = $item->{($this->definition->getSetting('text source'))};
|
||||
|
||||
// Avoid running check_markup() or
|
||||
// \Drupal\Component\Utility\SafeMarkup::checkPlain() on empty strings.
|
||||
// Avoid running check_markup() on empty strings.
|
||||
if (!isset($text) || $text === '') {
|
||||
$this->processed = '';
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
var $summary = $widget.find('.js-text-summary-wrapper');
|
||||
var $summaryLabel = $summary.find('label').eq(0);
|
||||
var $full = $widget.find('.js-text-full').closest('.form-item');
|
||||
var $full = $widget.find('.js-text-full').closest('.js-form-item');
|
||||
var $fullLabel = $full.find('label').eq(0);
|
||||
|
||||
// Create a placeholder label when the field cardinality is greater
|
||||
|
|
|
@ -18,11 +18,11 @@ function text_help($route_name, RouteMatchInterface $route_match) {
|
|||
case 'help.page.text':
|
||||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Text module allows you to create short and long text fields with optional summaries. See the <a href="!field">Field module help</a> and the <a href="!field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href="!text_documentation">online documentation for the Text module</a>.', array('!field' => \Drupal::url('help.page', array('name' => 'field')), '!field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) :'#', '!text_documentation' => 'https://www.drupal.org/documentation/modules/text')) . '</p>';
|
||||
$output .= '<p>' . t('The Text module allows you to create short and long text fields with optional summaries. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":text_documentation">online documentation for the Text module</a>.', array(':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) :'#', ':text_documentation' => 'https://www.drupal.org/documentation/modules/text')) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Managing and displaying text fields') . '</dt>';
|
||||
$output .= '<dd>' . t('The <em>settings</em> and <em>display</em> of the text field can be configured separately. See the <a href="!field_ui">Field UI help</a> for more information on how to manage fields and their display.', array('!field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
|
||||
$output .= '<dd>' . t('The <em>settings</em> and <em>display</em> of the text field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
|
||||
$output .= '<dt>' . t('Creating short text fields') . '</dt>';
|
||||
$output .= '<dd>' . t('If you choose <em>Text (plain)</em> or <em>Text (formatted)</em> as the field type on the <em>Manage fields</em> page, then a field with a single row is displayed. You can change the maximum text length in the <em>Field settings</em> when you set up the field.') . '</dd>';
|
||||
$output .= '<dt>' . t('Creating long text fields') . '</dt>';
|
||||
|
@ -32,7 +32,7 @@ function text_help($route_name, RouteMatchInterface $route_match) {
|
|||
$output .= '<dt>' . t('Displaying summaries instead of trimmed text') . '</dt>';
|
||||
$output .= '<dd>' . t('As an alternative to using a trimmed version of the text, you can enter a separate summary by choosing the <em>Text (formatted, long, with summary)</em> field type on the <em>Manage fields</em> page. Even when <em>Summary input</em> is enabled, and summaries are provided, you can display <em>trimmed</em> text nonetheless by choosing the appropriate format on the <em>Manage display</em> page.') . '</dd>';
|
||||
$output .= '<dt>' . t('Using text formats and editors') . '</dt>';
|
||||
$output .= '<dd>' . t('If you choose <em>Text (plain)</em> or <em>Text (plain, long)</em> you restrict the input to <em>Plain text</em> only. If you choose <em>Text (formatted)</em>, <em>Text (formatted, long)</em>, or <em>Text (formatted, long with summary)</em> you allow users to write formatted text. Which options are available to individual users depends on the settings on the <a href="!formats">Text formats and editors page</a>.', array('!formats' => \Drupal::url('filter.admin_overview'))) . '</dd>';
|
||||
$output .= '<dd>' . t('If you choose <em>Text (plain)</em> or <em>Text (plain, long)</em> you restrict the input to <em>Plain text</em> only. If you choose <em>Text (formatted)</em>, <em>Text (formatted, long)</em>, or <em>Text (formatted, long with summary)</em> you allow users to write formatted text. Which options are available to individual users depends on the settings on the <a href=":formats">Text formats and editors page</a>.', array(':formats' => \Drupal::url('filter.admin_overview'))) . '</dd>';
|
||||
$output .= '</dl>';
|
||||
return $output;
|
||||
}
|
||||
|
|
Reference in a new issue