Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -22,10 +22,10 @@ function views_entity_test_entity_base_field_info(EntityTypeInterface $entity_ty
->setLabel(t('Test access'))
->setTranslatable(FALSE)
->setSetting('max_length', 64)
->setDisplayOptions('form', array(
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => 10,
));
]);
return $definitions;
}
}

View file

@ -31,7 +31,7 @@ display:
field: type
id: type
table: node_field_data
plugin_id: node_type
plugin_id: bundle
entity_type: node
entity_field: type
body_value:
@ -76,6 +76,72 @@ display:
plugin_id: string
entity_type: node
entity_field: body
created:
id: created
table: node_field_data
field: created
relationship: none
group_type: group
admin_label: ''
operator: '='
value:
min: ''
max: ''
value: ''
type: date
group: 1
exposed: true
expose:
operator_id: created_op
label: 'Authored on'
description: null
use_operator: false
operator: created_op
identifier: created
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: true
group_info:
label: 'Authored on'
description: ''
identifier: created
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items:
1:
title: Between
operator: between
value:
type: date
value: ''
min: '2015-01-01'
max: '2016-01-01'
2:
title: 'Not Between'
operator: 'not between'
value:
type: date
value: ''
min: '2015-01-01'
max: '2016-01-01'
3:
title: Equal
operator: '='
value:
type: date
value: '2016-01-01'
min: ''
max: ''
entity_type: node
entity_field: created
plugin_id: date
pager:
type: full
sorts:

View file

@ -77,3 +77,34 @@ display:
operator: '='
value: 'not an existing name'
path: test_tokens_empty
page_3:
display_plugin: page
id: page_3
display_title: Page
position: 1
display_options:
defaults:
title: false
pager: false
header: false
pager:
type: mini
options:
items_per_page: 2
title: 'Test token page with minipager'
path: test_tokens_minipager
display_extenders: { }
header:
area:
id: area
table: views
field: area
relationship: none
group_type: group
admin_label: ''
empty: false
tokenize: false
content:
value: "Total rows: [view:total-rows] - Page count: [view:page-count]"
format: basic_html
plugin_id: text

View file

@ -0,0 +1,27 @@
<?php
namespace Drupal\views_test_data\Controller;
/**
* Controller class for views_test_data callbacks.
*/
class ViewsTestDataController {
/**
* Renders an error form page.
*
* This contains a form that will contain an error and an embedded view with
* an exposed form.
*/
public function errorFormPage() {
$build = [];
$build['view'] = [
'#type' => 'view',
'#name' => 'test_exposed_form_buttons',
];
$build['error_form'] = \Drupal::formBuilder()->getForm('Drupal\views_test_data\Form\ViewsTestDataErrorForm');
return $build;
}
}

View file

@ -21,13 +21,13 @@ class ViewsTestDataElementEmbedForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['view'] = array(
$form['view'] = [
'#type' => 'view',
'#name' => 'test_view_embed',
'#display_id' => 'embed_1',
'#arguments' => array(25),
'#arguments' => [25],
'#embed' => TRUE,
);
];
return $form;
}

View file

@ -21,13 +21,13 @@ class ViewsTestDataElementForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['view'] = array(
$form['view'] = [
'#type' => 'view',
'#name' => 'test_view_embed',
'#display_id' => 'default',
'#arguments' => array(25),
'#arguments' => [25],
'#embed' => FALSE,
);
];
return $form;
}

View file

@ -0,0 +1,48 @@
<?php
namespace Drupal\views_test_data\Form;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements a test form that has a validation error.
*/
class ViewsTestDataErrorForm implements FormInterface {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'views_test_data_error_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['text'] = [
'#type' => 'textfield',
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
];
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$form_state->setErrorByName('text', t('Form validation error'));
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
}
}

View file

@ -19,7 +19,7 @@ class StaticTest extends AccessPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
$options['access'] = array('default' => FALSE);
$options['access'] = ['default' => FALSE];
return $options;
}

View file

