updated core and modules

This commit is contained in:
Bachir Soussi Chiadmi
2017-09-09 16:27:51 +02:00
parent 027aa99b32
commit 41863f872c
7810 changed files with 318922 additions and 83631 deletions
@@ -0,0 +1,18 @@
uuid: 3c4e92c3-5fb1-408d-993c-6066559230be
langcode: en
status: true
dependencies:
theme:
- bartik
id: pagetitle_2
theme: bartik
region: '-1'
weight: null
provider: null
plugin: page_title_block
settings:
id: page_title_block
label: 'Page title'
provider: core
label_display: '0'
visibility: { }
@@ -0,0 +1,18 @@
uuid: 87097da9-29d1-441f-8b00-b93852c760d6
langcode: en
status: false
dependencies:
theme:
- bartik
id: pagetitle_1
theme: bartik
region: '-1'
weight: -8
provider: null
plugin: page_title_block
settings:
id: page_title_block
label: 'Page title'
provider: core
label_display: '0'
visibility: { }
@@ -6,8 +6,8 @@
* upgrade path of https://www.drupal.org/node/2354889.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
use Drupal\Core\Serialization\Yaml;
$connection = Database::getConnection();
@@ -23,16 +23,16 @@ $block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.thirdt
foreach ($block_configs as $block_config) {
$connection->insert('config')
->fields(array(
->fields([
'collection',
'name',
'data',
))
->values(array(
])
->values([
'collection' => '',
'name' => 'block.block.' . $block_config['id'],
'data' => serialize($block_config),
))
])
->execute();
}
@@ -0,0 +1,37 @@
<?php
/**
* @file
* Partial database to create broken config overrides.
*
* @see \Drupal\system\Tests\Update\ConfigOverridesUpdateTest
*/
use Drupal\Core\Database\Database;
use Symfony\Component\Yaml\Yaml;
$connection = Database::getConnection();
// Install the incorrect override configuration.
$configs = [
// The view has field titles translated and had an addition field added,
// translated and then removed.
'views.view.content',
// The configuration has a bogus key.
'system.cron',
];
foreach ($configs as $config_name) {
$config = Yaml::parse(file_get_contents(__DIR__ . '/es-' . $config_name . '.yml'));
$connection->delete('config')
->condition('name', $config_name)
->condition('collection', 'language.es')
->execute();
$connection->insert('config')
->fields(['data', 'name', 'collection'])
->values([
'name' => $config_name,
'data' => serialize($config),
'collection' => 'language.es',
])
->execute();
}
@@ -11,64 +11,64 @@ use Drupal\Core\Database\Database;
$connection = Database::getConnection();
$connection->insert('key_value')
->fields(array(
->fields([
'collection',
'name',
'value',
))
->values(array(
])
->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.body',
'value' => 'a:2:{s:19:"block_content__body";a:4:{s:11:"description";s:42:"Data storage for block_content field body.";s:6:"fields";a:9:{s:6:"bundle";a:5:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:128;s:8:"not null";b:1;s:7:"default";s:0:"";s:11:"description";s:88:"The field instance bundle to which this row belongs, used when deleting a field instance";}s:7:"deleted";a:5:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:1;s:7:"default";i:0;s:11:"description";s:60:"A boolean indicating whether this data item has been deleted";}s:9:"entity_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:38:"The entity id this data is attached to";}s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:47:"The entity revision id this data is attached to";}s:8:"langcode";a:5:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:32;s:8:"not null";b:1;s:7:"default";s:0:"";s:11:"description";s:37:"The language code for this data item.";}s:5:"delta";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:67:"The sequence number for this data item, used for multi-value fields";}s:10:"body_value";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:1;}s:12:"body_summary";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:0;}s:11:"body_format";a:3:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:255;s:8:"not null";b:0;}}s:11:"primary key";a:4:{i:0;s:9:"entity_id";i:1;s:7:"deleted";i:2;s:5:"delta";i:3;s:8:"langcode";}s:7:"indexes";a:3:{s:6:"bundle";a:1:{i:0;s:6:"bundle";}s:11:"revision_id";a:1:{i:0;s:11:"revision_id";}s:11:"body_format";a:1:{i:0;s:11:"body_format";}}}s:28:"block_content_revision__body";a:4:{s:11:"description";s:54:"Revision archive storage for block_content field body.";s:6:"fields";a:9:{s:6:"bundle";a:5:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:128;s:8:"not null";b:1;s:7:"default";s:0:"";s:11:"description";s:88:"The field instance bundle to which this row belongs, used when deleting a field instance";}s:7:"deleted";a:5:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:1;s:7:"default";i:0;s:11:"description";s:60:"A boolean indicating whether this data item has been deleted";}s:9:"entity_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:38:"The entity id this data is attached to";}s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:47:"The entity revision id this data is attached to";}s:8:"langcode";a:5:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:32;s:8:"not null";b:1;s:7:"default";s:0:"";s:11:"description";s:37:"The language code for this data item.";}s:5:"delta";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:8:"not null";b:1;s:11:"description";s:67:"The sequence number for this data item, used for multi-value fields";}s:10:"body_value";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:1;}s:12:"body_summary";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:0;}s:11:"body_format";a:3:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:255;s:8:"not null";b:0;}}s:11:"primary key";a:5:{i:0;s:9:"entity_id";i:1;s:11:"revision_id";i:2;s:7:"deleted";i:3;s:5:"delta";i:4;s:8:"langcode";}s:7:"indexes";a:3:{s:6:"bundle";a:1:{i:0;s:6:"bundle";}s:11:"revision_id";a:1:{i:0;s:11:"revision_id";}s:11:"body_format";a:1:{i:0;s:11:"body_format";}}}}',
))
->values(array(
])
->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.changed',
'value' => 'a:2:{s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:7:"changed";a:2:{s:4:"type";s:3:"int";s:8:"not null";b:0;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:7:"changed";a:2:{s:4:"type";s:3:"int";s:8:"not null";b:0;}}}}',
))
->values(array(
])
->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.default_langcode',
'value' => 'a:2:{s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:16:"default_langcode";a:3:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:1;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:16:"default_langcode";a:3:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:1;}}}}',
))
->values(array(
])
->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.id',
'value' => 'a:4:{s:13:"block_content";a:1:{s:6:"fields";a:1:{s:2:"id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:2:"id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:22:"block_content_revision";a:1:{s:6:"fields";a:1:{s:2:"id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:2:"id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}}',
))
->values(array(
])
->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.info',
'value' => 'a:2:{s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:4:"info";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:255;s:6:"binary";b:0;s:8:"not null";b:0;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:4:"info";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:255;s:6:"binary";b:0;s:8:"not null";b:0;}}}}',
))
->values(array(
])
->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.langcode',
'value' => 'a:4:{s:13:"block_content";a:1:{s:6:"fields";a:1:{s:8:"langcode";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:12;s:8:"is_ascii";b:1;s:8:"not null";b:1;}}}s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:8:"langcode";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:12;s:8:"is_ascii";b:1;s:8:"not null";b:1;}}}s:22:"block_content_revision";a:1:{s:6:"fields";a:1:{s:8:"langcode";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:12;s:8:"is_ascii";b:1;s:8:"not null";b:1;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:8:"langcode";a:4:{s:4:"type";s:7:"varchar";s:6:"length";i:12;s:8:"is_ascii";b:1;s:8:"not null";b:1;}}}}',
))
->values(array(
])
->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.revision_id',
'value' => 'a:4:{s:13:"block_content";a:1:{s:6:"fields";a:1:{s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:0;}}}s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:22:"block_content_revision";a:1:{s:6:"fields";a:1:{s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:11:"revision_id";a:4:{s:4:"type";s:3:"int";s:8:"unsigned";b:1;s:4:"size";s:6:"normal";s:8:"not null";b:1;}}}}',
))
->values(array(
])
->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.revision_log',
'value' => 'a:1:{s:22:"block_content_revision";a:1:{s:6:"fields";a:1:{s:12:"revision_log";a:3:{s:4:"type";s:4:"text";s:4:"size";s:3:"big";s:8:"not null";b:0;}}}}',
))
->values(array(
])
->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.revision_translation_affected',
'value' => 'a:2:{s:24:"block_content_field_data";a:1:{s:6:"fields";a:1:{s:29:"revision_translation_affected";a:3:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:0;}}}s:28:"block_content_field_revision";a:1:{s:6:"fields";a:1:{s:29:"revision_translation_affected";a:3:{s:4:"type";s:3:"int";s:4:"size";s:4:"tiny";s:8:"not null";b:0;}}}}',
))
->values(array(
])
->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.type',
'value' => 'a:2:{s:13:"block_content";a:2:{s:6:"fields";a:1:{s:4:"type";a:4:{s:11:"description";s:28:"The ID of the target entity.";s:4:"type";s:13:"varchar_ascii";s:6:"length";i:32;s:8:"not null";b:1;}}s:7:"indexes";a:1:{s:36:"block_content_field__type__target_id";a:1:{i:0;s:4:"type";}}}s:24:"block_content_field_data";a:2:{s:6:"fields";a:1:{s:4:"type";a:4:{s:11:"description";s:28:"The ID of the target entity.";s:4:"type";s:13:"varchar_ascii";s:6:"length";i:32;s:8:"not null";b:1;}}s:7:"indexes";a:1:{s:36:"block_content_field__type__target_id";a:1:{i:0;s:4:"type";}}}}',
))
->values(array(
])
->values([
'collection' => 'entity.storage_schema.sql',
'name' => 'block_content.field_schema_data.uuid',
'value' => 'a:1:{s:13:"block_content";a:2:{s:6:"fields";a:1:{s:4:"uuid";a:4:{s:4:"type";s:13:"varchar_ascii";s:6:"length";i:128;s:6:"binary";b:0;s:8:"not null";b:1;}}s:11:"unique keys";a:1:{s:32:"block_content_field__uuid__value";a:1:{i:0;s:4:"uuid";}}}}',
))
])
->execute();
@@ -6,8 +6,8 @@
* upgrade path of https://www.drupal.org/node/507488.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
use Drupal\Core\Serialization\Yaml;
$connection = Database::getConnection();
@@ -31,11 +31,11 @@ foreach ($block_configs as $block_config) {
// Update the config entity query "index".
$existing_blocks = $connection->select('key_value')
->fields('key_value', ['value'])
->condition('collection', 'config.entity.key_store.block')
->condition('name', 'theme:seven')
->execute()
->fetchField();
->fields('key_value', ['value'])
->condition('collection', 'config.entity.key_store.block')
->condition('name', 'theme:seven')
->execute()
->fetchField();
$existing_blocks = unserialize($existing_blocks);
$connection->update('key_value')
@@ -6,8 +6,8 @@
* upgrade path of https://www.drupal.org/node/2476947.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
use Drupal\Core\Serialization\Yaml;
$connection = Database::getConnection();
@@ -6,8 +6,8 @@
* upgrade path of https://www.drupal.org/node/507488.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
use Drupal\Core\Serialization\Yaml;
$connection = Database::getConnection();
@@ -31,11 +31,11 @@ foreach ($block_configs as $block_config) {
// Update the config entity query "index".
$existing_blocks = $connection->select('key_value')
->fields('key_value', ['value'])
->condition('collection', 'config.entity.key_store.block')
->condition('name', 'theme:seven')
->execute()
->fetchField();
->fields('key_value', ['value'])
->condition('collection', 'config.entity.key_store.block')
->condition('name', 'theme:seven')
->execute()
->fetchField();
$existing_blocks = unserialize($existing_blocks);
$connection->update('key_value')
@@ -6,8 +6,8 @@
* upgrade path of https://www.drupal.org/node/2005546.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
use Drupal\Core\Serialization\Yaml;
$connection = Database::getConnection();
@@ -0,0 +1,50 @@
<?php
/**
* @file
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
* upgrade path of https://www.drupal.org/node/2513534.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// A disabled block.
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2513534.yml'));
// A block placed in the default region.
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.secondtestfor2513534.yml'));
foreach ($block_configs as $block_config) {
$connection->insert('config')
->fields([
'collection',
'name',
'data',
])
->values([
'collection' => '',
'name' => 'block.block.' . $block_config['id'],
'data' => serialize($block_config),
])
->execute();
}
// Update the config entity query "index".
$existing_blocks = $connection->select('key_value')
->fields('key_value', ['value'])
->condition('collection', 'config.entity.key_store.block')
->condition('name', 'theme:bartik')
->execute()
->fetchField();
$existing_blocks = unserialize($existing_blocks);
$connection->update('key_value')
->fields([
'value' => serialize(array_merge($existing_blocks, ['block.block.testfor2513534', 'block.block.secondtestfor2513534']))
])
->condition('collection', 'config.entity.key_store.block')
->condition('name', 'theme:bartik')
->execute();
@@ -10,20 +10,20 @@ use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Create the table.
$connection->schema()->createTable('update_test_schema_table', array(
'fields' => array(
'a' => array(
$connection->schema()->createTable('update_test_schema_table', [
'fields' => [
'a' => [
'type' => 'int',
'not null' => TRUE,
'size' => 'normal',
),
'b' => array(
],
'b' => [
'type' => 'blob',
'not null' => FALSE,
'size' => 'normal',
),
),
));
],
],
]);
// Set the schema version.
$connection->merge('key_value')
@@ -6,8 +6,8 @@
* upgrade path of https://www.drupal.org/node/2455125.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
use Drupal\Core\Serialization\Yaml;
$connection = Database::getConnection();
@@ -17,16 +17,16 @@ $views_configs = [];
$views_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/drupal-8.views-entity-views-data-2455125.yml'));
foreach ($views_configs as $views_config) {
$connection->insert('config')
->fields(array(
$connection->insert('config')
->fields([
'collection',
'name',
'data',
))
->values(array(
])
->values([
'collection' => '',
'name' => 'views.view.' . $views_config['id'],
'data' => serialize($views_config),
))
->execute();
])
->execute();
}
@@ -6,8 +6,8 @@
* the upgrade path of https://www.drupal.org/node/2649914.
*/
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Database\Database;
use Drupal\Core\Serialization\Yaml;
$connection = Database::getConnection();
@@ -0,0 +1 @@
bogus_key: 'Should be cleaned by system_update_8200'
@@ -0,0 +1,15 @@
label: 'Spanish Content'
description: 'Spanish Find and manage content.'
display:
default:
display_options:
fields:
title:
label: 'Spanish Title'
name:
label: 'Spanish Author'
nid:
label: 'Spanish ID'
display_title: 'Spanish Master'
page_1:
display_title: 'Spanish Page'
@@ -4,8 +4,8 @@ type: module
package: Testing
# version: VERSION
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233791
datestamp: 1502903957
@@ -20,7 +20,7 @@ class AcceptHeaderMatcher implements RouteFilterInterface {
// Generates a list of Symfony formats matching the acceptable MIME types.
// @todo replace by proper content negotiation library.
$acceptable_mime_types = $request->getAcceptableContentTypes();
$acceptable_formats = array_filter(array_map(array($request, 'getFormat'), $acceptable_mime_types));
$acceptable_formats = array_filter(array_map([$request, 'getFormat'], $acceptable_mime_types));
$primary_format = $request->getRequestFormat();
foreach ($collection as $name => $route) {
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233791
datestamp: 1502903957
@@ -5,8 +5,8 @@ description: 'Test for AJAX form calls.'
package: Testing
# version: VERSION
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233791
datestamp: 1502903957
@@ -89,7 +89,7 @@ function ajax_forms_test_advanced_commands_css_callback($form, FormStateInterfac
$color = 'blue';
$response = new AjaxResponse();
$response->addCommand(new CssCommand($selector, array('background-color' => $color)));
$response->addCommand(new CssCommand($selector, ['background-color' => $color]));
return $response;
}
@@ -108,7 +108,7 @@ function ajax_forms_test_advanced_commands_data_callback($form, FormStateInterfa
*/
function ajax_forms_test_advanced_commands_invoke_callback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new InvokeCommand('#invoke_div', 'addClass', array('error')));
$response->addCommand(new InvokeCommand('#invoke_div', 'addClass', ['error']));
return $response;
}
@@ -181,7 +181,7 @@ function ajax_forms_test_advanced_commands_add_css_callback($form, FormStateInte
*/
function ajax_forms_test_validation_form_callback($form, FormStateInterface $form_state) {
drupal_set_message("ajax_forms_test_validation_form_callback invoked");
drupal_set_message(t("Callback: drivertext=%drivertext, spare_required_field=%spare_required_field", array('%drivertext' => $form_state->getValue('drivertext'), '%spare_required_field' => $form_state->getValue('spare_required_field'))));
drupal_set_message(t("Callback: drivertext=%drivertext, spare_required_field=%spare_required_field", ['%drivertext' => $form_state->getValue('drivertext'), '%spare_required_field' => $form_state->getValue('spare_required_field')]));
return ['#markup' => '<div id="message_area">ajax_forms_test_validation_form_callback at ' . date('c') . '</div>'];
}
@@ -190,7 +190,7 @@ function ajax_forms_test_validation_form_callback($form, FormStateInterface $for
*/
function ajax_forms_test_validation_number_form_callback($form, FormStateInterface $form_state) {
drupal_set_message("ajax_forms_test_validation_number_form_callback invoked");
drupal_set_message(t("Callback: drivernumber=%drivernumber, spare_required_field=%spare_required_field", array('%drivernumber' => $form_state->getValue('drivernumber'), '%spare_required_field' => $form_state->getValue('spare_required_field'))));
drupal_set_message(t("Callback: drivernumber=%drivernumber, spare_required_field=%spare_required_field", ['%drivernumber' => $form_state->getValue('drivernumber'), '%spare_required_field' => $form_state->getValue('spare_required_field')]));
return ['#markup' => '<div id="message_area_number">ajax_forms_test_validation_number_form_callback at ' . date('c') . '</div>'];
}
@@ -15,7 +15,7 @@ class Callbacks {
/**
* Ajax callback triggered by select.
*/
function selectCallback($form, FormStateInterface $form_state) {
public function selectCallback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new HtmlCommand('#ajax_selected_color', $form_state->getValue('select')));
$response->addCommand(new DataCommand('#ajax_selected_color', 'form_state_value_select', $form_state->getValue('select')));
@@ -25,7 +25,7 @@ class Callbacks {
/**
* Ajax callback triggered by checkbox.
*/
function checkboxCallback($form, FormStateInterface $form_state) {
public function checkboxCallback($form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$response->addCommand(new HtmlCommand('#ajax_checkbox_value', (int) $form_state->getValue('checkbox')));
$response->addCommand(new DataCommand('#ajax_checkbox_value', 'form_state_value_select', (int) $form_state->getValue('checkbox')));
@@ -35,7 +35,7 @@ class Callbacks {
/**
* Ajax callback triggered by the checkbox in a #group.
*/
function checkboxGroupCallback($form, FormStateInterface $form_state) {
public function checkboxGroupCallback($form, FormStateInterface $form_state) {
return $form['checkbox_in_group_wrapper'];
}
@@ -21,178 +21,178 @@ class AjaxFormsTestCommandsForm extends FormBase {
* {@inheritdoc}.
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form = array();
$form = [];
// Shows the 'after' command with a callback generating commands.
$form['after_command_example'] = array(
$form['after_command_example'] = [
'#value' => $this->t("AJAX 'After': Click to put something after the div"),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_after_callback',
),
],
'#suffix' => '<div id="after_div">Something can be inserted after this</div>',
);
];
// Shows the 'alert' command.
$form['alert_command_example'] = array(
$form['alert_command_example'] = [
'#value' => $this->t("AJAX 'Alert': Click to alert"),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_alert_callback',
),
);
],
];
// Shows the 'append' command.
$form['append_command_example'] = array(
$form['append_command_example'] = [
'#value' => $this->t("AJAX 'Append': Click to append something"),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_append_callback',
),
],
'#suffix' => '<div id="append_div">Append inside this div</div>',
);
];
// Shows the 'before' command.
$form['before_command_example'] = array(
$form['before_command_example'] = [
'#value' => $this->t("AJAX 'before': Click to put something before the div"),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_before_callback',
),
],
'#suffix' => '<div id="before_div">Insert something before this.</div>',
);
];
// Shows the 'changed' command without asterisk.
$form['changed_command_example'] = array(
$form['changed_command_example'] = [
'#value' => $this->t("AJAX changed: Click to mark div changed."),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_changed_callback',
),
],
'#suffix' => '<div id="changed_div"> <div id="changed_div_mark_this">This div can be marked as changed or not.</div></div>',
);
];
// Shows the 'changed' command adding the asterisk.
$form['changed_command_asterisk_example'] = array(
$form['changed_command_asterisk_example'] = [
'#value' => $this->t("AJAX changed: Click to mark div changed with asterisk."),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_changed_asterisk_callback',
),
);
],
];
// Shows the Ajax 'css' command.
$form['css_command_example'] = array(
$form['css_command_example'] = [
'#value' => $this->t("Set the '#box' div to be blue."),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_css_callback',
),
],
'#suffix' => '<div id="css_div" style="height: 50px; width: 50px; border: 1px solid black"> box</div>',
);
];
// Shows the Ajax 'data' command. But there is no use of this information,
// as this would require a javascript client to use the data.
$form['data_command_example'] = array(
$form['data_command_example'] = [
'#value' => $this->t("AJAX data command: Issue command."),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_data_callback',
),
],
'#suffix' => '<div id="data_div">Data attached to this div.</div>',
);
];
// Shows the Ajax 'invoke' command.
$form['invoke_command_example'] = array(
$form['invoke_command_example'] = [
'#value' => $this->t("AJAX invoke command: Invoke addClass() method."),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_invoke_callback',
),
],
'#suffix' => '<div id="invoke_div">Original contents</div>',
);
];
// Shows the Ajax 'html' command.
$form['html_command_example'] = array(
$form['html_command_example'] = [
'#value' => $this->t("AJAX html: Replace the HTML in a selector."),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_html_callback',
),
],
'#suffix' => '<div id="html_div">Original contents</div>',
);
];
// Shows the Ajax 'insert' command.
$form['insert_command_example'] = array(
$form['insert_command_example'] = [
'#value' => $this->t("AJAX insert: Let client insert based on #ajax['method']."),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_insert_callback',
'method' => 'prepend',
),
],
'#suffix' => '<div id="insert_div">Original contents</div>',
);
];
// Shows the Ajax 'prepend' command.
$form['prepend_command_example'] = array(
$form['prepend_command_example'] = [
'#value' => $this->t("AJAX 'prepend': Click to prepend something"),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_prepend_callback',
),
],
'#suffix' => '<div id="prepend_div">Something will be prepended to this div. </div>',
);
];
// Shows the Ajax 'remove' command.
$form['remove_command_example'] = array(
$form['remove_command_example'] = [
'#value' => $this->t("AJAX 'remove': Click to remove text"),
'#type' => 'submit',
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_remove_callback',
),
],
'#suffix' => '<div id="remove_div"><div id="remove_text">text to be removed</div></div>',
);
];
// Shows the Ajax 'restripe' command.
$form['restripe_command_example'] = array(
$form['restripe_command_example'] = [
'#type' => 'submit',
'#value' => $this->t("AJAX 'restripe' command"),
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_restripe_callback',
),
],
'#suffix' => '<div id="restripe_div">
<table id="restripe_table" style="border: 1px solid black" >
<tr id="table-first"><td>first row</td></tr>
<tr ><td>second row</td></tr>
</table>
</div>',
);
];
// Demonstrates the Ajax 'settings' command. The 'settings' command has
// nothing visual to "show", but it can be tested via SimpleTest and via
// Firebug.
$form['settings_command_example'] = array(
$form['settings_command_example'] = [
'#type' => 'submit',
'#value' => $this->t("AJAX 'settings' command"),
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_settings_callback',
),
);
],
];
// Shows the Ajax 'add_css' command.
$form['add_css_command_example'] = array(
$form['add_css_command_example'] = [
'#type' => 'submit',
'#value' => $this->t("AJAX 'add_css' command"),
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_advanced_commands_add_css_callback',
),
);
],
];
$form['submit'] = array(
$form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Submit'),
);
];
return $form;
}
@@ -26,20 +26,20 @@ class AjaxFormsTestLazyLoadForm extends FormBase {
// command to ensure that the 'currentPath' setting is not part
// of the Ajax response.
$form['#attached']['drupalSettings']['test'] = 'currentPathUpdate';
$form['add_files'] = array(
$form['add_files'] = [
'#title' => $this->t('Add files'),
'#type' => 'checkbox',
'#default_value' => FALSE,
);
$form['submit'] = array(
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Submit'),
'#ajax' => array(
'#ajax' => [
'wrapper' => 'ajax-forms-test-lazy-load-ajax-wrapper',
'callback' => 'ajax_forms_test_lazy_load_form_ajax',
),
],
'#prefix' => '<div id="ajax-forms-test-lazy-load-ajax-wrapper"></div>',
);
];
return $form;
}
@@ -24,47 +24,47 @@ class AjaxFormsTestSimpleForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$object = new Callbacks();
$form = array();
$form['select'] = array(
$form = [];
$form['select'] = [
'#title' => $this->t('Color'),
'#type' => 'select',
'#options' => array(
'#options' => [
'red' => 'red',
'green' => 'green',
'blue' => 'blue'),
'#ajax' => array(
'callback' => array($object, 'selectCallback'),
),
'blue' => 'blue'],
'#ajax' => [
'callback' => [$object, 'selectCallback'],
],
'#suffix' => '<div id="ajax_selected_color">No color yet selected</div>',
);
];
$form['checkbox'] = array(
$form['checkbox'] = [
'#type' => 'checkbox',
'#title' => $this->t('Test checkbox'),
'#ajax' => array(
'callback' => array($object, 'checkboxCallback'),
),
'#ajax' => [
'callback' => [$object, 'checkboxCallback'],
],
'#suffix' => '<div id="ajax_checkbox_value">No action yet</div>',
);
$form['submit'] = array(
];
$form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('submit'),
);
];
// This is for testing invalid callbacks that should return a 500 error in
// \Drupal\Core\Form\FormAjaxResponseBuilderInterface::buildResponse().
$invalid_callbacks = array(
$invalid_callbacks = [
'null' => NULL,
'empty' => '',
'nonexistent' => 'some_function_that_does_not_exist',
);
];
foreach ($invalid_callbacks as $key => $value) {
$form['select_' . $key . '_callback'] = array(
$form['select_' . $key . '_callback'] = [
'#type' => 'select',
'#title' => $this->t('Test %key callbacks', array('%key' => $key)),
'#options' => array('red' => 'red'),
'#ajax' => array('callback' => $value),
);
'#title' => $this->t('Test %key callbacks', ['%key' => $key]),
'#options' => ['red' => 'red'],
'#ajax' => ['callback' => $value],
];
}
$form['test_group'] = [
@@ -21,42 +21,42 @@ class AjaxFormsTestValidationForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['drivertext'] = array(
$form['drivertext'] = [
'#title' => $this->t('AJAX-enabled textfield.'),
'#description' => $this->t("When this one AJAX-triggers and the spare required field is empty, you should not get an error."),
'#type' => 'textfield',
'#default_value' => $form_state->getValue('drivertext', ''),
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_validation_form_callback',
'wrapper' => 'message_area',
'method' => 'replace',
),
],
'#suffix' => '<div id="message_area"></div>',
);
];
$form['drivernumber'] = array(
$form['drivernumber'] = [
'#title' => $this->t('AJAX-enabled number field.'),
'#description' => $this->t("When this one AJAX-triggers and the spare required field is empty, you should not get an error."),
'#type' => 'number',
'#default_value' => $form_state->getValue('drivernumber', ''),
'#ajax' => array(
'#ajax' => [
'callback' => 'ajax_forms_test_validation_number_form_callback',
'wrapper' => 'message_area_number',
'method' => 'replace',
),
],
'#suffix' => '<div id="message_area_number"></div>',
);
];
$form['spare_required_field'] = array(
$form['spare_required_field'] = [
'#title' => $this->t("Spare Required Field"),
'#type' => 'textfield',
'#required' => TRUE,
);
];
$form['submit'] = array(
$form['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Submit'),
);
];
return $form;
}
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- contact
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233791
datestamp: 1502903957
@@ -35,12 +35,17 @@ ajax_test.render:
requirements:
_access: 'TRUE'
ajax_test.admin.theme:
path: '/admin/ajax-test/theme'
defaults:
_controller: '\Drupal\ajax_test\Controller\AjaxTestController::theme'
requirements:
_access: 'TRUE'
ajax_test.order:
path: '/ajax-test/order'
defaults:
_controller: '\Drupal\ajax_test\Controller\AjaxTestController::order'
options:
_theme: ajax_base_page
requirements:
_access: 'TRUE'
@@ -22,22 +22,22 @@ class AjaxTestController {
*/
public static function dialogContents() {
// This is a regular render array; the keys do not have special meaning.
$content = array(
'#title' => 'AJAX Dialog contents',
'content' => array(
$content = [
'#title' => '<em>AJAX Dialog & contents</em>',
'content' => [
'#markup' => 'Example message',
),
'cancel' => array(
],
'cancel' => [
'#type' => 'link',
'#title' => 'Cancel',
'#url' => Url::fromRoute('<front>'),
'#attributes' => array(
'#attributes' => [
// This is a special class to which JavaScript assigns dialog closing
// behavior.
'class' => array('dialog-cancel'),
),
),
);
'class' => ['dialog-cancel'],
],
],
];
return $content;
}
@@ -61,6 +61,15 @@ class AjaxTestController {
];
}
/**
* Returns the used theme.
*/
public function theme() {
return [
'#markup' => 'Current theme: ' . \Drupal::theme()->getActiveTheme()->getName(),
];
}
/**
* Returns an AjaxResponse; settings command set last.
*
@@ -102,90 +111,101 @@ class AjaxTestController {
public function dialog() {
// Add two wrapper elements for testing non-modal dialogs. Modal dialogs use
// the global drupal-modal wrapper by default.
$build['dialog_wrappers'] = array('#markup' => '<div id="ajax-test-dialog-wrapper-1"></div><div id="ajax-test-dialog-wrapper-2"></div>');
$build['dialog_wrappers'] = ['#markup' => '<div id="ajax-test-dialog-wrapper-1"></div><div id="ajax-test-dialog-wrapper-2"></div>'];
// Dialog behavior applied to a button.
$build['form'] = \Drupal::formBuilder()->getForm('Drupal\ajax_test\Form\AjaxTestDialogForm');
// Dialog behavior applied to a #type => 'link'.
$build['link'] = array(
$build['link'] = [
'#type' => 'link',
'#title' => 'Link 1 (modal)',
'#url' => Url::fromRoute('ajax_test.dialog_contents'),
'#attributes' => array(
'class' => array('use-ajax'),
'#attributes' => [
'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
),
);
],
];
// Dialog behavior applied to links rendered by links.html.twig.
$build['links'] = array(
$build['links'] = [
'#theme' => 'links',
'#links' => array(
'link2' => array(
'#links' => [
'link2' => [
'title' => 'Link 2 (modal)',
'url' => Url::fromRoute('ajax_test.dialog_contents'),
'attributes' => array(
'class' => array('use-ajax'),
'attributes' => [
'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
'data-dialog-options' => json_encode(array(
'data-dialog-options' => json_encode([
'width' => 400,
))
),
),
'link3' => array(
])
],
],
'link3' => [
'title' => 'Link 3 (non-modal)',
'url' => Url::fromRoute('ajax_test.dialog_contents'),
'attributes' => array(
'class' => array('use-ajax'),
'attributes' => [
'class' => ['use-ajax'],
'data-dialog-type' => 'dialog',
'data-dialog-options' => json_encode(array(
'data-dialog-options' => json_encode([
'target' => 'ajax-test-dialog-wrapper-1',
'width' => 800,
))
),
),
'link4' => array(
])
],
],
'link4' => [
'title' => 'Link 4 (close non-modal if open)',
'url' => Url::fromRoute('ajax_test.dialog_close'),
'attributes' => array(
'class' => array('use-ajax'),
'attributes' => [
'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
),
),
'link5' => array(
],
],
'link5' => [
'title' => 'Link 5 (form)',
'url' => Url::fromRoute('ajax_test.dialog_form'),
'attributes' => array(
'class' => array('use-ajax'),
'attributes' => [
'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
),
),
'link6' => array(
],
],
'link6' => [
'title' => 'Link 6 (entity form)',
'url' => Url::fromRoute('contact.form_add'),
'attributes' => array(
'class' => array('use-ajax'),
'attributes' => [
'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
'data-dialog-options' => json_encode(array(
'data-dialog-options' => json_encode([
'width' => 800,
'height' => 500,
))
),
),
'link7' => array(
])
],
],
'link7' => [
'title' => 'Link 7 (non-modal, no target)',
'url' => Url::fromRoute('ajax_test.dialog_contents'),
'attributes' => array(
'class' => array('use-ajax'),
'attributes' => [
'class' => ['use-ajax'],
'data-dialog-type' => 'dialog',
'data-dialog-options' => json_encode(array(
'data-dialog-options' => json_encode([
'width' => 800,
))
),
),
),
);
])
],
],
'link8' => [
'title' => 'Link 8 (ajax)',
'url' => Url::fromRoute('ajax_test.admin.theme'),
'attributes' => [
'class' => ['use-ajax'],
'data-dialog-type' => 'modal',
'data-dialog-options' => json_encode([
'width' => 400,
]),
],
],
],
];
return $build;
}
@@ -28,25 +28,25 @@ class AjaxTestDialogForm extends FormBase {
// In order to use WebTestBase::drupalPostAjaxForm() to POST from a link, we need
// to have a dummy field we can set in WebTestBase::drupalPostForm() else it won't
// submit anything.
$form['textfield'] = array(
$form['textfield'] = [
'#type' => 'hidden'
);
$form['button1'] = array(
];
$form['button1'] = [
'#type' => 'submit',
'#name' => 'button1',
'#value' => 'Button 1 (modal)',
'#ajax' => array(
'#ajax' => [
'callback' => '::modal',
),
);
$form['button2'] = array(
],
];
$form['button2'] = [
'#type' => 'submit',
'#name' => 'button2',
'#value' => 'Button 2 (non-modal)',
'#ajax' => array(
'#ajax' => [
'callback' => '::nonModal',
),
);
],
];
return $form;
}
@@ -93,7 +93,7 @@ class AjaxTestDialogForm extends FormBase {
protected function dialog($is_modal = FALSE) {
$content = AjaxTestController::dialogContents();
$response = new AjaxResponse();
$title = $this->t('AJAX Dialog contents');
$title = $this->t('AJAX Dialog & contents');
// Attach the library necessary for using the Open(Modal)DialogCommand and
// set the attachments for this Ajax response.
@@ -24,23 +24,23 @@ class AjaxTestForm extends FormBase {
$form['#action'] = \Drupal::url('ajax_test.dialog');
$form['description'] = array(
$form['description'] = [
'#markup' => '<p>' . $this->t("Ajax Form contents description.") . '</p>',
);
];
$form['actions'] = array(
$form['actions'] = [
'#type' => 'actions',
);
$form['actions']['submit'] = array(
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Do it'),
);
$form['actions']['preview'] = array(
];
$form['actions']['preview'] = [
'#type' => 'submit',
'#value' => $this->t('Preview'),
// No regular submit-handler. This form only works via JavaScript.
'#submit' => array(),
'#ajax' => array(
'#submit' => [],
'#ajax' => [
// This means the ::preview() method on this class would be invoked in
// case of a click event. However, since Drupal core's test runner only
// is able to execute PHP, not JS, there is no point in actually
@@ -51,8 +51,8 @@ class AjaxTestForm extends FormBase {
// we cannot meaningfully test it anyway.
'callback' => '::preview',
'event' => 'click',
),
);
],
];
return $form;
}
@@ -100,7 +100,7 @@ function _batch_test_finished_helper($batch_id, $success, $results, $operations)
if (!$success) {
// A fatal error occurred during the processing.
$error_operation = reset($operations);
$messages[] = t('An error occurred while processing @op with arguments:<br />@args', array('@op' => $error_operation[0], '@args' => print_r($error_operation[1], TRUE)));
$messages[] = t('An error occurred while processing @op with arguments:<br />@args', ['@op' => $error_operation[0], '@args' => print_r($error_operation[1], TRUE)]);
}
// Use item list template to render the messages.
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233790
datestamp: 1502903957
@@ -20,11 +20,11 @@ function _batch_test_nested_drupal_form_submit_callback($value) {
* Batch 0: Does nothing.
*/
function _batch_test_batch_0() {
$batch = array(
'operations' => array(),
$batch = [
'operations' => [],
'finished' => '_batch_test_finished_0',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
);
];
return $batch;
}
@@ -38,15 +38,15 @@ function _batch_test_batch_1() {
$total = 10;
$sleep = (1000000 / $total) * 2;
$operations = array();
$operations = [];
for ($i = 1; $i <= $total; $i++) {
$operations[] = array('_batch_test_callback_1', array($i, $sleep));
$operations[] = ['_batch_test_callback_1', [$i, $sleep]];
}
$batch = array(
$batch = [
'operations' => $operations,
'finished' => '_batch_test_finished_1',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
);
];
return $batch;
}
@@ -60,14 +60,14 @@ function _batch_test_batch_2() {
$total = 10;
$sleep = (1000000 / $total) * 2;
$operations = array(
array('_batch_test_callback_2', array(1, $total, $sleep)),
);
$batch = array(
$operations = [
['_batch_test_callback_2', [1, $total, $sleep]],
];
$batch = [
'operations' => $operations,
'finished' => '_batch_test_finished_2',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
);
];
return $batch;
}
@@ -85,20 +85,20 @@ function _batch_test_batch_3() {
$total = 10;
$sleep = (1000000 / $total) * 2;
$operations = array();
$operations = [];
for ($i = 1; $i <= round($total / 2); $i++) {
$operations[] = array('_batch_test_callback_1', array($i, $sleep));
$operations[] = ['_batch_test_callback_1', [$i, $sleep]];
}
$operations[] = array('_batch_test_callback_2', array(1, $total / 2, $sleep));
$operations[] = ['_batch_test_callback_2', [1, $total / 2, $sleep]];
for ($i = round($total / 2) + 1; $i <= $total; $i++) {
$operations[] = array('_batch_test_callback_1', array($i, $sleep));
$operations[] = ['_batch_test_callback_1', [$i, $sleep]];
}
$operations[] = array('_batch_test_callback_2', array(6, $total / 2, $sleep));
$batch = array(
$operations[] = ['_batch_test_callback_2', [6, $total / 2, $sleep]];
$batch = [
'operations' => $operations,
'finished' => '_batch_test_finished_3',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
);
];
return $batch;
}
@@ -115,19 +115,19 @@ function _batch_test_batch_4() {
$total = 10;
$sleep = (1000000 / $total) * 2;
$operations = array();
$operations = [];
for ($i = 1; $i <= round($total / 2); $i++) {
$operations[] = array('_batch_test_callback_1', array($i, $sleep));
$operations[] = ['_batch_test_callback_1', [$i, $sleep]];
}
$operations[] = array('_batch_test_nested_batch_callback', array());
$operations[] = ['_batch_test_nested_batch_callback', []];
for ($i = round($total / 2) + 1; $i <= $total; $i++) {
$operations[] = array('_batch_test_callback_1', array($i, $sleep));
$operations[] = ['_batch_test_callback_1', [$i, $sleep]];
}
$batch = array(
$batch = [
'operations' => $operations,
'finished' => '_batch_test_finished_4',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
);
];
return $batch;
}
@@ -141,15 +141,15 @@ function _batch_test_batch_5() {
$total = 10;
$sleep = (1000000 / $total) * 2;
$operations = array();
$operations = [];
for ($i = 1; $i <= $total; $i++) {
$operations[] = array('_batch_test_callback_5', array($i, $sleep));
$operations[] = ['_batch_test_callback_5', [$i, $sleep]];
}
$batch = array(
$batch = [
'operations' => $operations,
'finished' => '_batch_test_finished_5',
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
);
];
return $batch;
}
@@ -16,11 +16,11 @@ class BatchTestController {
* Render array containing success message.
*/
public function testRedirect() {
return array(
'success' => array(
return [
'success' => [
'#markup' => 'Redirection successful.',
)
);
]
];
}
/**
@@ -47,9 +47,9 @@ class BatchTestController {
*/
public function testNestedDrupalFormSubmit($value = 1) {
// Set the batch and process it.
$batch['operations'] = array(
array('_batch_test_nested_drupal_form_submit_callback', array($value)),
);
$batch['operations'] = [
['_batch_test_nested_drupal_form_submit_callback', [$value]],
];
batch_set($batch);
return batch_process('batch-test/redirect');
}
@@ -95,16 +95,16 @@ class BatchTestController {
* @return array
* Render array containing markup.
*/
function testProgrammatic($value = 1) {
public function testProgrammatic($value = 1) {
$form_state = (new FormState())->setValues([
'value' => $value,
]);
\Drupal::formBuilder()->submitForm('Drupal\batch_test\Form\BatchTestChainedForm', $form_state);
return array(
'success' => array(
return [
'success' => [
'#markup' => 'Got out of a programmatic batched form.',
)
);
]
];
}
/**
@@ -115,11 +115,11 @@ class BatchTestController {
*/
public function testThemeBatch() {
batch_test_stack(NULL, TRUE);
$batch = array(
'operations' => array(
array('_batch_test_theme_callback', array()),
),
);
$batch = [
'operations' => [
['_batch_test_theme_callback', []],
],
];
batch_set($batch);
return batch_process('batch-test/redirect');
}
@@ -23,21 +23,21 @@ class BatchTestChainedForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
// This value is used to test that $form_state persists through batched
// submit handlers.
$form['value'] = array(
$form['value'] = [
'#type' => 'textfield',
'#title' => 'Value',
'#default_value' => 1,
);
$form['submit'] = array(
];
$form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
);
$form['#submit'] = array(
];
$form['#submit'] = [
'Drupal\batch_test\Form\BatchTestChainedForm::batchTestChainedFormSubmit1',
'Drupal\batch_test\Form\BatchTestChainedForm::batchTestChainedFormSubmit2',
'Drupal\batch_test\Form\BatchTestChainedForm::batchTestChainedFormSubmit3',
'Drupal\batch_test\Form\BatchTestChainedForm::batchTestChainedFormSubmit4',
);
];
return $form;
}
@@ -21,14 +21,14 @@ class BatchTestMockForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['test_value'] = array(
$form['test_value'] = [
'#title' => t('Test value'),
'#type' => 'textfield',
);
$form['submit'] = array(
];
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
);
];
return $form;
}
@@ -27,13 +27,13 @@ class BatchTestMultiStepForm extends FormBase {
$form_state->set('step', $step);
}
$form['step_display'] = array(
$form['step_display'] = [
'#markup' => 'step ' . $step . '<br/>',
);
$form['submit'] = array(
];
$form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
);
];
// This is a POST form with multiple steps that does not transition from one
// step to the next via POST requests, but via GET requests, because it uses
@@ -21,21 +21,21 @@ class BatchTestSimpleForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['batch'] = array(
$form['batch'] = [
'#type' => 'select',
'#title' => 'Choose batch',
'#options' => array(
'#options' => [
'batch_0' => 'batch 0',
'batch_1' => 'batch 1',
'batch_2' => 'batch 2',
'batch_3' => 'batch 3',
'batch_4' => 'batch 4',
),
);
$form['submit'] = array(
],
];
$form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
);
];
return $form;
}
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233791
datestamp: 1502903957
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233791
datestamp: 1502903957
@@ -114,18 +114,18 @@ function common_test_module_implements_alter(&$implementations, $hook) {
* Implements hook_theme().
*/
function common_test_theme() {
return array(
'common_test_foo' => array(
'variables' => array('foo' => 'foo', 'bar' => 'bar'),
),
'common_test_render_element' => array(
return [
'common_test_foo' => [
'variables' => ['foo' => 'foo', 'bar' => 'bar'],
],
'common_test_render_element' => [
'render element' => 'foo',
),
'common_test_empty' => array(
'variables' => array('foo' => 'foo'),
],
'common_test_empty' => [
'variables' => ['foo' => 'foo'],
'function' => 'theme_common_test_empty',
),
);
],
];
}
/**
@@ -18,40 +18,40 @@ class CommonTestController {
* generator.
*/
public function typeLinkActiveClass() {
return array(
'no_query' => array(
return [
'no_query' => [
'#type' => 'link',
'#title' => t('Link with no query string'),
'#url' => Url::fromRoute('<current>'),
'#options' => array(
'#options' => [
'set_active_class' => TRUE,
),
),
'with_query' => array(
],
],
'with_query' => [
'#type' => 'link',
'#title' => t('Link with a query string'),
'#url' => Url::fromRoute('<current>'),
'#options' => array(
'query' => array(
'#options' => [
'query' => [
'foo' => 'bar',
'one' => 'two',
),
],
'set_active_class' => TRUE,
),
),
'with_query_reversed' => array(
],
],
'with_query_reversed' => [
'#type' => 'link',
'#title' => t('Link with the same query string in reverse order'),
'#url' => Url::fromRoute('<current>'),
'#options' => array(
'query' => array(
'#options' => [
'query' => [
'one' => 'two',
'foo' => 'bar',
),
],
'set_active_class' => TRUE,
),
),
);
],
],
];
}
/**
@@ -61,18 +61,18 @@ class CommonTestController {
* An empty string.
*/
public function jsAndCssQuerystring() {
$attached = array(
'#attached' => array(
'library' => array(
$attached = [
'#attached' => [
'library' => [
'node/drupal.node',
),
'css' => array(
drupal_get_path('module', 'node') . '/css/node.admin.css' => array(),
],
'css' => [
drupal_get_path('module', 'node') . '/css/node.admin.css' => [],
// A relative URI may have a query string.
'/' . drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2' => array(),
),
),
);
'/' . drupal_get_path('module', 'node') . '/node-fake.css?arg1=value1&arg2=value2' => [],
],
],
];
return \Drupal::service('renderer')->renderRoot($attached);
}
@@ -46,19 +46,19 @@ class JsonRenderer implements MainContentRendererInterface {
* {@inheritdoc}
*/
public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match) {
$json = [];
$json = [];
$json['content'] = (string) $this->renderer->renderRoot($main_content);
if (!empty($main_content['#title'])) {
$json['title'] = (string) $main_content['#title'];
}
else {
$json['title'] = (string) $this->titleResolver->getTitle($request, $route_match->getRouteObject());
}
$json['content'] = (string) $this->renderer->renderRoot($main_content);
if (!empty($main_content['#title'])) {
$json['title'] = (string) $main_content['#title'];
}
else {
$json['title'] = (string) $this->titleResolver->getTitle($request, $route_match->getRouteObject());
}
$response = new CacheableJsonResponse($json, 200);
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($main_content));
return $response;
$response = new CacheableJsonResponse($json, 200);
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($main_content));
return $response;
}
}
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233790
datestamp: 1502903957
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233791
datestamp: 1502903957
@@ -39,10 +39,10 @@ class FormController implements FormInterface {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form = $this->condition->buildConfigurationForm($form, $form_state);
$form['actions']['submit'] = array(
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('Submit'),
);
];
return $form;
}
@@ -0,0 +1,34 @@
<?php
namespace Drupal\condition_test\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
/**
* Provides a condition that has a no existing context.
*
* @Condition(
* id = "condition_test_no_existing_type",
* label = @Translation("No existing type"),
* context = {
* "no_existing_type" = @ContextDefinition("no_existing_type", label = @Translation("No existing type")),
* }
* )
*/
class ConditionTestNoExistingType extends ConditionPluginBase {
/**
* {@inheritdoc}
*/
public function evaluate() {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function summary() {
return $this->t('Condition that requires a non-existent context.');
}
}
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233790
datestamp: 1502903957
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233790
datestamp: 1502903957
@@ -0,0 +1,12 @@
name: CSRF test
type: module
description: 'Support testing protecting routes with CSRF token.'
package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
@@ -0,0 +1,27 @@
# Tests CSRF request header token protection.
csrf_test.protected:
path: csrf/protected
defaults:
_controller: '\Drupal\csrf_test\Controller\TestController::testMethod'
requirements:
_csrf_request_header_token: 'TRUE'
_method: 'POST'
# Tests deprecated _access_rest_csrf protection.
# This originally was in the REST module but now is supported in core/lib.
# @see https://www.drupal.org/node/2753681
# @todo Remove this test route in Drupal 9.0.0.
csrf_test.deprecated.protected:
path: csrf/deprecated/protected
defaults:
_controller: '\Drupal\csrf_test\Controller\TestController::testMethod'
requirements:
_access_rest_csrf: 'TRUE'
_method: 'POST'
# @todo This route can be removed in 8.3.
# @see \Drupal\Core\Access\CsrfRequestHeaderAccessCheck::access()
csrf_test.deprecated.csrftoken:
path: '/deprecated/session/token'
defaults:
_controller: '\Drupal\csrf_test\Controller\DeprecatedCsrfTokenController::csrfToken'
requirements:
_access: 'TRUE'
@@ -0,0 +1,57 @@
<?php
namespace Drupal\csrf_test\Controller;
use Drupal\Core\Access\CsrfTokenGenerator;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;
/**
* Returns responses for Deprecated CSRF token routes.
*
* This controller tests using the deprecated CSRF token key 'rest'.
*
* @todo This class can be removed in 8.3.
*
* @see \Drupal\Core\Access\CsrfRequestHeaderAccessCheck::access()
*/
class DeprecatedCsrfTokenController implements ContainerInjectionInterface {
/**
* The CSRF token generator.
*
* @var \Drupal\Core\Access\CsrfTokenGenerator
*/
protected $tokenGenerator;
/**
* Constructs a new CsrfTokenController object.
*
* @param \Drupal\Core\Access\CsrfTokenGenerator $token_generator
* The CSRF token generator.
*/
public function __construct(CsrfTokenGenerator $token_generator) {
$this->tokenGenerator = $token_generator;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('csrf_token')
);
}
/**
* Returns a CSRF using the deprecated 'rest' value protecting session token.
*
* @return \Symfony\Component\HttpFoundation\Response
* The response object.
*/
public function csrfToken() {
return new Response($this->tokenGenerator->get('rest'), 200, ['Content-Type' => 'text/plain']);
}
}
@@ -0,0 +1,22 @@
<?php
namespace Drupal\csrf_test\Controller;
use Symfony\Component\HttpFoundation\Response;
/**
* Just a test controller for test routes.
*/
class TestController {
/**
* Just a test method for the test routes.
*
* @return \Symfony\Component\HttpFoundation\Response
* The response object.
*/
public function testMethod() {
return new Response('Sometimes it is hard to think of test content!');
}
}
@@ -5,8 +5,8 @@ description: 'Support module for Database layer tests.'
package: Testing
# version: VERSION
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233790
datestamp: 1502903957
@@ -14,281 +14,281 @@
* like any other, not directly in the test file.
*/
function database_test_schema() {
$schema['test'] = array(
$schema['test'] = [
'description' => 'Basic test table for the database unit tests.',
'fields' => array(
'id' => array(
'fields' => [
'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
],
'name' => [
'description' => "A person's name",
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
'binary' => TRUE,
),
'age' => array(
],
'age' => [
'description' => "The person's age",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'job' => array(
],
'job' => [
'description' => "The person's job",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'Undefined',
),
),
'primary key' => array('id'),
'unique keys' => array(
'name' => array('name')
),
'indexes' => array(
'ages' => array('age'),
),
);
],
],
'primary key' => ['id'],
'unique keys' => [
'name' => ['name']
],
'indexes' => [
'ages' => ['age'],
],
];
// This is an alternate version of the same table that is structured the same
// but has a non-serial Primary Key.
$schema['test_people'] = array(
$schema['test_people'] = [
'description' => 'A duplicate version of the test table, used for additional tests.',
'fields' => array(
'name' => array(
'fields' => [
'name' => [
'description' => "A person's name",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'age' => array(
],
'age' => [
'description' => "The person's age",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'job' => array(
],
'job' => [
'description' => "The person's job",
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('job'),
'indexes' => array(
'ages' => array('age'),
),
);
],
],
'primary key' => ['job'],
'indexes' => [
'ages' => ['age'],
],
];
$schema['test_people_copy'] = array(
$schema['test_people_copy'] = [
'description' => 'A duplicate version of the test_people table, used for additional tests.',
'fields' => array(
'name' => array(
'fields' => [
'name' => [
'description' => "A person's name",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'age' => array(
],
'age' => [
'description' => "The person's age",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'job' => array(
],
'job' => [
'description' => "The person's job",
'type' => 'varchar_ascii',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('job'),
'indexes' => array(
'ages' => array('age'),
),
);
],
],
'primary key' => ['job'],
'indexes' => [
'ages' => ['age'],
],
];
$schema['test_one_blob'] = array(
$schema['test_one_blob'] = [
'description' => 'A simple table including a BLOB field for testing BLOB behavior.',
'fields' => array(
'id' => array(
'fields' => [
'id' => [
'description' => 'Simple unique ID.',
'type' => 'serial',
'not null' => TRUE,
),
'blob1' => array(
],
'blob1' => [
'description' => 'A BLOB field.',
'type' => 'blob',
),
),
'primary key' => array('id'),
);
],
],
'primary key' => ['id'],
];
$schema['test_two_blobs'] = array(
$schema['test_two_blobs'] = [
'description' => 'A simple test table with two BLOB fields.',
'fields' => array(
'id' => array(
'fields' => [
'id' => [
'description' => 'Simple unique ID.',
'type' => 'serial',
'not null' => TRUE,
),
'blob1' => array(
],
'blob1' => [
'description' => 'A dummy BLOB field.',
'type' => 'blob',
),
'blob2' => array(
],
'blob2' => [
'description' => 'A second BLOB field.',
'type' => 'blob'
),
),
'primary key' => array('id'),
);
],
],
'primary key' => ['id'],
];
$schema['test_task'] = array(
$schema['test_task'] = [
'description' => 'A task list for people in the test table.',
'fields' => array(
'tid' => array(
'fields' => [
'tid' => [
'description' => 'Task ID, primary key.',
'type' => 'serial',
'not null' => TRUE,
),
'pid' => array(
],
'pid' => [
'description' => 'The {test_people}.pid, foreign key for the test table.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'task' => array(
],
'task' => [
'description' => 'The task to be completed.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'priority' => array(
],
'priority' => [
'description' => 'The priority of the task.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('tid'),
);
],
],
'primary key' => ['tid'],
];
$schema['test_null'] = array(
$schema['test_null'] = [
'description' => 'Basic test table for NULL value handling.',
'fields' => array(
'id' => array(
'fields' => [
'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
],
'name' => [
'description' => "A person's name.",
'type' => 'varchar_ascii',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'age' => array(
],
'age' => [
'description' => "The person's age.",
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => 0),
),
'primary key' => array('id'),
'unique keys' => array(
'name' => array('name')
),
'indexes' => array(
'ages' => array('age'),
),
);
'default' => 0],
],
'primary key' => ['id'],
'unique keys' => [
'name' => ['name']
],
'indexes' => [
'ages' => ['age'],
],
];
$schema['test_serialized'] = array(
$schema['test_serialized'] = [
'description' => 'Basic test table for NULL value handling.',
'fields' => array(
'id' => array(
'fields' => [
'id' => [
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
],
'name' => [
'description' => "A person's name.",
'type' => 'varchar_ascii',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'info' => array(
],
'info' => [
'description' => "The person's data in serialized form.",
'type' => 'blob',
'serialize' => TRUE,
),
),
'primary key' => array('id'),
'unique keys' => array(
'name' => array('name')
),
);
],
],
'primary key' => ['id'],
'unique keys' => [
'name' => ['name']
],
];
$schema['test_composite_primary'] = array(
$schema['test_composite_primary'] = [
'description' => 'Basic test table with a composite primary key',
'fields' => array(
'name' => array(
'fields' => [
'name' => [
'description' => "A person's name",
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => '',
'binary' => TRUE,
),
'age' => array(
],
'age' => [
'description' => "The person's age",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'job' => array(
],
'job' => [
'description' => "The person's job",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'Undefined',
),
),
'primary key' => array('name', 'age'),
);
],
],
'primary key' => ['name', 'age'],
];
$schema['test_special_columns'] = array(
$schema['test_special_columns'] = [
'description' => 'A simple test table with special column names.',
'fields' => array(
'id' => array(
'fields' => [
'id' => [
'description' => 'Simple unique ID.',
'type' => 'int',
'not null' => TRUE,
),
'offset' => array(
],
'offset' => [
'description' => 'A column with preserved name.',
'type' => 'text',
),
),
'primary key' => array('id'),
);
],
],
'primary key' => ['id'],
];
$schema['TEST_UPPERCASE'] = $schema['test'];
@@ -19,11 +19,11 @@ class DatabaseTestController {
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function dbQueryTemporary() {
$table_name = db_query_temporary('SELECT age FROM {test}', array());
return new JsonResponse(array(
$table_name = db_query_temporary('SELECT age FROM {test}', []);
return new JsonResponse([
'table_name' => $table_name,
'row_count' => db_select($table_name)->countQuery()->execute()->fetchField(),
));
]);
}
/**
@@ -37,7 +37,7 @@ class DatabaseTestController {
public function pagerQueryEven($limit) {
$query = db_select('test', 't');
$query
->fields('t', array('name'))
->fields('t', ['name'])
->orderBy('age');
// This should result in 2 pages of results.
@@ -47,9 +47,9 @@ class DatabaseTestController {
$names = $query->execute()->fetchCol();
return new JsonResponse(array(
return new JsonResponse([
'names' => $names,
));
]);
}
/**
@@ -63,7 +63,7 @@ class DatabaseTestController {
public function pagerQueryOdd($limit) {
$query = db_select('test_task', 't');
$query
->fields('t', array('task'))
->fields('t', ['task'])
->orderBy('pid');
// This should result in 4 pages of results.
@@ -73,9 +73,9 @@ class DatabaseTestController {
$names = $query->execute()->fetchCol();
return new JsonResponse(array(
return new JsonResponse([
'names' => $names,
));
]);
}
/**
@@ -87,16 +87,16 @@ class DatabaseTestController {
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function testTablesort() {
$header = array(
'tid' => array('data' => t('Task ID'), 'field' => 'tid', 'sort' => 'desc'),
'pid' => array('data' => t('Person ID'), 'field' => 'pid'),
'task' => array('data' => t('Task'), 'field' => 'task'),
'priority' => array('data' => t('Priority'), 'field' => 'priority', ),
);
$header = [
'tid' => ['data' => t('Task ID'), 'field' => 'tid', 'sort' => 'desc'],
'pid' => ['data' => t('Person ID'), 'field' => 'pid'],
'task' => ['data' => t('Task'), 'field' => 'task'],
'priority' => ['data' => t('Priority'), 'field' => 'priority', ],
];
$query = db_select('test_task', 't');
$query
->fields('t', array('tid', 'pid', 'task', 'priority'));
->fields('t', ['tid', 'pid', 'task', 'priority']);
$query = $query
->extend('Drupal\Core\Database\Query\TableSortExtender')
@@ -105,9 +105,9 @@ class DatabaseTestController {
// We need all the results at once to check the sort.
$tasks = $query->execute()->fetchAll();
return new JsonResponse(array(
return new JsonResponse([
'tasks' => $tasks,
));
]);
}
/**
@@ -119,16 +119,16 @@ class DatabaseTestController {
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function testTablesortFirst() {
$header = array(
'tid' => array('data' => t('Task ID'), 'field' => 'tid', 'sort' => 'desc'),
'pid' => array('data' => t('Person ID'), 'field' => 'pid'),
'task' => array('data' => t('Task'), 'field' => 'task'),
'priority' => array('data' => t('Priority'), 'field' => 'priority', ),
);
$header = [
'tid' => ['data' => t('Task ID'), 'field' => 'tid', 'sort' => 'desc'],
'pid' => ['data' => t('Person ID'), 'field' => 'pid'],
'task' => ['data' => t('Task'), 'field' => 'task'],
'priority' => ['data' => t('Priority'), 'field' => 'priority', ],
];
$query = db_select('test_task', 't');
$query
->fields('t', array('tid', 'pid', 'task', 'priority'));
->fields('t', ['tid', 'pid', 'task', 'priority']);
$query = $query
->extend('Drupal\Core\Database\Query\TableSortExtender')
@@ -138,9 +138,9 @@ class DatabaseTestController {
// We need all the results at once to check the sort.
$tasks = $query->execute()->fetchAll();
return new JsonResponse(array(
return new JsonResponse([
'tasks' => $tasks,
));
]);
}
}
@@ -22,10 +22,10 @@ class DatabaseTestForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$header = array(
'username' => array('data' => t('Username'), 'field' => 'u.name'),
'status' => array('data' => t('Status'), 'field' => 'u.status'),
);
$header = [
'username' => ['data' => t('Username'), 'field' => 'u.name'],
'status' => ['data' => t('Status'), 'field' => 'u.status'],
];
$query = db_select('users_field_data', 'u');
$query->condition('u.uid', 0, '<>');
@@ -38,7 +38,7 @@ class DatabaseTestForm extends FormBase {
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
->extend('Drupal\Core\Database\Query\TableSortExtender');
$query
->fields('u', array('uid'))
->fields('u', ['uid'])
->limit(50)
->orderByHeader($header)
->setCountQuery($count_query);
@@ -46,22 +46,22 @@ class DatabaseTestForm extends FormBase {
->execute()
->fetchCol();
$options = array();
$options = [];
foreach (User::loadMultiple($uids) as $account) {
$options[$account->id()] = array(
'title' => array('data' => array('#title' => $account->getUsername())),
$options[$account->id()] = [
'title' => ['data' => ['#title' => $account->getUsername()]],
'username' => $account->getUsername(),
'status' => $account->isActive() ? t('active') : t('blocked'),
);
];
}
$form['accounts'] = array(
$form['accounts'] = [
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No people available.'),
);
];
return $form;
}
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233791
datestamp: 1502903957
@@ -31,8 +31,8 @@ class TestPageDisplayVariantSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
static function getSubscribedEvents() {
$events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = array('onSelectPageDisplayVariant');
public static function getSubscribedEvents() {
$events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = ['onSelectPageDisplayVariant'];
return $events;
}
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233791
datestamp: 1502903957
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233791
datestamp: 1502903957
@@ -3,28 +3,10 @@
namespace Drupal\early_rendering_controller_test;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Cache\UncacheableDependencyTrait;
class CacheableTestDomainObject extends TestDomainObject implements CacheableDependencyInterface {
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
return [];
}
/**
* {@inheritdoc}
*/
public function getCacheTags() {
return [];
}
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
return 0;
}
use UncacheableDependencyTrait;
}
@@ -37,7 +37,7 @@ class TestDomainObjectViewSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
static function getSubscribedEvents() {
public static function getSubscribedEvents() {
$events[KernelEvents::VIEW][] = ['onViewTestDomainObject'];
return $events;
@@ -5,8 +5,8 @@ description: 'Support module for CRUD hook tests.'
package: Testing
# version: VERSION
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233790
datestamp: 1502903957
@@ -88,7 +88,7 @@ display:
entity_field: title
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
@@ -10,8 +10,8 @@ dependencies:
- views
- entity_test
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233790
datestamp: 1502903957
@@ -12,7 +12,7 @@ use Drupal\Core\Field\BaseFieldDefinition;
* Implements hook_entity_base_field_info().
*/
function entity_reference_test_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields = array();
$fields = [];
if ($entity_type->id() === 'entity_test') {
$fields['user_role'] = BaseFieldDefinition::create('entity_reference')
@@ -33,10 +33,10 @@ function entity_reference_test_entity_base_field_info_alter(&$fields, EntityType
// Allow user_id field to use configurable widget.
$fields['user_id']
->setSetting('handler', 'default')
->setDisplayOptions('form', array(
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 0,
))
])
->setDisplayConfigurable('form', TRUE);
}
}
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- views
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233790
datestamp: 1502903957
@@ -0,0 +1,121 @@
langcode: en
status: true
dependencies:
module:
- entity_test
id: test_entity_reference_entity_test_view_long
label: test_entity_reference_entity_test_view_long
module: views
description: ''
tag: ''
base_table: entity_test_mul_changed_property
base_field: id
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: none
options: { }
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: full
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ' Previous'
next: 'Next '
first: '« First'
last: 'Last »'
quantity: 9
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
row:
type: fields
options:
inline: { }
separator: ''
hide_empty: false
default_field_elements: true
fields:
id:
id: id
table: entity_test_mul_changed_property
field: id
entity_type: entity_test
entity_field: id
plugin_id: field
id_1:
id: id_1
table: entity_test
field: id
entity_type: entity_test
entity_field: id
plugin_id: field
relationship: field_test_data_with_a_long_name
filters: { }
sorts:
id:
id: id
table: entity_test_mul_changed_property
field: id
entity_type: entity_test
entity_field: id
plugin_id: standard
header: { }
footer: { }
empty: { }
relationships:
field_test_data_with_a_long_name:
id: field_test_data_with_a_long_name_data
table: entity_test_mul_changed__field_test_data_with_a_long_name
field: field_test_data_with_a_long_name
plugin_id: standard
arguments: { }
display_extenders: { }
cache_metadata:
contexts:
- entity_test_view_grants
- languages
- 'languages:language_interface'
max-age: 0
@@ -0,0 +1,128 @@
langcode: en
status: true
dependencies: { }
id: test_entity_reference_group_by_empty_relationships
label: ''
module: views
description: ''
tag: ''
base_table: entity_test
base_field: id
core: '8'
display:
default:
display_options:
access:
type: none
cache:
type: tag
exposed_form:
type: basic
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
fields:
name_1:
id: name_1
table: entity_test
field: name
entity_type: entity_test
entity_field: name
plugin_id: field
relationship: none
group_type: group
group_column: value
group_columns: { }
group_rows: true
exclude: false
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
name_2:
id: name_2
table: entity_test_mul_property_data
field: name
entity_type: entity_test_mul
entity_field: name
plugin_id: field
relationship: reverse__entity_test_mul__field_data_test_unlimited
group_type: group
group_column: entity_id
group_columns: { }
group_rows: false
exclude: false
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
sorts:
name:
table: entity_test
field: name
id: name
entity_type: entity_test
entity_field: field_test
order: ASC
plugin_id: standard
pager:
type: some
style:
type: table
options:
grouping: { }
row_class: ''
default_row_class: true
override: true
sticky: false
caption: ''
summary: ''
description: ''
columns:
name_1: name_1
name_2: name_2
info:
name_1:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
name_2:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
default: '-1'
empty_table: false
row:
type: fields
options:
inline: { }
separator: ''
hide_empty: false
default_field_elements: true
relationships:
reverse__entity_test_mul__field_data_test_unlimited:
id: reverse__entity_test_mul__field_data_test_unlimited
table: entity_test
field: reverse__entity_test_mul__field_data_test_unlimited
entity_type: entity_test
plugin_id: entity_reverse
group_type: group
required: false
group_by: true
display_plugin: block
display_title: Master
id: default
position: 0
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- entity_test
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233791
datestamp: 1502903957
@@ -8,8 +8,8 @@ dependencies:
- field
- text
# Information added by Drupal.org packaging script on 2016-08-03
version: '8.1.8'
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
core: '8.x'
project: 'drupal'
datestamp: 1470233790
datestamp: 1502903957
@@ -15,12 +15,12 @@ use Drupal\field\Entity\FieldConfig;
function entity_test_install() {
foreach (entity_test_entity_types() as $entity_type) {
// Auto-create fields for testing.
FieldStorageConfig::create(array(
FieldStorageConfig::create([
'entity_type' => $entity_type,
'field_name' => 'field_test_text',
'type' => 'text',
'cardinality' => 1,
))->save();
])->save();
FieldConfig::create([
'entity_type' => $entity_type,
'field_name' => 'field_test_text',
@@ -30,7 +30,7 @@ function entity_test_install() {
])->save();
entity_get_form_display($entity_type, $entity_type, 'default')
->setComponent('field_test_text', array('type' => 'text_textfield'))
->setComponent('field_test_text', ['type' => 'text_textfield'])
->save();
}
}
@@ -40,17 +40,17 @@ function entity_test_install() {
*/
function entity_test_schema() {
// Schema for simple entity.
$schema['entity_test_example'] = array(
$schema['entity_test_example'] = [
'description' => 'Stores entity_test items.',
'fields' => array(
'id' => array(
'fields' => [
'id' => [
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique entity-test item ID.',
),
),
'primary key' => array('id'),
);
],
],
'primary key' => ['id'],
];
return $schema;
}
@@ -6,6 +6,7 @@
*/
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
@@ -53,7 +54,7 @@ const ENTITY_TEST_TYPES_ROUTING = 3;
* List with entity_types.
*/
function entity_test_entity_types($filter = NULL) {
$types = array();
$types = [];
if ($filter === NULL || $filter === ENTITY_TEST_TYPES_ROUTING) {
$types[] = 'entity_test';
}
@@ -92,8 +93,8 @@ function entity_test_entity_type_alter(array &$entity_types) {
}
}
// Allow entity_test_update tests to override the entity type definition.
$entity_types['entity_test_update'] = $state->get('entity_test_update.entity_type', $entity_types['entity_test_update']);
// Allow entity_test_with_bundle tests to override the entity type definition.
$entity_types['entity_test_with_bundle'] = $state->get('entity_test_with_bundle.entity_type', $entity_types['entity_test_with_bundle']);
// Enable the entity_test_new only when needed.
if (!$state->get('entity_test_new')) {
@@ -101,6 +102,17 @@ function entity_test_entity_type_alter(array &$entity_types) {
}
}
/**
* Implements hook_module_implements_alter().
*/
function entity_test_module_implements_alter(&$implementations, $hook) {
// Move our hook_entity_type_alter() implementation to the beginning of the
// list in order to run before content_moderation_entity_type_alter().
if ($hook === 'entity_type_alter') {
$implementations = ['entity_test' => $implementations['entity_test']] + $implementations;
}
}
/**
* Implements hook_entity_base_field_info().
*/
@@ -148,15 +160,6 @@ function entity_test_entity_base_field_info_alter(&$fields, EntityTypeInterface
}
}
/**
* Implements hook_entity_field_storage_info().
*/
function entity_test_entity_field_storage_info(EntityTypeInterface $entity_type) {
if ($entity_type->id() == 'entity_test_update') {
return \Drupal::state()->get('entity_test_update.additional_field_storage_definitions', array());
}
}
/**
* Creates a new bundle for entity_test entities.
*
@@ -170,8 +173,8 @@ function entity_test_entity_field_storage_info(EntityTypeInterface $entity_type)
* 'entity_test'.
*/
function entity_test_create_bundle($bundle, $text = NULL, $entity_type = 'entity_test') {
$bundles = \Drupal::state()->get($entity_type . '.bundles') ?: array($entity_type => array('label' => 'Entity Test Bundle'));
$bundles += array($bundle => array('label' => $text ? $text : $bundle));
$bundles = \Drupal::state()->get($entity_type . '.bundles') ?: [$entity_type => ['label' => 'Entity Test Bundle']];
$bundles += [$bundle => ['label' => $text ? $text : $bundle]];
\Drupal::state()->set($entity_type . '.bundles', $bundles);
\Drupal::entityManager()->onBundleCreate($bundle, $entity_type);
@@ -187,7 +190,7 @@ function entity_test_create_bundle($bundle, $text = NULL, $entity_type = 'entity
* 'entity_test'.
*/
function entity_test_delete_bundle($bundle, $entity_type = 'entity_test') {
$bundles = \Drupal::state()->get($entity_type . '.bundles') ?: array($entity_type => array('label' => 'Entity Test Bundle'));
$bundles = \Drupal::state()->get($entity_type . '.bundles') ?: [$entity_type => ['label' => 'Entity Test Bundle']];
unset($bundles[$bundle]);
\Drupal::state()->set($entity_type . '.bundles', $bundles);
@@ -198,11 +201,11 @@ function entity_test_delete_bundle($bundle, $entity_type = 'entity_test') {
* Implements hook_entity_bundle_info().
*/
function entity_test_entity_bundle_info() {
$bundles = array();
$bundles = [];
$entity_types = \Drupal::entityManager()->getDefinitions();
foreach ($entity_types as $entity_type_id => $entity_type) {
if ($entity_type->getProvider() == 'entity_test' && $entity_type_id != 'entity_test_with_bundle') {
$bundles[$entity_type_id] = \Drupal::state()->get($entity_type_id . '.bundles') ?: array($entity_type_id => array('label' => 'Entity Test Bundle'));
$bundles[$entity_type_id] = \Drupal::state()->get($entity_type_id . '.bundles') ?: [$entity_type_id => ['label' => 'Entity Test Bundle']];
}
}
return $bundles;
@@ -215,18 +218,18 @@ function entity_test_entity_view_mode_info_alter(&$view_modes) {
$entity_info = \Drupal::entityManager()->getDefinitions();
foreach ($entity_info as $entity_type => $info) {
if ($entity_info[$entity_type]->getProvider() == 'entity_test' && !isset($view_modes[$entity_type])) {
$view_modes[$entity_type] = array(
'full' => array(
$view_modes[$entity_type] = [
'full' => [
'label' => t('Full object'),
'status' => TRUE,
'cache' => TRUE,
),
'teaser' => array(
],
'teaser' => [
'label' => t('Teaser'),
'status' => TRUE,
'cache' => TRUE,
),
);
],
];
}
}
}
@@ -238,12 +241,12 @@ function entity_test_entity_form_mode_info_alter(&$form_modes) {
$entity_info = \Drupal::entityManager()->getDefinitions();
foreach ($entity_info as $entity_type => $info) {
if ($entity_info[$entity_type]->getProvider() == 'entity_test') {
$form_modes[$entity_type] = array(
'compact' => array(
$form_modes[$entity_type] = [
'compact' => [
'label' => t('Compact version'),
'status' => TRUE,
),
);
],
];
}
}
}
@@ -252,24 +255,24 @@ function entity_test_entity_form_mode_info_alter(&$form_modes) {
* Implements hook_entity_extra_field_info().
*/
function entity_test_entity_extra_field_info() {
$extra['entity_test']['bundle_with_extra_fields'] = array(
'display' => array(
$extra['entity_test']['bundle_with_extra_fields'] = [
'display' => [
// Note: those extra fields do not currently display anything, they are
// just used in \Drupal\Tests\field_ui\Kernel\EntityDisplayTest to test
// the behavior of entity display objects.
'display_extra_field' => array(
'display_extra_field' => [
'label' => t('Display extra field'),
'description' => t('An extra field on the display side.'),
'weight' => 5,
'visible' => TRUE,
),
'display_extra_field_hidden' => array(
],
'display_extra_field_hidden' => [
'label' => t('Display extra field (hidden)'),
'description' => t('An extra field on the display side, hidden by default.'),
'visible' => FALSE,
),
)
);
],
]
];
return $extra;
}
@@ -325,7 +328,11 @@ function entity_test_form_node_form_alter(&$form, FormStateInterface $form_state
* The loaded entity object, or NULL if the entity cannot be loaded.
*/
function entity_test_load($id, $reset = FALSE) {
return entity_load('entity_test', $id, $reset);
$storage = \Drupal::entityTypeManager()->getStorage('entity_test');
if ($reset) {
$storage->resetCache([$id]);
}
return $storage->load($id);
}
/**
@@ -340,7 +347,11 @@ function entity_test_load($id, $reset = FALSE) {
* The loaded entity object, or NULL if the entity cannot be loaded.
*/
function entity_test_rev_load($id, $reset = FALSE) {
return entity_load('entity_test_rev', $id, $reset);
$storage = \Drupal::entityTypeManager()->getStorage('entity_test_rev');
if ($reset) {
$storage->resetCache([$id]);
}
return $storage->load($id);
}
/**
@@ -355,7 +366,11 @@ function entity_test_rev_load($id, $reset = FALSE) {
* The loaded entity object, or FALSE if the entity cannot be loaded.
*/
function entity_test_mul_load($id, $reset = FALSE) {
return entity_load('entity_test_mul', $id, $reset);
$storage = \Drupal::entityTypeManager()->getStorage('entity_test_mul');
if ($reset) {
$storage->resetCache([$id]);
}
return $storage->load($id);
}
/**
@@ -370,7 +385,11 @@ function entity_test_mul_load($id, $reset = FALSE) {
* The loaded entity object, or NULL if the entity cannot be loaded.
*/
function entity_test_mulrev_load($id, $reset = FALSE) {
return entity_load('entity_test_mulrev', $id, $reset);
$storage = \Drupal::entityTypeManager()->getStorage('entity_test_mulrev');
if ($reset) {
$storage->resetCache([$id]);
}
return $storage->load($id);
}
/**
@@ -382,6 +401,25 @@ function entity_test_entity_test_insert($entity) {
}
}
/**
* Implements hook_entity_insert().
*/
function entity_test_entity_insert(EntityInterface $entity) {
if ($entity->getEntityTypeId() == 'entity_test_mulrev' && $entity->label() == 'EntityLoadedRevisionTest') {
$entity->setNewRevision(FALSE);
$entity->save();
}
}
/**
* Implements hook_entity_update().
*/
function entity_test_entity_update(EntityInterface $entity) {
if ($entity instanceof ContentEntityInterface) {
\Drupal::state()->set('entity_test.loadedRevisionId', $entity->getLoadedRevisionId());
}
}
/**
* Implements hook_entity_field_access().
*
@@ -626,16 +664,16 @@ function entity_test_field_default_value(FieldableEntityInterface $entity, Field
// that they are correctly passed.
$string = $definition->getName() . '_' . $entity->language()->getId();
// Return a "default value" with multiple items.
return array(
array(
return [
[
'shape' => "shape:0:$string",
'color' => "color:0:$string",
),
array(
],
[
'shape' => "shape:1:$string",
'color' => "color:1:$string",
),
);
],
];
}
/**
@@ -658,12 +696,23 @@ function _entity_test_record_hooks($hook, $data) {
* Implements hook_entity_prepare_view().
*/
function entity_test_entity_prepare_view($entity_type, array $entities, array $displays) {
// Add a dummy field item attribute on field_test_text if it exists.
if ($entity_type == 'entity_test') {
foreach ($entities as $entity) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
// Add a dummy field item attribute on field_test_text if it exists.
if ($entity->hasField('field_test_text') && $displays[$entity->bundle()]->getComponent('field_test_text')) {
foreach ($entity->get('field_test_text') as $item) {
$item->_attributes += array('data-field-item-attr' => 'foobar');
$item->_attributes += ['data-field-item-attr' => 'foobar'];
}
}
// Add a dummy field item attribute on daterange fields if they exist.
$fields = $entity->getFieldDefinitions();
foreach ($fields as $field) {
if ($field->getType() === 'daterange') {
$item = $entity->get($field->getName());
$item->_attributes += ['data-field-item-attr' => 'foobar'];
}
}
}
@@ -698,6 +747,16 @@ function entity_test_entity_access(EntityInterface $entity, $operation, AccountI
return AccessResult::allowed();
}
// Create specific labels to allow or deny access based on certain test
// conditions.
// @see \Drupal\KernelTests\Core\Entity\EntityAccessControlHandlerTest
if ($entity->label() == 'Accessible') {
return AccessResult::allowed();
}
if ($entity->label() == 'Inaccessible') {
return AccessResult::forbidden();
}
// Uncacheable because the access result depends on a State key-value pair and
// might therefore change at any time.
$condition = \Drupal::state()->get("entity_test_entity_access.{$operation}." . $entity->id(), FALSE);
@@ -4,40 +4,12 @@ namespace Drupal\entity_test\Controller;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\Query\QueryFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Controller routines for entity_test routes.
*/
class EntityTestController extends ControllerBase {
/**
* The entity query factory.
*
* @var \Drupal\Core\Entity\Query\QueryFactory
*/
protected $entityQueryFactory;
/**
* Constructs a new EntityTestController.
*
* @param \Drupal\Core\Entity\Query\QueryFactory
* The entity query factory.
*/
public function __construct(QueryFactory $entity_query_factory) {
$this->entityQueryFactory = $entity_query_factory;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.query')
);
}
/**
* Returns an empty page.
*
@@ -66,11 +38,10 @@ class EntityTestController extends ControllerBase {
->getStorage($referenced_entity_type)
->load($referenced_entity_id);
if ($referenced_entity === NULL) {
return array();
return [];
}
$query = $this->entityQueryFactory
->get('entity_test')
$query = $this->entityTypeManager()->getStorage('entity_test')->getQuery()
->condition($entity_reference_field_name . '.target_id', $referenced_entity_id);
$entities = $this->entityManager()
->getStorage('entity_test')
@@ -91,7 +62,7 @@ class EntityTestController extends ControllerBase {
*/
public function listEntitiesAlphabetically($entity_type_id) {
$entity_type_definition = $this->entityManager()->getDefinition($entity_type_id);
$query = $this->entityQueryFactory->get($entity_type_id);
$query = $this->entityTypeManager()->getStorage($entity_type_id)->getQuery();
// Sort by label field, if any.
if ($label_field = $entity_type_definition->getKey('label')) {
@@ -72,15 +72,15 @@ class EntityTest extends ContentEntityBase implements EntityOwnerInterface {
->setDescription(t('The name of the test entity.'))
->setTranslatable(TRUE)
->setSetting('max_length', 32)
->setDisplayOptions('view', array(
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'string',
'weight' => -5,
))
->setDisplayOptions('form', array(
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -5,
));
]);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Authored on'))
@@ -94,17 +94,17 @@ class EntityTest extends ContentEntityBase implements EntityOwnerInterface {
->setSetting('handler', 'default')
// Default EntityTest entities to have the root user as the owner, to
// simplify testing.
->setDefaultValue(array(0 => array('target_id' => 1)))
->setDefaultValue([0 => ['target_id' => 1]])
->setTranslatable(TRUE)
->setDisplayOptions('form', array(
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => -1,
'settings' => array(
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'placeholder' => '',
),
));
],
]);
return $fields;
}
@@ -53,39 +53,39 @@ class EntityTestBaseFieldDisplay extends EntityTest {
$fields['test_display_configurable'] = BaseFieldDefinition::create('text')
->setLabel(t('Field with configurable display'))
->setDisplayOptions('view', array(
->setDisplayOptions('view', [
'type' => 'text_default',
'weight' => 10,
))
])
->setDisplayConfigurable('view', TRUE)
->setDisplayOptions('form', array(
->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 10,
))
])
->setDisplayConfigurable('form', TRUE);
$fields['test_display_non_configurable'] = BaseFieldDefinition::create('text')
->setLabel(t('Field with non-configurable display'))
->setDisplayOptions('view', array(
->setDisplayOptions('view', [
'type' => 'text_default',
'weight' => 11,
))
->setDisplayOptions('form', array(
])
->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 11,
));
]);
$fields['test_display_multiple'] = BaseFieldDefinition::create('text')
->setLabel(t('A field with multiple values'))
->setCardinality(FieldStorageDefinition::CARDINALITY_UNLIMITED)
->setDisplayOptions('view', array(
->setDisplayOptions('view', [
'type' => 'text_default',
'weight' => 12,
))
->setDisplayOptions('form', array(
])
->setDisplayOptions('form', [
'type' => 'text_textfield',
'weight' => 12,
));
]);
return $fields;
}
@@ -36,15 +36,15 @@ class EntityTestCompositeConstraint extends EntityTest {
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['name']->setDisplayOptions('form', array(
$fields['name']->setDisplayOptions('form', [
'type' => 'string',
'weight' => 0,
));
]);
$fields['type']->setDisplayOptions('form', array(
$fields['type']->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 0,
));
]);
return $fields;
}
@@ -33,11 +33,11 @@ class EntityTestConstraintViolation extends EntityTest {
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['name']->setDisplayOptions('form', array(
$fields['name']->setDisplayOptions('form', [
'type' => 'string',
'weight' => 0,
));
$fields['name']->addConstraint('FieldWidgetConstraint', array());
]);
$fields['name']->addConstraint('FieldWidgetConstraint', []);
return $fields;
}
@@ -0,0 +1,55 @@
<?php
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
/**
* Defines the test entity class.
*
* @ContentEntityType(
* id = "entity_test_field_methods",
* label = @Translation("Test entity - data table"),
* handlers = {
* "view_builder" = "Drupal\entity_test\EntityTestViewBuilder",
* "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
* "form" = {
* "default" = "Drupal\entity_test\EntityTestForm",
* "delete" = "Drupal\entity_test\EntityTestDeleteForm"
* },
* "translation" = "Drupal\content_translation\ContentTranslationHandler",
* "views_data" = "Drupal\views\EntityViewsData",
* "route_provider" = {
* "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
* },
* },
* base_table = "entity_test_field_methods",
* data_table = "entity_test_field_methods_property",
* admin_permission = "administer entity_test content",
* translatable = TRUE,
* entity_keys = {
* "id" = "id",
* "uuid" = "uuid",
* "bundle" = "type",
* "label" = "name",
* "langcode" = "langcode",
* },
* )
*/
class EntityTestFieldMethods extends EntityTestMul {
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['test_invocation_order'] = BaseFieldDefinition::create('auto_incrementing_test')
->setLabel(t('Test field method invocation order.'))
->setTranslatable(TRUE);
return $fields;
}
}
@@ -60,6 +60,10 @@ class EntityTestMulChanged extends EntityTestMul implements EntityChangedInterfa
->setDescription(t('The time that the entity was last edited.'))
->setTranslatable(TRUE);
$fields['not_translatable'] = BaseFieldDefinition::create('string')
->setLabel(t('Non translatable'))
->setDescription(t('A non-translatable string field'));
return $fields;
}
@@ -27,6 +27,7 @@ namespace Drupal\entity_test\Entity;
* revision_data_table = "entity_test_mulrev_property_revision",
* admin_permission = "administer entity_test content",
* translatable = TRUE,
* show_revision_ui = TRUE,
* entity_keys = {
* "id" = "id",
* "uuid" = "uuid",
@@ -0,0 +1,46 @@
<?php
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\RevisionLogEntityTrait;
use Drupal\Core\Entity\RevisionLogInterface;
/**
* Defines the test entity class.
*
* @ContentEntityType(
* id = "entity_test_mulrev_chnged_revlog",
* label = @Translation("Test entity - revisions log and data table"),
* base_table = "entity_test_mulrev_changed_revlog",
* revision_table = "entity_test_mulrev_changed_revlog_revision",
* entity_keys = {
* "id" = "id",
* "uuid" = "uuid",
* "bundle" = "type",
* "revision" = "revision_id",
* "label" = "name",
* "langcode" = "langcode",
* },
* revision_metadata_keys = {
* "revision_user" = "revision_user",
* "revision_created" = "revision_created",
* "revision_log_message" = "revision_log_message"
* },
* )
*/
class EntityTestMulRevChangedWithRevisionLog extends EntityTestMulRevChanged implements RevisionLogInterface {
use RevisionLogEntityTrait;
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields += static::revisionLogBaseFieldDefinitions($entity_type);
return $fields;
}
}
@@ -0,0 +1,64 @@
<?php
namespace Drupal\entity_test\Entity;
use Drupal\Core\Entity\EntityPublishedInterface;
use Drupal\Core\Entity\EntityPublishedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Defines the test entity class.
*
* @ContentEntityType(
* id = "entity_test_mulrevpub",
* label = @Translation("Test entity - revisions, data table, and published interface"),
* handlers = {
* "view_builder" = "Drupal\entity_test\EntityTestViewBuilder",
* "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
* "form" = {
* "default" = "Drupal\entity_test\EntityTestForm",
* "delete" = "Drupal\entity_test\EntityTestDeleteForm"
* },
* "translation" = "Drupal\content_translation\ContentTranslationHandler",
* "views_data" = "Drupal\views\EntityViewsData",
* "route_provider" = {
* "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
* },
* },
* base_table = "entity_test_mulrevpub",
* data_table = "entity_test_mulrevpub_property_data",
* revision_table = "entity_test_mulrevpub_revision",
* revision_data_table = "entity_test_mulrevpub_property_revision",
* admin_permission = "administer entity_test content",
* translatable = TRUE,
* show_revision_ui = TRUE,
* entity_keys = {
* "id" = "id",
* "uuid" = "uuid",
* "bundle" = "type",
* "revision" = "revision_id",
* "label" = "name",
* "langcode" = "langcode",
* "published" = "status",
* },
* links = {
* "add-form" = "/entity_test_mulrevpub/add",
* "canonical" = "/entity_test_mulrevpub/manage/{entity_test_mulrevpub}",
* "delete-form" = "/entity_test/delete/entity_test_mulrevpub/{entity_test_mulrevpub}",
* "edit-form" = "/entity_test_mulrevpub/manage/{entity_test_mulrevpub}/edit",
* "revision" = "/entity_test_mulrevpub/{entity_test_mulrevpub}/revision/{entity_test_mulrevpub_revision}/view",
* }
* )
*/
class EntityTestMulRevPub extends EntityTestMulRev implements EntityPublishedInterface {
use EntityPublishedTrait;
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
return parent::baseFieldDefinitions($entity_type) + EntityPublishedTrait::publishedBaseFieldDefinitions($entity_type);
}
}
@@ -0,0 +1,24 @@
<?php
namespace Drupal\entity_test\Entity;
/**
* Test entity class with no bundle.
*
* @ContentEntityType(
* id = "entity_test_no_bundle",
* label = @Translation("Entity Test without bundle"),
* base_table = "entity_test_no_bundle",
* entity_keys = {
* "id" = "id",
* "revision" = "revision_id",
* },
* admin_permission = "administer entity_test content",
* links = {
* "add-form" = "/entity_test_no_bundle/add",
* },
* )
*/
class EntityTestNoBundle extends EntityTest {
}
@@ -19,7 +19,7 @@ namespace Drupal\entity_test\Entity;
class EntityTestNoLabel extends EntityTest {
/**
* @{inheritdoc}
* {@inheritdoc}
*/
public function label() {
return $this->getName();
@@ -0,0 +1,29 @@
<?php
namespace Drupal\entity_test\Entity;
/**
* Test entity class with revisions but without UUIDs.
*
* @ContentEntityType(
* id = "entity_test_no_uuid",
* label = @Translation("Test entity without UUID"),
* handlers = {
* "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
* },
* base_table = "entity_test_no_uuid",
* revision_table = "entity_test_no_uuid_revision",
* admin_permission = "administer entity_test content",
* persistent_cache = FALSE,
* entity_keys = {
* "id" = "id",
* "revision" = "vid",
* "bundle" = "type",
* "label" = "name",
* "langcode" = "langcode",
* },
* )
*/
class EntityTestNoUuid extends EntityTest {
}
@@ -28,6 +28,7 @@ use Drupal\Core\Field\BaseFieldDefinition;
* base_table = "entity_test_rev",
* revision_table = "entity_test_rev_revision",
* admin_permission = "administer entity_test content",
* show_revision_ui = TRUE,
* entity_keys = {
* "id" = "id",
* "uuid" = "uuid",
@@ -53,13 +54,6 @@ class EntityTestRev extends EntityTest {
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['revision_id'] = BaseFieldDefinition::create('integer')
->setLabel(t('Revision ID'))
->setDescription(t('The version id of the test entity.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['langcode']->setRevisionable(TRUE);
$fields['name']->setRevisionable(TRUE);
$fields['user_id']->setRevisionable(TRUE);
@@ -67,6 +61,7 @@ class EntityTestRev extends EntityTest {
->setLabel(t('Non Revisionable Field'))
->setDescription(t('A non-revisionable test field.'))
->setRevisionable(FALSE)
->setTranslatable(TRUE)
->setCardinality(1)
->setReadOnly(TRUE);
@@ -25,7 +25,8 @@ use Drupal\Core\Entity\EntityTypeInterface;
* entity_keys = {
* "id" = "id",
* "uuid" = "uuid",
* "bundle" = "type"
* "bundle" = "type",
* "label" = "name",
* },
* links = {
* "canonical" = "/entity_test_string_id/manage/{entity_test_string_id}",
@@ -45,13 +45,13 @@ class EntityTestAccessControlHandler extends EntityAccessControlHandler {
// Viewing the label of the 'entity_test_label' entity type is allowed.
return AccessResult::allowed();
}
elseif (in_array($operation, array('view', 'view label'))) {
elseif (in_array($operation, ['view', 'view label'])) {
if (!$entity->isDefaultTranslation()) {
return AccessResult::allowedIfHasPermission($account, 'view test entity translations');
}
return AccessResult::allowedIfHasPermission($account, 'view test entity');
}
elseif (in_array($operation, array('update', 'delete'))) {
elseif (in_array($operation, ['update', 'delete'])) {
return AccessResult::allowedIfHasPermission($account, 'administer entity_test content');
}
@@ -38,7 +38,7 @@ class EntityTestDefinitionSubscriber implements EventSubscriberInterface, Entity
/**
* {@inheritdoc}
*/
function __construct(StateInterface $state) {
public function __construct(StateInterface $state) {
$this->state = $state;
}
@@ -32,11 +32,11 @@ class EntityTestForm extends ContentEntityForm {
// @todo: Is there a better way to check if an entity type is revisionable?
if ($entity->getEntityType()->hasKey('revision') && !$entity->isNew()) {
$form['revision'] = array(
$form['revision'] = [
'#type' => 'checkbox',
'#title' => t('Create new revision'),
'#default_value' => $entity->isNewRevision(),
);
];
}
return $form;
@@ -58,10 +58,10 @@ class EntityTestForm extends ContentEntityForm {
$entity->save();
if ($is_new) {
$message = t('%entity_type @id has been created.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()));
$message = t('%entity_type @id has been created.', ['@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()]);
}
else {
$message = t('%entity_type @id has been updated.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()));
$message = t('%entity_type @id has been updated.', ['@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()]);
}
drupal_set_message($message);
@@ -69,7 +69,7 @@ class EntityTestForm extends ContentEntityForm {
$entity_type = $entity->getEntityTypeId();
$form_state->setRedirect(
"entity.$entity_type.edit_form",
array($entity_type => $entity->id())
[$entity_type => $entity->id()]
);
}
else {
@@ -2,7 +2,6 @@
namespace Drupal\entity_test;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityViewBuilder;
/**
@@ -12,15 +11,6 @@ use Drupal\Core\Entity\EntityViewBuilder;
*/
class EntityTestViewBuilder extends EntityViewBuilder {
/**
* {@inheritdoc}
*/
protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
$build = parent::getBuildDefaults($entity, $view_mode);
unset($build['#theme']);
return $build;
}
/**
* {@inheritdoc}
*/
@@ -28,18 +18,18 @@ class EntityTestViewBuilder extends EntityViewBuilder {
parent::buildComponents($build, $entities, $displays, $view_mode);
foreach ($entities as $id => $entity) {
$build[$id]['label'] = array(
$build[$id]['label'] = [
'#weight' => -100,
'#plain_text' => $entity->label(),
);
$build[$id]['separator'] = array(
];
$build[$id]['separator'] = [
'#weight' => -150,
'#markup' => ' | ',
);
$build[$id]['view_mode'] = array(
];
$build[$id]['view_mode'] = [
'#weight' => -200,
'#plain_text' => $view_mode,
);
];
}
}
@@ -13,16 +13,16 @@ class EntityTestLocalTasks extends DeriverBase {
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$this->derivatives = array();
$this->derivatives = [];
$types = entity_test_entity_types(ENTITY_TEST_TYPES_ROUTING);
foreach ($types as $entity_type) {
$this->derivatives[$entity_type . '.canonical'] = array();
$this->derivatives[$entity_type . '.canonical'] = [];
$this->derivatives[$entity_type . '.canonical']['base_route'] = "entity.$entity_type.canonical";
$this->derivatives[$entity_type . '.canonical']['route_name'] = "entity.$entity_type.canonical";
$this->derivatives[$entity_type . '.canonical']['title'] = 'View';
$this->derivatives[$entity_type . '.edit'] = array();
$this->derivatives[$entity_type . '.edit'] = [];
$this->derivatives[$entity_type . '.edit']['base_route'] = "entity.$entity_type.canonical";
$this->derivatives[$entity_type . '.edit']['route_name'] = "entity.$entity_type.edit_form";
$this->derivatives[$entity_type . '.edit']['title'] = 'Edit';
@@ -0,0 +1,28 @@
<?php
namespace Drupal\entity_test\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase;
/**
* Plugin implementation of the 'entity_reference_custom_cache_tag' formatter.
*
* @FieldFormatter(
* id = "entity_reference_custom_cache_tag",
* label = @Translation("Custom cache tag"),
* field_types = {
* "entity_reference"
* }
* )
*/
class EntityTestReferenceCustomCacheTagFormatter extends EntityReferenceFormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
return ['#cache' => ['tags' => ['custom_cache_tag']]];
}
}
@@ -0,0 +1,39 @@
<?php
namespace Drupal\entity_test\Plugin\Field\FieldType;
use Drupal\Core\Field\Plugin\Field\FieldType\IntegerItem;
/**
* Defines the 'field_method_invocation_order_test' entity field type.
*
* @FieldType(
* id = "auto_incrementing_test",
* label = @Translation("Auto incrementing test field item"),
* description = @Translation("An entity field designed to test the field method invocation order."),
* category = @Translation("Number"),
* no_ui = TRUE,
* )
*/
class AutoIncrementingTestItem extends IntegerItem {
/**
* {@inheritdoc}
*/
public function preSave() {
parent::preSave();
$this->value = static::getIncrementedFieldValue();
}
/**
* Gets an incremented field value.
*
* @return int
* The incremented field value.
*/
private static function getIncrementedFieldValue() {
$current_value = &drupal_static(__METHOD__, 0);
return ++$current_value;
}
}
@@ -46,14 +46,14 @@ class FieldTestItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
return array(
'columns' => array(
'value' => array(
return [
'columns' => [
'value' => [
'type' => 'varchar',
'length' => 255,
),
),
);
],
],
];
}
/**
@@ -21,9 +21,9 @@ class ShapeItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function defaultStorageSettings() {
return array(
return [
'foreign_key_name' => 'shape',
) + parent::defaultStorageSettings();
] + parent::defaultStorageSettings();
}
/**
@@ -43,30 +43,30 @@ class ShapeItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
$foreign_keys = array();
$foreign_keys = [];
// The 'foreign keys' key is not always used in tests.
if ($field_definition->getSetting('foreign_key_name')) {
$foreign_keys['foreign keys'] = array(
$foreign_keys['foreign keys'] = [
// This is a dummy foreign key definition, references a table that
// doesn't exist, but that's not a problem.
$field_definition->getSetting('foreign_key_name') => array(
$field_definition->getSetting('foreign_key_name') => [
'table' => $field_definition->getSetting('foreign_key_name'),
'columns' => array($field_definition->getSetting('foreign_key_name') => 'id'),
),
);
'columns' => [$field_definition->getSetting('foreign_key_name') => 'id'],
],
];
}
return array(
'columns' => array(
'shape' => array(
return [
'columns' => [
'shape' => [
'type' => 'varchar',
'length' => 32,
),
'color' => array(
],
'color' => [
'type' => 'varchar',
'length' => 32,
),
),
) + $foreign_keys;
],
],
] + $foreign_keys;
}
/**

Some files were not shown because too many files have changed in this diff Show More