@ -27,8 +27,8 @@ class TestExample extends AreaPluginBase {
*/
public function defineOptions() {
$options = parent::defineOptions();
$options['string'] = array('default' => '');
$options['custom_access'] = array('default' => TRUE);
$options['string'] = ['default' => ''];
$options['custom_access'] = ['default' => TRUE];
return $options;
}
@ -46,11 +46,11 @@ class TestExample extends AreaPluginBase {
*/
public function render($empty = FALSE) {
if (!$empty || !empty($this->options['empty'])) {
return array(
return [
'#markup' => $this->globalTokenReplace($this->options['string']),
);
];
}
return array();
return [];
}
}

View file

@ -19,7 +19,7 @@ class ArgumentDefaultTest extends ArgumentDefaultPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['value'] = array('default' => '');
$options['value'] = ['default' => ''];
return $options;
}
@ -28,6 +28,7 @@ class ArgumentDefaultTest extends ArgumentDefaultPluginBase {
* {@inheritdoc}
*/
public function getArgument() {
$this->view->element['#cache']['tags'][] = 'example_tag';
return $this->options['value'];
}

View file

@ -39,7 +39,7 @@ class DisplayTest extends DisplayPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['test_option'] = array('default' => '');
$options['test_option'] = ['default' => ''];
return $options;
}
@ -50,21 +50,21 @@ class DisplayTest extends DisplayPluginBase {
public function optionsSummary(&$categories, &$options) {
parent::optionsSummary($categories, $options);
$categories['display_test'] = array(
$categories['display_test'] = [
'title' => $this->t('Display test settings'),
'column' => 'second',
'build' => array(
'build' => [
'#weight' => -100,
),
);
],
];
$test_option = $this->getOption('test_option') ?: $this->t('Empty');
$options['test_option'] = array(
$options['test_option'] = [
'category' => 'display_test',
'title' => $this->t('Test option'),
'value' => views_ui_truncate($test_option, 24),
);
];
}
/**
@ -76,12 +76,12 @@ class DisplayTest extends DisplayPluginBase {
switch ($form_state->get('section')) {
case 'test_option':
$form['#title'] .= $this->t('Test option');
$form['test_option'] = array(
$form['test_option'] = [
'#title' => $this->t('Test option'),
'#type' => 'textfield',
'#description' => $this->t('This is a textfield for test_option.'),
'#default_value' => $this->getOption('test_option'),
);
];
break;
}
}

View file

@ -39,19 +39,19 @@ class DisplayExtenderTest extends DisplayExtenderPluginBase {
public function optionsSummary(&$categories, &$options) {
parent::optionsSummary($categories, $options);
$categories['display_extender_test'] = array(
$categories['display_extender_test'] = [
'title' => $this->t('Display extender test settings'),
'column' => 'second',
'build' => array(
'build' => [
'#weight' => -100,
),
);
],
];
$options['test_extender_test_option'] = array(
$options['test_extender_test_option'] = [
'category' => 'display_extender_test',
'title' => $this->t('Test option'),
'value' => views_ui_truncate($this->options['test_extender_test_option'], 24),
);
];
}
/**
@ -61,12 +61,12 @@ class DisplayExtenderTest extends DisplayExtenderPluginBase {
switch ($form_state->get('section')) {
case 'test_extender_test_option':
$form['#title'] .= $this->t('Test option');
$form['test_extender_test_option'] = array(
$form['test_extender_test_option'] = [
'#title' => $this->t('Test option'),
'#type' => 'textfield',
'#description' => $this->t('This is a textfield for test_option.'),
'#default_value' => $this->options['test_extender_test_option'],
);
];
}
}
@ -86,7 +86,7 @@ class DisplayExtenderTest extends DisplayExtenderPluginBase {
* {@inheritdoc}
*/
public function defaultableSections(&$sections, $section = NULL) {
$sections['test_extender_test_option'] = array('test_extender_test_option');
$sections['test_extender_test_option'] = ['test_extender_test_option'];
}
/**

View file

@ -0,0 +1,25 @@
<?php
namespace Drupal\views_test_data\Plugin\views\filter;
use Drupal\views\Plugin\views\filter\BooleanOperator;
/**
* Filter to test queryOpBoolean() with default operator.
*
* @ingroup views_filter_handlers
*
* @ViewsFilter("boolean_default")
*/
class FilterBooleanOperatorDefaultTest extends BooleanOperator {
/**
* {@inheritdoc}
*/
public function query() {
$this->ensureMyTable();
$field = "$this->tableAlias.$this->realField";
$this->queryOpBoolean($field);
}
}

View file

@ -18,7 +18,7 @@ class FilterTest extends FilterPluginBase {
protected function defineOptions() {
$options = parent::defineOptions();
$options['test_enable'] = array('default' => TRUE);
$options['test_enable'] = ['default' => TRUE];
return $options;
}
@ -30,11 +30,11 @@ class FilterTest extends FilterPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['test_enable'] = array(
$form['test_enable'] = [
'#type' => 'checkbox',
'#title' => $this->t('Controls whether the filter plugin should be active'),
'#default_value' => $this->options['test_enable'],
);
];
}
/**

View file

@ -18,17 +18,17 @@ use Drupal\views\ViewExecutable;
* )
*/
class QueryTest extends QueryPluginBase {
protected $conditions = array();
protected $fields = array();
protected $allItems = array();
protected $orderBy = array();
protected $conditions = [];
protected $fields = [];
protected $allItems = [];
protected $orderBy = [];
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['test_setting'] = array('default' => '');
$options['test_setting'] = ['default' => ''];
return $options;
}
@ -39,11 +39,11 @@ class QueryTest extends QueryPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['test_setting'] = array(
$form['test_setting'] = [
'#title' => $this->t('Test setting'),
'#type' => 'textfield',
'#default_value' => $this->options['test_setting'],
);
];
}
/**
@ -57,21 +57,21 @@ class QueryTest extends QueryPluginBase {
}
public function addWhere($group, $field, $value = NULL, $operator = NULL) {
$this->conditions[] = array(
$this->conditions[] = [
'field' => $field,
'value' => $value,
'operator' => $operator
);
];
}
public function addField($table, $field, $alias = '', $params = array()) {
public function addField($table, $field, $alias = '', $params = []) {
$this->fields[$field] = $field;
return $field;
}
public function addOrderBy($table, $field = NULL, $order = 'ASC', $alias = '', $params = array()) {
$this->orderBy = array('field' => $field, 'order' => $order);
public function addOrderBy($table, $field = NULL, $order = 'ASC', $alias = '', $params = []) {
$this->orderBy = ['field' => $field, 'order' => $order];
}
@ -96,7 +96,7 @@ class QueryTest extends QueryPluginBase {
* {@inheritdoc}
*/
public function execute(ViewExecutable $view) {
$result = array();
$result = [];
foreach ($this->allItems as $element) {
// Run all conditions on the element, and add it to the result if they
// match.

View file

@ -32,7 +32,7 @@ class RowTest extends RowPluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['test_option'] = array('default' => '');
$options['test_option'] = ['default' => ''];
return $options;
}
@ -43,12 +43,12 @@ class RowTest extends RowPluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['test_option'] = array(
$form['test_option'] = [
'#title' => $this->t('Test option'),
'#type' => 'textfield',
'#description' => $this->t('This is a textfield for test_option.'),
'#default_value' => $this->options['test_option'],
);
];
}
/**

View file

@ -24,26 +24,26 @@ class MappingTest extends Mapping {
* {@inheritdoc}
*/
protected function defineMapping() {
return array(
'title_field' => array(
return [
'title_field' => [
'#title' => $this->t('Title field'),
'#description' => $this->t('Choose the field with the custom title.'),
'#toggle' => TRUE,
'#required' => TRUE,
),
'name_field' => array(
],
'name_field' => [
'#title' => $this->t('Name field'),
'#description' => $this->t('Choose the field with the custom name.'),
),
'numeric_field' => array(
],
'numeric_field' => [
'#title' => $this->t('Numeric field'),
'#description' => $this->t('Select one or more numeric fields.'),
'#multiple' => TRUE,
'#toggle' => TRUE,
'#filter' => 'filterNumericFields',
'#required' => TRUE,
),
);
],
];
}
/**

View file

@ -40,7 +40,7 @@ class StyleTest extends StylePluginBase {
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['test_option'] = array('default' => '');
$options['test_option'] = ['default' => ''];
return $options;
}
@ -51,12 +51,12 @@ class StyleTest extends StylePluginBase {
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['test_option'] = array(
$form['test_option'] = [
'#title' => $this->t('Test option'),
'#type' => 'textfield',
'#description' => $this->t('This is a textfield for test_option.'),
'#default_value' => $this->options['test_option'],
);
];
}
/**

View file

@ -17,7 +17,7 @@ function views_test_data_schema() {
*/
function views_test_data_install() {
// Add the marquee tag to possible html elements to test the field handler.
$values = array(
$values = [
'div' => 'DIV',
'span' => 'SPAN',
'h1' => 'H1',
@ -30,6 +30,6 @@ function views_test_data_install() {
'strong' => 'STRONG',
'em' => 'EM',
'marquee' => 'MARQUEE'
);
];
\Drupal::configFactory()->getEditable('views.settings')->set('field_rewrite_elements', $values)->save();
}

View file

@ -66,13 +66,13 @@ function views_test_data_preprocess_views_view_table(&$variables) {
* - view: The view object.
*/
function template_preprocess_views_view_mapping_test(&$variables) {
$variables['element'] = array();
$variables['element'] = [];
foreach ($variables['rows'] as $delta => $row) {
$fields = array();
$fields = [];
foreach ($variables['options']['mapping'] as $type => $field_names) {
if (!is_array($field_names)) {
$field_names = array($field_names);
$field_names = [$field_names];
}
foreach ($field_names as $field_name) {
if ($value = $variables['view']->style_plugin->getField($delta, $field_name)) {
@ -87,26 +87,26 @@ function template_preprocess_views_view_mapping_test(&$variables) {
}
// Build a container for the row.
$variables['element'][$delta] = array(
$variables['element'][$delta] = [
'#type' => 'container',
'#attributes' => array(
'class' => array(
'#attributes' => [
'class' => [
'views-row-mapping-test',
),
),
);
],
],
];
// Add each field to the row.
foreach ($fields as $key => $render) {
$variables['element'][$delta][$key] = array(
$variables['element'][$delta][$key] = [
'#children' => $render,
'#type' => 'container',
'#attributes' => array(
'class' => array(
'#attributes' => [
'class' => [
$key,
),
),
);
],
],
];
}
}
}

View file

@ -19,3 +19,11 @@ views_test_data.form_multiple:
_controller: '\Drupal\views_test_data\Controller\ViewsTestFormMultipleController::testPage'
requirements:
_access: 'TRUE'
views_test_data.error_form_page:
path: '/views_test_data_error_form_page'
defaults:
_title: 'Test Views Form Exposed Errors'
_controller: '\Drupal\views_test_data\Controller\ViewsTestDataController::errorFormPage'
requirements:
_access: 'TRUE'

View file

@ -39,7 +39,7 @@ function views_test_data_views_data_alter() {
function views_test_data_views_analyze(ViewExecutable $view) {
\Drupal::state()->set('views_hook_test_views_analyze', TRUE);
$ret = array();
$ret = [];
$ret[] = Analyzer::formatMessage(t('Test ok message'), 'ok');
$ret[] = Analyzer::formatMessage(t('Test warning message'), 'warning');

View file

@ -22,10 +22,10 @@ function views_test_data_views_query_substitutions(ViewExecutable $view) {
function views_test_data_views_form_substitutions() {
\Drupal::state()->set('views_hook_test_views_form_substitutions', TRUE);
$render = ['#markup' => '<em>unescaped</em>'];
return array(
return [
'<!--will-be-escaped-->' => '<em>escaped</em>',
'<!--will-be-not-escaped-->' => \Drupal::service('renderer')->renderPlain($render),
);
];
}
/**