Move into nested docroot
This commit is contained in:
parent
83a0d3a149
commit
c8b70abde9
13405 changed files with 0 additions and 0 deletions
6
web/core/modules/system/tests/css/system.module.css
Normal file
6
web/core/modules/system/tests/css/system.module.css
Normal file
|
@ -0,0 +1,6 @@
|
|||
|
||||
/**
|
||||
* This file is for testing CSS file override in
|
||||
* CascadingStylesheetsTestCase::testRenderOverride().
|
||||
* No contents are necessary.
|
||||
*/
|
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.engine
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.engine
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.inc
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.inc
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.install
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.install
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.make
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.make
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.bak
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.bak
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.orig
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.orig
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.save
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.save
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.swo
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.swo
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.swp
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module.swp
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module~
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.module~
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php-info.txt
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php-info.txt
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.bak
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.bak
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.orig
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.orig
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.save
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.save
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.swo
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.swo
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.swp
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php.swp
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php~
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.php~
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.po
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.po
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.profile
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.profile
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.sh
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.sh
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.sql
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.sql
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.theme
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.theme
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.tpl.php
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.tpl.php
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.twig
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.twig
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.xtmpl
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.xtmpl
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.yml
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/access_test.yml
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/composer.json
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/composer.json
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/composer.lock
generated
vendored
Normal file
0
web/core/modules/system/tests/fixtures/HtaccessTest/composer.lock
generated
vendored
Normal file
0
web/core/modules/system/tests/fixtures/IgnoreDirectories/a.txt
vendored
Normal file
0
web/core/modules/system/tests/fixtures/IgnoreDirectories/a.txt
vendored
Normal file
0
web/core/modules/system/tests/fixtures/IgnoreDirectories/frontend_framework/b.txt
vendored
Normal file
0
web/core/modules/system/tests/fixtures/IgnoreDirectories/frontend_framework/b.txt
vendored
Normal file
23
web/core/modules/system/tests/fixtures/update/block.block.secondtestfor2354889.yml
vendored
Normal file
23
web/core/modules/system/tests/fixtures/update/block.block.secondtestfor2354889.yml
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
uuid: C499B41D-035E-432E-9462-36410C43C49F
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- search
|
||||
theme:
|
||||
- bartik
|
||||
id: secondtestfor2354889
|
||||
theme: bartik
|
||||
region: sidebar_first
|
||||
weight: -6
|
||||
provider: null
|
||||
plugin: search_form_block
|
||||
settings:
|
||||
id: search_form_block
|
||||
label: Search
|
||||
provider: search
|
||||
label_display: visible
|
||||
cache:
|
||||
max_age: -1
|
||||
status: true
|
||||
visibility: { }
|
25
web/core/modules/system/tests/fixtures/update/block.block.testfor2005546.yml
vendored
Normal file
25
web/core/modules/system/tests/fixtures/update/block.block.testfor2005546.yml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
uuid: b299258f-6fb5-47f8-b42f-473787d02e22
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- system
|
||||
theme:
|
||||
- bartik
|
||||
id: bartik_branding
|
||||
theme: bartik
|
||||
region: header
|
||||
weight: 0
|
||||
provider: null
|
||||
plugin: system_branding_block
|
||||
settings:
|
||||
id: system_branding_block
|
||||
label: 'Site branding'
|
||||
provider: system
|
||||
label_display: '0'
|
||||
cache:
|
||||
max_age: -1
|
||||
use_site_logo: true
|
||||
use_site_name: true
|
||||
use_site_slogan: true
|
||||
visibility: { }
|
51
web/core/modules/system/tests/fixtures/update/block.block.testfor2354889.yml
vendored
Normal file
51
web/core/modules/system/tests/fixtures/update/block.block.testfor2354889.yml
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
uuid: 9d204071-a923-4707-8200-c298a540fb0c
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
content:
|
||||
- 'block_content:basic:c1895145-893e-460b-a24e-78cd2cefbb1f'
|
||||
module:
|
||||
- block_content
|
||||
- node
|
||||
- user
|
||||
theme:
|
||||
- bartik
|
||||
id: testfor2354889
|
||||
theme: bartik
|
||||
region: content
|
||||
weight: -6
|
||||
provider: null
|
||||
plugin: 'block_content:c1895145-893e-460b-a24e-78cd2cefbb1f'
|
||||
settings:
|
||||
id: 'block_content:c1895145-893e-460b-a24e-78cd2cefbb1f'
|
||||
label: 'Test for 2354889'
|
||||
provider: block_content
|
||||
label_display: visible
|
||||
cache:
|
||||
max_age: -1
|
||||
status: true
|
||||
info: ''
|
||||
view_mode: full
|
||||
visibility:
|
||||
node_type:
|
||||
id: node_type
|
||||
bundles:
|
||||
page: page
|
||||
negate: false
|
||||
context_mapping:
|
||||
node: node.node
|
||||
user_role:
|
||||
id: user_role
|
||||
roles:
|
||||
authenticated: authenticated
|
||||
negate: false
|
||||
context_mapping:
|
||||
user: user.current_user
|
||||
language:
|
||||
id: language
|
||||
langcodes:
|
||||
en: en
|
||||
de: de
|
||||
negate: false
|
||||
context_mapping:
|
||||
language: language.language_interface
|
17
web/core/modules/system/tests/fixtures/update/block.block.testfor2476947.yml
vendored
Normal file
17
web/core/modules/system/tests/fixtures/update/block.block.testfor2476947.yml
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
theme:
|
||||
- bartik
|
||||
id: bartik_page_title
|
||||
theme: bartik
|
||||
region: content
|
||||
weight: -50
|
||||
provider: null
|
||||
plugin: page_title_block
|
||||
settings:
|
||||
id: page_title_block
|
||||
label: 'Page title'
|
||||
provider: core
|
||||
label_display: '0'
|
||||
visibility: { }
|
19
web/core/modules/system/tests/fixtures/update/block.block.testfor2569529.yml
vendored
Normal file
19
web/core/modules/system/tests/fixtures/update/block.block.testfor2569529.yml
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
theme:
|
||||
- seven
|
||||
id: seven_secondary_local_tasks
|
||||
theme: seven
|
||||
region: pre_content
|
||||
weight: 0
|
||||
provider: null
|
||||
plugin: local_tasks_block
|
||||
settings:
|
||||
id: local_tasks_block
|
||||
label: 'Secondary tabs'
|
||||
provider: core
|
||||
label_display: '0'
|
||||
primary: false
|
||||
secondary: true
|
||||
visibility: { }
|
20
web/core/modules/system/tests/fixtures/update/block.block.testfor507488.yml
vendored
Normal file
20
web/core/modules/system/tests/fixtures/update/block.block.testfor507488.yml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
uuid: ee7c230c-337b-4e8f-8600-d65bfd34f171
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
theme:
|
||||
- seven
|
||||
id: seven_local_actions
|
||||
theme: seven
|
||||
region: content
|
||||
weight: -10
|
||||
provider: null
|
||||
plugin: local_actions_block
|
||||
settings:
|
||||
id: local_actions_block
|
||||
label: 'Primary admin actions'
|
||||
label_display: '0'
|
||||
cache:
|
||||
max_age: 0
|
||||
status: true
|
||||
visibility: { }
|
30
web/core/modules/system/tests/fixtures/update/block.block.thirdtestfor2354889.yml
vendored
Normal file
30
web/core/modules/system/tests/fixtures/update/block.block.thirdtestfor2354889.yml
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
uuid: 4558907D-2918-48FE-B56F-8A007B5FBDD5
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- user
|
||||
theme:
|
||||
- bartik
|
||||
id: thirdtestfor2354889
|
||||
theme: bartik
|
||||
region: sidebar_first
|
||||
weight: -6
|
||||
provider: null
|
||||
plugin: user_login_block
|
||||
settings:
|
||||
id: user_login_block
|
||||
label: 'User login'
|
||||
provider: user
|
||||
label_display: visible
|
||||
cache:
|
||||
max_age: -1
|
||||
status: true
|
||||
visibility:
|
||||
node_type:
|
||||
id: node_type
|
||||
bundles:
|
||||
page: page
|
||||
negate: false
|
||||
context_mapping:
|
||||
baloney: baloney_spam
|
BIN
web/core/modules/system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz
vendored
Normal file
BIN
web/core/modules/system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz
vendored
Normal file
Binary file not shown.
BIN
web/core/modules/system/tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz
vendored
Normal file
BIN
web/core/modules/system/tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz
vendored
Normal file
Binary file not shown.
BIN
web/core/modules/system/tests/fixtures/update/drupal-8.bare.standard.php.gz
vendored
Normal file
BIN
web/core/modules/system/tests/fixtures/update/drupal-8.bare.standard.php.gz
vendored
Normal file
Binary file not shown.
149
web/core/modules/system/tests/fixtures/update/drupal-8.block-content-uninstall.php
vendored
Normal file
149
web/core/modules/system/tests/fixtures/update/drupal-8.block-content-uninstall.php
vendored
Normal file
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Partial database to mimic the uninstallation of the block_content module.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
$connection->schema()->dropTable('block_content');
|
||||
$connection->schema()->dropTable('block_content__body');
|
||||
$connection->schema()->dropTable('block_content_field_data');
|
||||
$connection->schema()->dropTable('block_content_field_revision');
|
||||
$connection->schema()->dropTable('block_content_revision');
|
||||
$connection->schema()->dropTable('block_content_revision__body');
|
||||
|
||||
$connection->update('config')
|
||||
->condition('collection', '')
|
||||
->condition('name', 'core.extension')
|
||||
->fields(['data' => 'a:2:{s:6:"module";a:39:{s:5:"block";i:0;s:10:"breakpoint";i:0;s:8:"ckeditor";i:0;s:5:"color";i:0;s:7:"comment";i:0;s:6:"config";i:0;s:7:"contact";i:0;s:10:"contextual";i:0;s:8:"datetime";i:0;s:5:"dblog";i:0;s:6:"editor";i:0;s:16:"entity_reference";i:0;s:5:"field";i:0;s:8:"field_ui";i:0;s:4:"file";i:0;s:6:"filter";i:0;s:4:"help";i:0;s:7:"history";i:0;s:5:"image";i:0;s:4:"link";i:0;s:7:"menu_ui";i:0;s:4:"node";i:0;s:7:"options";i:0;s:10:"page_cache";i:0;s:4:"path";i:0;s:9:"quickedit";i:0;s:3:"rdf";i:0;s:6:"search";i:0;s:8:"shortcut";i:0;s:6:"system";i:0;s:8:"taxonomy";i:0;s:4:"text";i:0;s:7:"toolbar";i:0;s:4:"tour";i:0;s:4:"user";i:0;s:8:"views_ui";i:0;s:17:"menu_link_content";i:1;s:5:"views";i:10;s:8:"standard";i:1000;}s:5:"theme";a:3:{s:6:"classy";i:0;s:6:"bartik";i:0;s:5:"seven";i:0;}}'])
|
||||
->execute();
|
||||
|
||||
$connection->delete('config')
|
||||
->condition('name', 'block_content.type.basic')
|
||||
->execute();
|
||||
$connection->delete('config')
|
||||
->condition('name', 'core.entity_form_display.block_content.basic.default')
|
||||
->execute();
|
||||
$connection->delete('config')
|
||||
->condition('name', 'core.entity_view_display.block_content.basic.default')
|
||||
->execute();
|
||||
$connection->delete('config')
|
||||
->condition('name', 'core.entity_view_mode.block_content.full')
|
||||
->execute();
|
||||
$connection->delete('config')
|
||||
->condition('name', 'field.field.block_content.basic.body')
|
||||
->execute();
|
||||
$connection->delete('config')
|
||||
->condition('name', 'field.storage.block_content.body')
|
||||
->execute();
|
||||
$connection->delete('config')
|
||||
->condition('name', 'views.view.block_content')
|
||||
->execute();
|
||||
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'config.entity.key_store.block_content_type')
|
||||
->execute();
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'config.entity.key_store.entity_form_display')
|
||||
->condition('value', '%.block_content.%', 'LIKE')
|
||||
->execute();
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'config.entity.key_store.entity_view_display')
|
||||
->condition('value', '%.block_content.%', 'LIKE')
|
||||
->execute();
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'config.entity.key_store.entity_view_mode')
|
||||
->condition('value', '%.block_content.%', 'LIKE')
|
||||
->execute();
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'config.entity.key_store.field_config')
|
||||
->condition('value', '%.block_content.%', 'LIKE')
|
||||
->execute();
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'config.entity.key_store.field_storage_config')
|
||||
->condition('value', '%.block_content.%', 'LIKE')
|
||||
->execute();
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'config.entity.key_store.view')
|
||||
->condition('value', '%.block_content"%', 'LIKE')
|
||||
->execute();
|
||||
|
||||
$connection->update('key_value')
|
||||
->condition('collection', 'entity.definitions.bundle_field_map')
|
||||
->condition('name', 'block_content')
|
||||
->fields(['value' => 'a:0:{}'])
|
||||
->execute();
|
||||
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'entity.definitions.installed')
|
||||
->condition('name', 'block_content.entity_type')
|
||||
->execute();
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'entity.definitions.installed')
|
||||
->condition('name', 'block_content.field_storage_definitions')
|
||||
->execute();
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'entity.definitions.installed')
|
||||
->condition('name', 'block_content_type.entity_type')
|
||||
->execute();
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'entity.storage_schema.sql')
|
||||
->condition('name', 'block_content.entity_schema_data')
|
||||
->execute();
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'entity.storage_schema.sql')
|
||||
->condition('name', 'block_content.field_schema_data.%', 'LIKE')
|
||||
->execute();
|
||||
|
||||
$connection->update('key_value')
|
||||
->condition('collection', 'state')
|
||||
->condition('name', 'router.path_roots')
|
||||
->fields(['value' => 'a:27:{i:0;s:5:"admin";i:1;s:14:"block-category";i:2;s:7:"comment";i:3;s:8:"comments";i:4;s:7:"contact";i:5;s:4:"user";i:6;s:10:"contextual";i:7;s:6:"editor";i:8;s:4:"file";i:9;s:6:"filter";i:10;s:7:"history";i:11;s:5:"sites";i:12;s:6:"system";i:13;s:4:"node";i:14;s:9:"quickedit";i:15;s:6:"search";i:16;s:4:"cron";i:17;s:12:"machine_name";i:18;s:0:"";i:19;s:9:"<current>";i:20;s:5:"batch";i:21;s:10:"update.php";i:22;s:29:"entity_reference_autocomplete";i:23;s:8:"taxonomy";i:24;s:7:"toolbar";i:25;s:7:"rss.xml";i:26;s:5:"views";}'])
|
||||
->execute();
|
||||
$connection->update('key_value')
|
||||
->condition('collection', 'state')
|
||||
->condition('name', 'routing.non_admin_routes')
|
||||
->fields(['value' => 'a:79:{i:0;s:27:"block.category_autocomplete";i:1;s:24:"entity.comment.edit_form";i:2;s:15:"comment.approve";i:3;s:24:"entity.comment.canonical";i:4;s:26:"entity.comment.delete_form";i:5;s:13:"comment.reply";i:6;s:31:"comment.new_comments_node_links";i:7;s:21:"comment.node_redirect";i:8;s:17:"contact.site_page";i:9;s:22:"contact.site_page_form";i:10;s:24:"entity.user.contact_form";i:11;s:17:"contextual.render";i:12;s:17:"editor.filter_xss";i:13;s:31:"editor.field_untransformed_text";i:14;s:19:"editor.image_dialog";i:15;s:18:"editor.link_dialog";i:16;s:18:"file.ajax_progress";i:17;s:15:"filter.tips_all";i:18;s:11:"filter.tips";i:19;s:26:"history.get_last_node_view";i:20;s:17:"history.read_node";i:21;s:18:"image.style_public";i:22;s:19:"image.style_private";i:23;s:13:"node.add_page";i:24;s:8:"node.add";i:25;s:19:"entity.node.preview";i:26;s:27:"entity.node.version_history";i:27;s:20:"entity.node.revision";i:28;s:28:"node.revision_revert_confirm";i:29;s:28:"node.revision_delete_confirm";i:30;s:18:"quickedit.metadata";i:31;s:21:"quickedit.attachments";i:32;s:20:"quickedit.field_form";i:33;s:21:"quickedit.entity_save";i:34;s:11:"search.view";i:35;s:23:"search.view_node_search";i:36;s:23:"search.help_node_search";i:37;s:23:"search.view_user_search";i:38;s:23:"search.help_user_search";i:39;s:19:"shortcut.set_switch";i:40;s:11:"system.ajax";i:41;s:10:"system.401";i:42;s:10:"system.403";i:43;s:10:"system.404";i:44;s:11:"system.cron";i:45;s:33:"system.machine_name_transliterate";i:46;s:12:"system.files";i:47;s:28:"system.private_file_download";i:48;s:16:"system.temporary";i:49;s:7:"<front>";i:50;s:6:"<none>";i:51;s:9:"<current>";i:52;s:15:"system.timezone";i:53;s:22:"system.batch_page.html";i:54;s:22:"system.batch_page.json";i:55;s:16:"system.db_update";i:56;s:26:"system.entity_autocomplete";i:57;s:30:"entity.taxonomy_term.edit_form";i:58;s:32:"entity.taxonomy_term.delete_form";i:59;s:16:"toolbar.subtrees";i:60;s:13:"user.register";i:61;s:11:"user.logout";i:62;s:9:"user.pass";i:63;s:9:"user.page";i:64;s:10:"user.login";i:65;s:19:"user.cancel_confirm";i:66;s:10:"user.reset";i:67;s:21:"view.frontpage.feed_1";i:68;s:21:"view.frontpage.page_1";i:69;s:25:"view.taxonomy_term.feed_1";i:70;s:25:"view.taxonomy_term.page_1";i:71;s:10:"views.ajax";i:72;s:21:"entity.node.canonical";i:73;s:23:"entity.node.delete_form";i:74;s:21:"entity.node.edit_form";i:75;s:21:"entity.user.canonical";i:76;s:21:"entity.user.edit_form";i:77;s:23:"entity.user.cancel_form";i:78;s:30:"entity.taxonomy_term.canonical";}'])
|
||||
->execute();
|
||||
$connection->update('key_value')
|
||||
->condition('collection', 'state')
|
||||
->condition('name', 'views.view_route_names')
|
||||
->fields(['value' => 'a:8:{s:24:"user_admin_people.page_1";s:22:"entity.user.collection";s:20:"taxonomy_term.page_1";s:30:"entity.taxonomy_term.canonical";s:14:"content.page_1";s:20:"system.admin_content";s:12:"files.page_1";s:17:"view.files.page_1";s:12:"files.page_2";s:17:"view.files.page_2";s:16:"frontpage.feed_1";s:21:"view.frontpage.feed_1";s:16:"frontpage.page_1";s:21:"view.frontpage.page_1";s:20:"taxonomy_term.feed_1";s:25:"view.taxonomy_term.feed_1";}'])
|
||||
->execute();
|
||||
|
||||
$connection->delete('key_value')
|
||||
->condition('collection', 'system.schema')
|
||||
->condition('name', 'block_content')
|
||||
->execute();
|
||||
|
||||
$connection->delete('router')
|
||||
->condition('name', 'block_content.%', 'LIKE')
|
||||
->execute();
|
||||
$connection->delete('router')
|
||||
->condition('name', 'entity.block_content.%', 'LIKE')
|
||||
->execute();
|
||||
$connection->delete('router')
|
||||
->condition('name', 'entity.entity_form_display.block_content.%', 'LIKE')
|
||||
->execute();
|
||||
$connection->delete('router')
|
||||
->condition('name', 'entity.entity_view_display.block_content.%', 'LIKE')
|
||||
->execute();
|
||||
$connection->delete('router')
|
||||
->condition('name', 'entity.field_config.block_content_%', 'LIKE')
|
||||
->execute();
|
||||
$connection->delete('router')
|
||||
->condition('name', 'field_ui.field_storage_config_add_block_content')
|
||||
->execute();
|
||||
$connection->delete('router')
|
||||
->condition('name', 'view.block_content.page_1')
|
||||
->execute();
|
||||
$connection->delete('router')
|
||||
->condition('name', 'entity.block_content_type.collection')
|
||||
->execute();
|
||||
$connection->delete('router')
|
||||
->condition('name', 'entity.block_content_type.%', 'LIKE')
|
||||
->execute();
|
54
web/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php
vendored
Normal file
54
web/core/modules/system/tests/fixtures/update/drupal-8.block-context-manager-2354889.php
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
|
||||
* upgrade path of https://www.drupal.org/node/2354889.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// A custom block with visibility settings.
|
||||
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2354889.yml'));
|
||||
|
||||
// A custom block without any visibility settings.
|
||||
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.secondtestfor2354889.yml'));
|
||||
|
||||
// A custom block with visibility settings that contain a non-existing context
|
||||
// mapping.
|
||||
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.thirdtestfor2354889.yml'));
|
||||
|
||||
foreach ($block_configs as $block_config) {
|
||||
$connection->insert('config')
|
||||
->fields(array(
|
||||
'collection',
|
||||
'name',
|
||||
'data',
|
||||
))
|
||||
->values(array(
|
||||
'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.testfor2354889', 'block.block.secondtestfor2354889', 'block.block.thirdtestfor2354889']))
|
||||
])
|
||||
->condition('collection', 'config.entity.key_store.block')
|
||||
->condition('name', 'theme:bartik')
|
||||
->execute();
|
49
web/core/modules/system/tests/fixtures/update/drupal-8.block-test-enabled.php
vendored
Normal file
49
web/core/modules/system/tests/fixtures/update/drupal-8.block-test-enabled.php
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Partial database to mimic the installation of the block_test module.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Set the schema version.
|
||||
$connection->insert('key_value')
|
||||
->fields([
|
||||
'collection' => 'system.schema',
|
||||
'name' => 'block_test',
|
||||
'value' => 'i:8000;',
|
||||
])
|
||||
->execute();
|
||||
|
||||
// Update core.extension.
|
||||
$extensions = $connection->select('config')
|
||||
->fields('config', ['data'])
|
||||
->condition('collection', '')
|
||||
->condition('name', 'core.extension')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$extensions = unserialize($extensions);
|
||||
$extensions['module']['block_test'] = 8000;
|
||||
$connection->update('config')
|
||||
->fields([
|
||||
'data' => serialize($extensions),
|
||||
])
|
||||
->condition('collection', '')
|
||||
->condition('name', 'core.extension')
|
||||
->execute();
|
||||
|
||||
// Install the block configuration.
|
||||
$config = file_get_contents(__DIR__ . '/../../../../block/tests/modules/block_test/config/install/block.block.test_block.yml');
|
||||
$config = Yaml::parse($config);
|
||||
$connection->insert('config')
|
||||
->fields(['data', 'name', 'collection'])
|
||||
->values([
|
||||
'name' => 'block.block.test_block',
|
||||
'data' => serialize($config),
|
||||
'collection' => '',
|
||||
])
|
||||
->execute();
|
22
web/core/modules/system/tests/fixtures/update/drupal-8.broken_routing.php
vendored
Normal file
22
web/core/modules/system/tests/fixtures/update/drupal-8.broken_routing.php
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Test fixture.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
$config = unserialize($connection->query("SELECT data FROM {config} where name = :name", [':name' => 'core.extension'])->fetchField());
|
||||
$config['module']['update_script_test'] = 0;
|
||||
$connection->update('config')
|
||||
->fields(['data' => serialize($config)])
|
||||
->condition('name', 'core.extension')
|
||||
->execute();
|
||||
|
||||
$connection->insert('key_value')
|
||||
->fields(['collection' => 'system.schema', 'name' => 'update_script_test', 'value' => serialize(8000)])
|
||||
->execute();
|
37
web/core/modules/system/tests/fixtures/update/drupal-8.config-override-fix.php
vendored
Normal file
37
web/core/modules/system/tests/fixtures/update/drupal-8.config-override-fix.php
vendored
Normal file
|
@ -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();
|
||||
}
|
39
web/core/modules/system/tests/fixtures/update/drupal-8.editor-editor_update_8001.php
vendored
Normal file
39
web/core/modules/system/tests/fixtures/update/drupal-8.editor-editor_update_8001.php
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
|
||||
* upgrade path of editor_update_8001().
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Simulate an un-synchronized environment.
|
||||
|
||||
// Disable the 'basic_html' editor.
|
||||
$data = $connection->select('config')
|
||||
->fields('config', ['data'])
|
||||
->condition('name', 'editor.editor.basic_html')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$data = unserialize($data);
|
||||
$data['status'] = FALSE;
|
||||
$connection->update('config')
|
||||
->fields(['data' => serialize($data)])
|
||||
->condition('name', 'editor.editor.basic_html')
|
||||
->execute();
|
||||
|
||||
// Disable the 'full_html' text format.
|
||||
$data = $connection->select('config')
|
||||
->fields('config', ['data'])
|
||||
->condition('name', 'filter.format.full_html')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$data = unserialize($data);
|
||||
$data['status'] = FALSE;
|
||||
$connection->update('config')
|
||||
->fields(['data' => serialize($data)])
|
||||
->condition('name', 'filter.format.full_html')
|
||||
->execute();
|
74
web/core/modules/system/tests/fixtures/update/drupal-8.field-schema-data-uninstall-2573667.php
vendored
Normal file
74
web/core/modules/system/tests/fixtures/update/drupal-8.field-schema-data-uninstall-2573667.php
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
|
||||
* upgrade path of https://www.drupal.org/node/2573667.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
$connection->insert('key_value')
|
||||
->fields(array(
|
||||
'collection',
|
||||
'name',
|
||||
'value',
|
||||
))
|
||||
->values(array(
|
||||
'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(
|
||||
'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(
|
||||
'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(
|
||||
'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(
|
||||
'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(
|
||||
'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(
|
||||
'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(
|
||||
'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(
|
||||
'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(
|
||||
'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(
|
||||
'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();
|
BIN
web/core/modules/system/tests/fixtures/update/drupal-8.filled.standard.php.gz
vendored
Normal file
BIN
web/core/modules/system/tests/fixtures/update/drupal-8.filled.standard.php.gz
vendored
Normal file
Binary file not shown.
BIN
web/core/modules/system/tests/fixtures/update/drupal-8.language-enabled.php
vendored
Normal file
BIN
web/core/modules/system/tests/fixtures/update/drupal-8.language-enabled.php
vendored
Normal file
Binary file not shown.
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
|
||||
* upgrade path of https://www.drupal.org/node/507488.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Structure of a custom block with visibility settings.
|
||||
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor507488.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:seven')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$existing_blocks = unserialize($existing_blocks);
|
||||
|
||||
$connection->update('key_value')
|
||||
->fields([
|
||||
'value' => serialize(array_merge($existing_blocks, ['block.block.seven_local_actions']))
|
||||
])
|
||||
->condition('collection', 'config.entity.key_store.block')
|
||||
->condition('name', 'theme:seven')
|
||||
->execute();
|
||||
|
||||
// Enable test theme.
|
||||
$extensions = $connection->select('config')
|
||||
->fields('config', ['data'])
|
||||
->condition('name', 'core.extension')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$extensions = unserialize($extensions);
|
||||
$connection->update('config')
|
||||
->fields([
|
||||
'data' => serialize(array_merge_recursive($extensions, ['theme' => ['test_theme' => 0]]))
|
||||
])
|
||||
->condition('name', 'core.extension')
|
||||
->execute();
|
61
web/core/modules/system/tests/fixtures/update/drupal-8.page-title-into-block-2476947.php
vendored
Normal file
61
web/core/modules/system/tests/fixtures/update/drupal-8.page-title-into-block-2476947.php
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
|
||||
* upgrade path of https://www.drupal.org/node/2476947.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Structure of a custom block with visibility settings.
|
||||
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2476947.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.bartik_page_title']))
|
||||
])
|
||||
->condition('collection', 'config.entity.key_store.block')
|
||||
->condition('name', 'theme:bartik')
|
||||
->execute();
|
||||
|
||||
// Enable test theme.
|
||||
$extensions = $connection->select('config')
|
||||
->fields('config', ['data'])
|
||||
->condition('name', 'core.extension')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$extensions = unserialize($extensions);
|
||||
$connection->update('config')
|
||||
->fields([
|
||||
'data' => serialize(array_merge_recursive($extensions, ['theme' => ['test_theme' => 0]]))
|
||||
])
|
||||
->condition('name', 'core.extension')
|
||||
->execute();
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
|
||||
* upgrade path of https://www.drupal.org/node/507488.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Structure of a custom block with visibility settings.
|
||||
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2569529.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:seven')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$existing_blocks = unserialize($existing_blocks);
|
||||
|
||||
$connection->update('key_value')
|
||||
->fields([
|
||||
'value' => serialize(array_merge($existing_blocks, ['block.block.seven_secondary_local_tasks']))
|
||||
])
|
||||
->condition('collection', 'config.entity.key_store.block')
|
||||
->condition('name', 'theme:seven')
|
||||
->execute();
|
61
web/core/modules/system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php
vendored
Normal file
61
web/core/modules/system/tests/fixtures/update/drupal-8.site-branding-into-block-2005546.php
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
|
||||
* upgrade path of https://www.drupal.org/node/2005546.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Structure of a custom block with visibility settings.
|
||||
$block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2005546.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.bartik_branding']))
|
||||
])
|
||||
->condition('collection', 'config.entity.key_store.block')
|
||||
->condition('name', 'theme:bartik')
|
||||
->execute();
|
||||
|
||||
// Enable test theme.
|
||||
$extensions = $connection->select('config')
|
||||
->fields('config', ['data'])
|
||||
->condition('name', 'core.extension')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$extensions = unserialize($extensions);
|
||||
$connection->update('config')
|
||||
->fields([
|
||||
'data' => serialize(array_merge_recursive($extensions, ['theme' => ['test_theme' => 0]]))
|
||||
])
|
||||
->condition('name', 'core.extension')
|
||||
->execute();
|
25
web/core/modules/system/tests/fixtures/update/drupal-8.stable-base-theme-2575421.php
vendored
Normal file
25
web/core/modules/system/tests/fixtures/update/drupal-8.stable-base-theme-2575421.php
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
|
||||
* upgrade path of https://www.drupal.org/node/2575421.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Enable test_stable theme.
|
||||
$extensions = $connection->select('config')
|
||||
->fields('config', ['data'])
|
||||
->condition('name', 'core.extension')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$extensions = unserialize($extensions);
|
||||
$connection->update('config')
|
||||
->fields([
|
||||
'data' => serialize(array_merge_recursive($extensions, ['theme' => ['test_stable' => 0]]))
|
||||
])
|
||||
->condition('name', 'core.extension')
|
||||
->execute();
|
39
web/core/modules/system/tests/fixtures/update/drupal-8.update-test-postupdate-enabled.php
vendored
Normal file
39
web/core/modules/system/tests/fixtures/update/drupal-8.update-test-postupdate-enabled.php
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Partial database to mimic the installation of the update_test_post_update
|
||||
* module.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Set the schema version.
|
||||
$connection->merge('key_value')
|
||||
->condition('collection', 'system.schema')
|
||||
->condition('name', 'update_test_postupdate')
|
||||
->fields([
|
||||
'collection' => 'system.schema',
|
||||
'name' => 'update_test_postupdate',
|
||||
'value' => 'i:8000;',
|
||||
])
|
||||
->execute();
|
||||
|
||||
// Update core.extension.
|
||||
$extensions = $connection->select('config')
|
||||
->fields('config', ['data'])
|
||||
->condition('collection', '')
|
||||
->condition('name', 'core.extension')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$extensions = unserialize($extensions);
|
||||
$extensions['module']['update_test_postupdate'] = 8000;
|
||||
$connection->update('config')
|
||||
->fields([
|
||||
'data' => serialize($extensions),
|
||||
])
|
||||
->condition('collection', '')
|
||||
->condition('name', 'core.extension')
|
||||
->execute();
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Partial database to mimic the installation of the update_test_failing module.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Set the schema version.
|
||||
$connection->merge('key_value')
|
||||
->condition('collection', 'system.schema')
|
||||
->condition('name', 'update_test_failing')
|
||||
->fields([
|
||||
'collection' => 'system.schema',
|
||||
'name' => 'update_test_failing',
|
||||
'value' => 'i:8000;',
|
||||
])
|
||||
->execute();
|
||||
|
||||
// Update core.extension.
|
||||
$extensions = $connection->select('config')
|
||||
->fields('config', ['data'])
|
||||
->condition('collection', '')
|
||||
->condition('name', 'core.extension')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$extensions = unserialize($extensions);
|
||||
$extensions['module']['update_test_failing'] = 8000;
|
||||
$connection->update('config')
|
||||
->fields([
|
||||
'data' => serialize($extensions),
|
||||
])
|
||||
->condition('collection', '')
|
||||
->condition('name', 'core.extension')
|
||||
->execute();
|
54
web/core/modules/system/tests/fixtures/update/drupal-8.update-test-schema-enabled.php
vendored
Normal file
54
web/core/modules/system/tests/fixtures/update/drupal-8.update-test-schema-enabled.php
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Partial database to mimic the installation of the update_test_schema module.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Create the table.
|
||||
$connection->schema()->createTable('update_test_schema_table', array(
|
||||
'fields' => array(
|
||||
'a' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'size' => 'normal',
|
||||
),
|
||||
'b' => array(
|
||||
'type' => 'blob',
|
||||
'not null' => FALSE,
|
||||
'size' => 'normal',
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
// Set the schema version.
|
||||
$connection->merge('key_value')
|
||||
->condition('collection', 'system.schema')
|
||||
->condition('name', 'update_test_schema')
|
||||
->fields([
|
||||
'collection' => 'system.schema',
|
||||
'name' => 'update_test_schema',
|
||||
'value' => 'i:8000;',
|
||||
])
|
||||
->execute();
|
||||
|
||||
// Update core.extension.
|
||||
$extensions = $connection->select('config')
|
||||
->fields('config', ['data'])
|
||||
->condition('collection', '')
|
||||
->condition('name', 'core.extension')
|
||||
->execute()
|
||||
->fetchField();
|
||||
$extensions = unserialize($extensions);
|
||||
$extensions['module']['update_test_schema'] = 8000;
|
||||
$connection->update('config')
|
||||
->fields([
|
||||
'data' => serialize($extensions),
|
||||
])
|
||||
->condition('collection', '')
|
||||
->condition('name', 'core.extension')
|
||||
->execute();
|
32
web/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php
vendored
Normal file
32
web/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
|
||||
* upgrade path of https://www.drupal.org/node/2455125.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
// Structure of a view with timestamp fields.
|
||||
$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(
|
||||
'collection',
|
||||
'name',
|
||||
'data',
|
||||
))
|
||||
->values(array(
|
||||
'collection' => '',
|
||||
'name' => 'views.view.' . $views_config['id'],
|
||||
'data' => serialize($views_config),
|
||||
))
|
||||
->execute();
|
||||
}
|
294
web/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.yml
vendored
Normal file
294
web/core/modules/system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.yml
vendored
Normal file
|
@ -0,0 +1,294 @@
|
|||
uuid: e693b165-0e14-4dee-9909-9f0892037c23
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- user
|
||||
id: update_test
|
||||
label: 'Update Test'
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: users_field_data
|
||||
base_field: uid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
options:
|
||||
perm: 'access user profiles'
|
||||
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: none
|
||||
options:
|
||||
items_per_page: 0
|
||||
offset: 0
|
||||
style:
|
||||
type: default
|
||||
row:
|
||||
type: fields
|
||||
fields:
|
||||
name:
|
||||
id: name
|
||||
table: users_field_data
|
||||
field: name
|
||||
entity_type: user
|
||||
entity_field: name
|
||||
label: ''
|
||||
alter:
|
||||
alter_text: false
|
||||
make_link: false
|
||||
absolute: false
|
||||
trim: false
|
||||
word_boundary: false
|
||||
ellipsis: false
|
||||
strip_tags: false
|
||||
html: false
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
plugin_id: field
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
exclude: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: user_name
|
||||
settings: { }
|
||||
group_column: value
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: 0
|
||||
delta_offset: 0
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
created:
|
||||
id: created
|
||||
table: users_field_data
|
||||
field: created
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
date_format: long
|
||||
custom_date_format: ''
|
||||
timezone: Africa/Abidjan
|
||||
entity_type: user
|
||||
entity_field: created
|
||||
plugin_id: date
|
||||
created_1:
|
||||
id: created_1
|
||||
table: users_field_data
|
||||
field: created
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
date_format: 'raw time ago'
|
||||
custom_date_format: ''
|
||||
timezone: ''
|
||||
entity_type: user
|
||||
entity_field: created
|
||||
plugin_id: date
|
||||
created_2:
|
||||
id: created_2
|
||||
table: users_field_data
|
||||
field: created
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
date_format: 'time ago'
|
||||
custom_date_format: ''
|
||||
timezone: ''
|
||||
entity_type: user
|
||||
entity_field: created
|
||||
plugin_id: date
|
||||
filters: { }
|
||||
sorts: { }
|
||||
title: 'Update Test'
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
cache_metadata:
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- user.permissions
|
||||
cacheable: false
|
||||
block_1:
|
||||
display_plugin: block
|
||||
id: block_1
|
||||
display_title: Block
|
||||
position: 1
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
allow:
|
||||
items_per_page: false
|
||||
cache_metadata:
|
||||
contexts:
|
||||
- 'languages:language_content'
|
||||
- 'languages:language_interface'
|
||||
- user.permissions
|
||||
cacheable: false
|
21
web/core/modules/system/tests/fixtures/update/drupal-8.without_automated_cron.php
vendored
Normal file
21
web/core/modules/system/tests/fixtures/update/drupal-8.without_automated_cron.php
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Test fixture.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
$config = $connection;
|
||||
|
||||
$connection->merge('config')
|
||||
->condition('name', 'system.cron')
|
||||
->condition('collection', '')
|
||||
->fields([
|
||||
'name' => 'system.cron',
|
||||
'collection' => '',
|
||||
'data' => serialize(['threshold' => ['autorun' => 0]]),
|
||||
])
|
||||
->execute();
|
22
web/core/modules/system/tests/fixtures/update/drupal8.views-image-style-dependency-2649914.php
vendored
Normal file
22
web/core/modules/system/tests/fixtures/update/drupal8.views-image-style-dependency-2649914.php
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains database additions to drupal-8-rc1.bare.standard.php.gz for testing
|
||||
* the upgrade path of https://www.drupal.org/node/2649914.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Serialization\Yaml;
|
||||
|
||||
$connection = Database::getConnection();
|
||||
|
||||
$views_config = Yaml::decode(file_get_contents(__DIR__ . '/drupal8.views-image-style-dependency-2649914.yml'));
|
||||
|
||||
$connection->insert('config')
|
||||
->fields(['collection', 'name', 'data'])
|
||||
->values([
|
||||
'collection' => '',
|
||||
'name' => 'views.view.' . $views_config['id'],
|
||||
'data' => serialize($views_config),
|
||||
])->execute();
|
43
web/core/modules/system/tests/fixtures/update/drupal8.views-image-style-dependency-2649914.yml
vendored
Normal file
43
web/core/modules/system/tests/fixtures/update/drupal8.views-image-style-dependency-2649914.yml
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- field.storage.node.field_image
|
||||
module:
|
||||
- image
|
||||
- node
|
||||
id: foo
|
||||
label: Foo
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_data
|
||||
base_field: nid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
fields:
|
||||
field_image:
|
||||
id: field_image
|
||||
table: node__field_image
|
||||
field: field_image
|
||||
type: image
|
||||
settings:
|
||||
image_style: thumbnail
|
||||
image_link: ''
|
||||
plugin_id: field
|
||||
field_image_1:
|
||||
id: field_image_1
|
||||
table: node__field_image
|
||||
field: field_image
|
||||
type: image
|
||||
settings:
|
||||
# This field's formatter is using a non-existent image style.
|
||||
image_style: nonexistent
|
||||
image_link: ''
|
||||
plugin_id: field
|
1
web/core/modules/system/tests/fixtures/update/es-system.cron.yml
vendored
Normal file
1
web/core/modules/system/tests/fixtures/update/es-system.cron.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
bogus_key: 'Should be cleaned by system_update_8200'
|
15
web/core/modules/system/tests/fixtures/update/es-views.view.content.yml
vendored
Normal file
15
web/core/modules/system/tests/fixtures/update/es-views.view.content.yml
vendored
Normal file
|
@ -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'
|
29
web/core/modules/system/tests/http.php
Normal file
29
web/core/modules/system/tests/http.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Fake an HTTP request, for use during testing.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Test\TestKernel;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
chdir('../../../..');
|
||||
|
||||
$autoloader = require_once 'autoload.php';
|
||||
|
||||
// Change to HTTP.
|
||||
$_SERVER['HTTPS'] = NULL;
|
||||
ini_set('session.cookie_secure', FALSE);
|
||||
foreach ($_SERVER as &$value) {
|
||||
$value = str_replace('core/modules/system/tests/http.php', 'index.php', $value);
|
||||
$value = str_replace('https://', 'http://', $value);
|
||||
}
|
||||
|
||||
$kernel = new TestKernel('testing', $autoloader, TRUE);
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
$response = $kernel->handle($request);
|
||||
$response->send();
|
||||
|
||||
$kernel->terminate($request, $response);
|
31
web/core/modules/system/tests/https.php
Normal file
31
web/core/modules/system/tests/https.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Fake an HTTPS request, for use during testing.
|
||||
*
|
||||
* @todo Fix this to use a new request rather than modifying server variables,
|
||||
* see http.php.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Test\TestKernel;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
chdir('../../../..');
|
||||
|
||||
$autoloader = require_once 'autoload.php';
|
||||
|
||||
// Change to HTTPS.
|
||||
$_SERVER['HTTPS'] = 'on';
|
||||
foreach ($_SERVER as &$value) {
|
||||
$value = str_replace('core/modules/system/tests/https.php', 'index.php', $value);
|
||||
$value = str_replace('http://', 'https://', $value);
|
||||
}
|
||||
|
||||
$kernel = new TestKernel('testing', $autoloader, TRUE);
|
||||
|
||||
$request = Request::createFromGlobals();
|
||||
$response = $kernel->handle($request);
|
||||
$response->send();
|
||||
|
||||
$kernel->terminate($request, $response);
|
BIN
web/core/modules/system/tests/logo.svgz
Normal file
BIN
web/core/modules/system/tests/logo.svgz
Normal file
Binary file not shown.
|
@ -0,0 +1,5 @@
|
|||
name: Accept header based routing test
|
||||
core: 8.x
|
||||
type: module
|
||||
package: Testing
|
||||
version: VERSION
|
|
@ -0,0 +1,5 @@
|
|||
services:
|
||||
accept_header_matcher:
|
||||
class: Drupal\accept_header_routing_test\Routing\AcceptHeaderMatcher
|
||||
tags:
|
||||
- { name: route_filter }
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\accept_header_routing_test;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
/**
|
||||
* Example implementation of accept header based content negotation.
|
||||
*/
|
||||
class AcceptHeaderMiddleware implements HttpKernelInterface {
|
||||
|
||||
/**
|
||||
* Constructs a new AcceptHeaderMiddleware instance.
|
||||
*
|
||||
* @param \Symfony\Component\HttpKernel\HttpKernelInterface $app
|
||||
* The app.
|
||||
*/
|
||||
public function __construct(HttpKernelInterface $app) {
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
|
||||
$mapping = [
|
||||
'application/json' => 'json',
|
||||
'application/hal+json' => 'hal_json',
|
||||
'application/xml' => 'xml',
|
||||
'text/html' => 'html',
|
||||
];
|
||||
|
||||
$accept = $request->headers->get('Accept') ?: ['text/html'];
|
||||
if (isset($mapping[$accept[0]])) {
|
||||
$request->setRequestFormat($mapping[$accept[0]]);
|
||||
}
|
||||
|
||||
return $this->app->handle($request, $type, $catch);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\accept_header_routing_test;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
|
||||
|
||||
/**
|
||||
* Service provider for the accept_header_routing_test module.
|
||||
*/
|
||||
class AcceptHeaderRoutingTestServiceProvider implements ServiceModifierInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function alter(ContainerBuilder $container) {
|
||||
// Remove the basic content negotation middleware and replace it with a
|
||||
// basic header based one.
|
||||
$container->register('http_middleware.negotiation', 'Drupal\accept_header_routing_test\AcceptHeaderMiddleware')
|
||||
->addTag('http_middleware', ['priority' => 400]);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\accept_header_routing_test\Routing;
|
||||
|
||||
use Drupal\Core\Routing\RouteFilterInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* Filters routes based on the media type specified in the HTTP Accept headers.
|
||||
*/
|
||||
class AcceptHeaderMatcher implements RouteFilterInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function filter(RouteCollection $collection, Request $request) {
|
||||
// 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));
|
||||
$primary_format = $request->getRequestFormat();
|
||||
|
||||
foreach ($collection as $name => $route) {
|
||||
// _format could be a |-delimited list of supported formats.
|
||||
$supported_formats = array_filter(explode('|', $route->getRequirement('_format')));
|
||||
|
||||
if (empty($supported_formats)) {
|
||||
// No format restriction on the route, so it always matches. Move it to
|
||||
// the end of the collection by re-adding it.
|
||||
$collection->add($name, $route);
|
||||
}
|
||||
elseif (in_array($primary_format, $supported_formats)) {
|
||||
// Perfect match, which will get a higher priority by leaving the route
|
||||
// on top of the list.
|
||||
}
|
||||
// The route partially matches if it doesn't care about format, if it
|
||||
// explicitly allows any format, or if one of its allowed formats is
|
||||
// in the request's list of acceptable formats.
|
||||
elseif (in_array('*/*', $acceptable_mime_types) || array_intersect($acceptable_formats, $supported_formats)) {
|
||||
// Move it to the end of the list.
|
||||
$collection->add($name, $route);
|
||||
}
|
||||
else {
|
||||
// Remove the route if it does not match at all.
|
||||
$collection->remove($name);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($collection)) {
|
||||
return $collection;
|
||||
}
|
||||
|
||||
// We do not throw a
|
||||
// \Symfony\Component\Routing\Exception\ResourceNotFoundException here
|
||||
// because we don't want to return a 404 status code, but rather a 406.
|
||||
throw new NotAcceptableHttpException('No route found for the specified formats ' . implode(' ', $acceptable_mime_types));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function applies(Route $route) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\accept_header_routing_teste\Unit\Routing;
|
||||
|
||||
use Drupal\accept_header_routing_test\Routing\AcceptHeaderMatcher;
|
||||
use Drupal\Tests\Core\Routing\RoutingFixtures;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Confirm that the mime types partial matcher is functioning properly.
|
||||
*
|
||||
* @group Routing
|
||||
*/
|
||||
class AcceptHeaderMatcherTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* A collection of shared fixture data for tests.
|
||||
*
|
||||
* @var \Drupal\Tests\Core\Routing\RoutingFixtures
|
||||
*/
|
||||
protected $fixtures;
|
||||
|
||||
/**
|
||||
* The matcher object that is going to be tested.
|
||||
*
|
||||
* @var \Drupal\accept_header_routing_test\Routing\AcceptHeaderMatcher
|
||||
*/
|
||||
protected $matcher;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->fixtures = new RoutingFixtures();
|
||||
$this->matcher = new AcceptHeaderMatcher();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides data for the Accept header filtering test.
|
||||
*
|
||||
* @see Drupal\Tests\Core\Routing\AcceptHeaderMatcherTest::testAcceptFiltering()
|
||||
*/
|
||||
public function acceptFilterProvider() {
|
||||
return [
|
||||
// Check that JSON routes get filtered and prioritized correctly.
|
||||
['application/json, text/xml;q=0.9', 'json', 'route_c', 'route_e'],
|
||||
// Tests a JSON request with alternative JSON MIME type Accept header.
|
||||
['application/x-json, text/xml;q=0.9', 'json', 'route_c', 'route_e'],
|
||||
// Tests a standard HTML request.
|
||||
['text/html, text/xml;q=0.9', 'html', 'route_e', 'route_c'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that requests using Accept headers get filtered correctly.
|
||||
*
|
||||
* @param string $accept_header
|
||||
* The HTTP Accept header value of the request.
|
||||
* @param string $format
|
||||
* The request format.
|
||||
* @param string $included_route
|
||||
* The route name that should survive the filter and be ranked first.
|
||||
* @param string $excluded_route
|
||||
* The route name that should be filtered out during matching.
|
||||
*
|
||||
* @dataProvider acceptFilterProvider
|
||||
*/
|
||||
public function testAcceptFiltering($accept_header, $format, $included_route, $excluded_route) {
|
||||
$collection = $this->fixtures->sampleRouteCollection();
|
||||
|
||||
$request = Request::create('path/two', 'GET');
|
||||
$request->headers->set('Accept', $accept_header);
|
||||
$request->setRequestFormat($format);
|
||||
$routes = $this->matcher->filter($collection, $request);
|
||||
$this->assertEquals(count($routes), 4, 'The correct number of routes was found.');
|
||||
$this->assertNotNull($routes->get($included_route), "Route $included_route was found when matching $accept_header.");
|
||||
$this->assertNull($routes->get($excluded_route), "Route $excluded_route was not found when matching $accept_header.");
|
||||
foreach ($routes as $name => $route) {
|
||||
$this->assertEquals($name, $included_route, "Route $included_route is the first one in the collection when matching $accept_header.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirms that the AcceptHeaderMatcher throws an exception for no-route.
|
||||
*
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException
|
||||
* @expectedExceptionMessage No route found for the specified formats application/json text/xml.
|
||||
*/
|
||||
public function testNoRouteFound() {
|
||||
// Remove the sample routes that would match any method.
|
||||
$routes = $this->fixtures->sampleRouteCollection();
|
||||
$routes->remove('route_a');
|
||||
$routes->remove('route_b');
|
||||
$routes->remove('route_c');
|
||||
$routes->remove('route_d');
|
||||
|
||||
$request = Request::create('path/two', 'GET');
|
||||
$request->headers->set('Accept', 'application/json, text/xml;q=0.9');
|
||||
$request->setRequestFormat('json');
|
||||
$this->matcher->filter($routes, $request);
|
||||
$this->matcher->filter($routes, $request);
|
||||
$this->fail('No exception was thrown.');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Action test'
|
||||
type: module
|
||||
description: 'Support module for action testing.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\action_test\Plugin\Action;
|
||||
|
||||
use Drupal\Core\Access\AccessResult;
|
||||
use Drupal\Core\Action\ActionBase;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
|
||||
/**
|
||||
* Provides an operation with no type specified.
|
||||
*
|
||||
* @Action(
|
||||
* id = "action_test_no_type",
|
||||
* label = @Translation("An operation with no type specified")
|
||||
* )
|
||||
*/
|
||||
class NoType extends ActionBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute($entity = NULL) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
|
||||
$result = AccessResult::allowed();
|
||||
return $return_as_object ? $result : $result->isAllowed();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\action_test\Plugin\Action;
|
||||
|
||||
use Drupal\Core\Action\ActionBase;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
|
||||
/**
|
||||
* Provides an operation to save user entities.
|
||||
*
|
||||
* @Action(
|
||||
* id = "action_test_save_entity",
|
||||
* label = @Translation("Saves entities"),
|
||||
* type = "user"
|
||||
* )
|
||||
*/
|
||||
class SaveEntity extends ActionBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute($entity = NULL) {
|
||||
$entity->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
|
||||
/** @var \Drupal\Core\Entity\EntityInterface $object */
|
||||
return $object->access('update', $account, $return_as_object);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
name: 'AJAX form test mock module'
|
||||
type: module
|
||||
description: 'Test for AJAX form calls.'
|
||||
core: 8.x
|
||||
package: Testing
|
||||
version: VERSION
|
|
@ -0,0 +1,212 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Simpletest mock module for Ajax forms testing.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Ajax\AddCssCommand;
|
||||
use Drupal\Core\Ajax\AfterCommand;
|
||||
use Drupal\Core\Ajax\AjaxResponse;
|
||||
use Drupal\Core\Ajax\AlertCommand;
|
||||
use Drupal\Core\Ajax\AppendCommand;
|
||||
use Drupal\Core\Ajax\BeforeCommand;
|
||||
use Drupal\Core\Ajax\ChangedCommand;
|
||||
use Drupal\Core\Ajax\CssCommand;
|
||||
use Drupal\Core\Ajax\DataCommand;
|
||||
use Drupal\Core\Ajax\HtmlCommand;
|
||||
use Drupal\Core\Ajax\InsertCommand;
|
||||
use Drupal\Core\Ajax\InvokeCommand;
|
||||
use Drupal\Core\Ajax\PrependCommand;
|
||||
use Drupal\Core\Ajax\RemoveCommand;
|
||||
use Drupal\Core\Ajax\RestripeCommand;
|
||||
use Drupal\Core\Ajax\SettingsCommand;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'after'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_after_callback($form, FormStateInterface $form_state) {
|
||||
$selector = '#after_div';
|
||||
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new AfterCommand($selector, "This will be placed after"));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'alert'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_alert_callback($form, FormStateInterface $form_state) {
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new AlertCommand('Alert'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'append'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_append_callback($form, FormStateInterface $form_state) {
|
||||
$selector = '#append_div';
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new AppendCommand($selector, "Appended text"));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'before'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_before_callback($form, FormStateInterface $form_state) {
|
||||
$selector = '#before_div';
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new BeforeCommand($selector, "Before text"));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'changed'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_changed_callback($form, FormStateInterface $form_state) {
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new ChangedCommand('#changed_div'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'changed' with asterisk marking inner div.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_changed_asterisk_callback($form, FormStateInterface $form_state) {
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new ChangedCommand('#changed_div', '#changed_div_mark_this'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'css'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_css_callback($form, FormStateInterface $form_state) {
|
||||
$selector = '#css_div';
|
||||
$color = 'blue';
|
||||
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new CssCommand($selector, array('background-color' => $color)));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'data'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_data_callback($form, FormStateInterface $form_state) {
|
||||
$selector = '#data_div';
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new DataCommand($selector, 'testkey', 'testvalue'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'invoke'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_invoke_callback($form, FormStateInterface $form_state) {
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new InvokeCommand('#invoke_div', 'addClass', array('error')));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'html'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_html_callback($form, FormStateInterface $form_state) {
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new HtmlCommand('#html_div', 'replacement text'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'insert'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_insert_callback($form, FormStateInterface $form_state) {
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new InsertCommand('#insert_div', 'insert replacement text'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'prepend'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_prepend_callback($form, FormStateInterface $form_state) {
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new PrependCommand('#prepend_div', "prepended text"));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'remove'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_remove_callback($form, FormStateInterface $form_state) {
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new RemoveCommand('#remove_text'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'restripe'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_restripe_callback($form, FormStateInterface $form_state) {
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new RestripeCommand('#restripe_table'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects 'settings'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_settings_callback($form, FormStateInterface $form_state) {
|
||||
$setting['ajax_forms_test']['foo'] = 42;
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new SettingsCommand($setting));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax callback for 'add_css'.
|
||||
*/
|
||||
function ajax_forms_test_advanced_commands_add_css_callback($form, FormStateInterface $form_state) {
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new AddCssCommand('my/file.css'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects the 'drivertext' element of the validation form.
|
||||
*/
|
||||
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'))));
|
||||
return ['#markup' => '<div id="message_area">ajax_forms_test_validation_form_callback at ' . date('c') . '</div>'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax form callback: Selects the 'drivernumber' element of the validation form.
|
||||
*/
|
||||
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'))));
|
||||
return ['#markup' => '<div id="message_area_number">ajax_forms_test_validation_number_form_callback at ' . date('c') . '</div>'];
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX form callback: Selects for the ajax_forms_test_lazy_load_form() form.
|
||||
*/
|
||||
function ajax_forms_test_lazy_load_form_ajax($form, FormStateInterface $form_state) {
|
||||
$build = [
|
||||
'#markup' => 'new content',
|
||||
];
|
||||
|
||||
if ($form_state->getValue('add_files')) {
|
||||
$build['#attached']['library'][] = 'system/admin';
|
||||
$build['#attached']['library'][] = 'system/drupal.system';
|
||||
$build['#attached']['drupalSettings']['ajax_forms_test_lazy_load_form_submit'] = 'executed';
|
||||
}
|
||||
|
||||
return $build;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
ajax_forms_test.get_form:
|
||||
path: '/ajax_forms_test_get_form'
|
||||
defaults:
|
||||
_title: 'AJAX forms simple form test'
|
||||
_form: '\Drupal\ajax_forms_test\Form\AjaxFormsTestSimpleForm'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
ajax_forms_test.commands_form:
|
||||
path: '/ajax_forms_test_ajax_commands_form'
|
||||
defaults:
|
||||
_title: 'AJAX forms AJAX commands test'
|
||||
_form: '\Drupal\ajax_forms_test\Form\AjaxFormsTestCommandsForm'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
ajax_forms_test.validation_test:
|
||||
path: '/ajax_validation_test'
|
||||
defaults:
|
||||
_title: 'AJAX Validation Test'
|
||||
_form: '\Drupal\ajax_forms_test\Form\AjaxFormsTestValidationForm'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
ajax_forms_test.lazy_load_form:
|
||||
path: '/ajax_forms_test_lazy_load_form'
|
||||
defaults:
|
||||
_title: 'AJAX forms lazy load test'
|
||||
_form: '\Drupal\ajax_forms_test\Form\AjaxFormsTestLazyLoadForm'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\ajax_forms_test;
|
||||
|
||||
use Drupal\Core\Ajax\AjaxResponse;
|
||||
use Drupal\Core\Ajax\DataCommand;
|
||||
use Drupal\Core\Ajax\HtmlCommand;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Simple object for testing methods as Ajax callbacks.
|
||||
*/
|
||||
class Callbacks {
|
||||
|
||||
/**
|
||||
* Ajax callback triggered by select.
|
||||
*/
|
||||
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')));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax callback triggered by checkbox.
|
||||
*/
|
||||
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')));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax callback triggered by the checkbox in a #group.
|
||||
*/
|
||||
function checkboxGroupCallback($form, FormStateInterface $form_state) {
|
||||
return $form['checkbox_in_group_wrapper'];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,206 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\ajax_forms_test\Form;
|
||||
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Form constructor for the Ajax Command display form.
|
||||
*/
|
||||
class AjaxFormsTestCommandsForm extends FormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'ajax_forms_test_ajax_commands_form';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$form = array();
|
||||
|
||||
// Shows the 'after' command with a callback generating commands.
|
||||
$form['after_command_example'] = array(
|
||||
'#value' => $this->t("AJAX 'After': Click to put something after the div"),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'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(
|
||||
'#value' => $this->t("AJAX 'Alert': Click to alert"),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'callback' => 'ajax_forms_test_advanced_commands_alert_callback',
|
||||
),
|
||||
);
|
||||
|
||||
// Shows the 'append' command.
|
||||
$form['append_command_example'] = array(
|
||||
'#value' => $this->t("AJAX 'Append': Click to append something"),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'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(
|
||||
'#value' => $this->t("AJAX 'before': Click to put something before the div"),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'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(
|
||||
'#value' => $this->t("AJAX changed: Click to mark div changed."),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'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(
|
||||
'#value' => $this->t("AJAX changed: Click to mark div changed with asterisk."),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'callback' => 'ajax_forms_test_advanced_commands_changed_asterisk_callback',
|
||||
),
|
||||
);
|
||||
|
||||
// Shows the Ajax 'css' command.
|
||||
$form['css_command_example'] = array(
|
||||
'#value' => $this->t("Set the '#box' div to be blue."),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'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(
|
||||
'#value' => $this->t("AJAX data command: Issue command."),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'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(
|
||||
'#value' => $this->t("AJAX invoke command: Invoke addClass() method."),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'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(
|
||||
'#value' => $this->t("AJAX html: Replace the HTML in a selector."),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'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(
|
||||
'#value' => $this->t("AJAX insert: Let client insert based on #ajax['method']."),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'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(
|
||||
'#value' => $this->t("AJAX 'prepend': Click to prepend something"),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'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(
|
||||
'#value' => $this->t("AJAX 'remove': Click to remove text"),
|
||||
'#type' => 'submit',
|
||||
'#ajax' => array(
|
||||
'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(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t("AJAX 'restripe' command"),
|
||||
'#ajax' => array(
|
||||
'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(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t("AJAX 'settings' command"),
|
||||
'#ajax' => array(
|
||||
'callback' => 'ajax_forms_test_advanced_commands_settings_callback',
|
||||
),
|
||||
);
|
||||
|
||||
// Shows the Ajax 'add_css' command.
|
||||
$form['add_css_command_example'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t("AJAX 'add_css' command"),
|
||||
'#ajax' => array(
|
||||
'callback' => 'ajax_forms_test_advanced_commands_add_css_callback',
|
||||
),
|
||||
);
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Submit'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\ajax_forms_test\Form;
|
||||
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Form builder: Builds a form that triggers a simple AJAX callback.
|
||||
*/
|
||||
class AjaxFormsTestLazyLoadForm extends FormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'ajax_forms_test_lazy_load_form';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
// We attach a JavaScript setting, so that one of the generated AJAX
|
||||
// commands will be a settings command. We can then check the settings
|
||||
// command to ensure that the 'currentPath' setting is not part
|
||||
// of the Ajax response.
|
||||
$form['#attached']['drupalSettings']['test'] = 'currentPathUpdate';
|
||||
$form['add_files'] = array(
|
||||
'#title' => $this->t('Add files'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => FALSE,
|
||||
);
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Submit'),
|
||||
'#ajax' => array(
|
||||
'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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$form_state->setRebuild();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\ajax_forms_test\Form;
|
||||
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\ajax_forms_test\Callbacks;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Form builder: Builds a form that triggers a simple AJAX callback.
|
||||
*/
|
||||
class AjaxFormsTestSimpleForm extends FormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'ajax_forms_test_simple_form';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$object = new Callbacks();
|
||||
|
||||
$form = array();
|
||||
$form['select'] = array(
|
||||
'#title' => $this->t('Color'),
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'red' => 'red',
|
||||
'green' => 'green',
|
||||
'blue' => 'blue'),
|
||||
'#ajax' => array(
|
||||
'callback' => array($object, 'selectCallback'),
|
||||
),
|
||||
'#suffix' => '<div id="ajax_selected_color">No color yet selected</div>',
|
||||
);
|
||||
|
||||
$form['checkbox'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Test checkbox'),
|
||||
'#ajax' => array(
|
||||
'callback' => array($object, 'checkboxCallback'),
|
||||
),
|
||||
'#suffix' => '<div id="ajax_checkbox_value">No action yet</div>',
|
||||
);
|
||||
$form['submit'] = array(
|
||||
'#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(
|
||||
'null' => NULL,
|
||||
'empty' => '',
|
||||
'nonexistent' => 'some_function_that_does_not_exist',
|
||||
);
|
||||
foreach ($invalid_callbacks as $key => $value) {
|
||||
$form['select_' . $key . '_callback'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Test %key callbacks', array('%key' => $key)),
|
||||
'#options' => array('red' => 'red'),
|
||||
'#ajax' => array('callback' => $value),
|
||||
);
|
||||
}
|
||||
|
||||
$form['test_group'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Test group'),
|
||||
'#open' => TRUE,
|
||||
];
|
||||
|
||||
// Test ajax element in a #group.
|
||||
$form['checkbox_in_group_wrapper'] = [
|
||||
'#type' => 'container',
|
||||
'#attributes' => ['id' => 'checkbox-wrapper'],
|
||||
'#group' => 'test_group',
|
||||
'checkbox_in_group' => [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('AJAX checkbox in a group'),
|
||||
'#ajax' => [
|
||||
'callback' => [$object, 'checkboxGroupCallback'],
|
||||
'wrapper' => 'checkbox-wrapper',
|
||||
],
|
||||
],
|
||||
'nested_group' => [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Nested group'),
|
||||
'#open' => TRUE,
|
||||
],
|
||||
'checkbox_in_nested' => [
|
||||
'#type' => 'checkbox',
|
||||
'#group' => 'nested_group',
|
||||
'#title' => $this->t('AJAX checkbox in a nested group'),
|
||||
'#ajax' => [
|
||||
'callback' => [$object, 'checkboxGroupCallback'],
|
||||
'wrapper' => 'checkbox-wrapper',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$form['another_checkbox_in_nested'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#group' => 'nested_group',
|
||||
'#title' => $this->t('Another AJAX checkbox in a nested group'),
|
||||
];
|
||||
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\ajax_forms_test\Form;
|
||||
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Form builder: Builds a form that triggers a simple AJAX callback.
|
||||
*/
|
||||
class AjaxFormsTestValidationForm extends FormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'ajax_forms_test_validation_form';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$form['drivertext'] = array(
|
||||
'#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(
|
||||
'callback' => 'ajax_forms_test_validation_form_callback',
|
||||
'wrapper' => 'message_area',
|
||||
'method' => 'replace',
|
||||
),
|
||||
'#suffix' => '<div id="message_area"></div>',
|
||||
);
|
||||
|
||||
$form['drivernumber'] = array(
|
||||
'#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(
|
||||
'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(
|
||||
'#title' => $this->t("Spare Required Field"),
|
||||
'#type' => 'textfield',
|
||||
'#required' => TRUE,
|
||||
);
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Submit'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
drupal_set_message($this->t("Validation form submitted"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\ajax_forms_test\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Form\FormBuilderInterface;
|
||||
use Drupal\Core\Form\FormInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Provides an AJAX form block.
|
||||
*
|
||||
* @Block(
|
||||
* id = "ajax_forms_test_block",
|
||||
* admin_label = @Translation("AJAX test form"),
|
||||
* category = @Translation("Forms")
|
||||
* )
|
||||
*/
|
||||
class AjaxFormBlock extends BlockBase implements FormInterface, ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The form builder.
|
||||
*
|
||||
* @var \Drupal\Core\Form\FormBuilderInterface
|
||||
*/
|
||||
protected $formBuilder;
|
||||
|
||||
/**
|
||||
* Constructs a new AjaxFormBlock.
|
||||
*
|
||||
* @param array $configuration
|
||||
* A configuration array containing information about the plugin instance.
|
||||
* @param string $plugin_id
|
||||
* The plugin ID for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
|
||||
* The form builder.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, FormBuilderInterface $form_builder) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->formBuilder = $form_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('form_builder')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build() {
|
||||
return $this->formBuilder->getForm($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'ajax_forms_test_block';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$form['test1'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Test 1'),
|
||||
'#required' => TRUE,
|
||||
'#options' => [
|
||||
'option1' => $this->t('Option 1'),
|
||||
'option2' => $this->t('Option 2'),
|
||||
],
|
||||
'#ajax' => [
|
||||
'callback' => '::updateOptions',
|
||||
'wrapper' => 'edit-test1-wrapper',
|
||||
],
|
||||
'#prefix' => '<div id="edit-test1-wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
];
|
||||
$form['actions'] = [
|
||||
'#type' => 'actions',
|
||||
];
|
||||
$form['actions']['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Submit'),
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the options of a select list.
|
||||
*
|
||||
* @param array $form
|
||||
* An associative array containing the structure of the form.
|
||||
* @param \Drupal\Core\Form\FormStateInterface $form_state
|
||||
* The current state of the form.
|
||||
*
|
||||
* @return array
|
||||
* The updated form element.
|
||||
*/
|
||||
public function updateOptions(array $form, FormStateInterface $form_state) {
|
||||
$form['test1']['#options']['option1'] = $this->t('Option 1!!!');
|
||||
$form['test1']['#options'] += [
|
||||
'option3' => $this->t('Option 3'),
|
||||
'option4' => $this->t('Option 4'),
|
||||
];
|
||||
return $form['test1'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
drupal_set_message('Submission successful.');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
name: 'AJAX Test'
|
||||
type: module
|
||||
description: 'Support module for AJAX framework tests.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- contact
|
|
@ -0,0 +1,23 @@
|
|||
order:
|
||||
drupalSettings:
|
||||
ajax: test
|
||||
dependencies:
|
||||
- ajax_test/order-css-command
|
||||
- ajax_test/order-footer-js-command
|
||||
- ajax_test/order-header-js-command
|
||||
|
||||
order-css-command:
|
||||
css:
|
||||
theme:
|
||||
# Two CSS files (order should remain the same).
|
||||
a.css: {}
|
||||
b.css: {}
|
||||
|
||||
order-footer-js-command:
|
||||
js:
|
||||
footer.js: {}
|
||||
|
||||
order-header-js-command:
|
||||
header: true
|
||||
js:
|
||||
header.js: {}
|
|
@ -0,0 +1,57 @@
|
|||
ajax_test.dialog_contents:
|
||||
path: '/ajax-test/dialog-contents'
|
||||
defaults:
|
||||
_title: 'AJAX Dialog contents routing'
|
||||
_controller: '\Drupal\ajax_test\Controller\AjaxTestController::dialogContents'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
ajax_test.dialog_form:
|
||||
path: '/ajax-test/dialog-form'
|
||||
defaults:
|
||||
_title: 'Ajax Form contents'
|
||||
_form: '\Drupal\ajax_test\Form\AjaxTestForm'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
ajax_test.dialog:
|
||||
path: '/ajax-test/dialog'
|
||||
defaults:
|
||||
_controller: '\Drupal\ajax_test\Controller\AjaxTestController::dialog'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
ajax_test.dialog_close:
|
||||
path: '/ajax-test/dialog-close'
|
||||
defaults:
|
||||
_controller: '\Drupal\ajax_test\Controller\AjaxTestController::dialogClose'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
ajax_test.render:
|
||||
path: '/ajax-test/render'
|
||||
defaults:
|
||||
_controller: '\Drupal\ajax_test\Controller\AjaxTestController::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'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
ajax_test.render_error:
|
||||
path: '/ajax-test/render-error'
|
||||
defaults:
|
||||
_controller: '\Drupal\ajax_test\Controller\AjaxTestController::renderError'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
|
@ -0,0 +1,225 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\ajax_test\Controller;
|
||||
|
||||
use Drupal\Core\Ajax\AjaxResponse;
|
||||
use Drupal\Core\Ajax\AlertCommand;
|
||||
use Drupal\Core\Ajax\CloseDialogCommand;
|
||||
use Drupal\Core\Ajax\HtmlCommand;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Provides content for dialog tests.
|
||||
*/
|
||||
class AjaxTestController {
|
||||
|
||||
/**
|
||||
* Example content for dialog testing.
|
||||
*
|
||||
* @return array
|
||||
* Renderable array of AJAX dialog contents.
|
||||
*/
|
||||
public static function dialogContents() {
|
||||
// This is a regular render array; the keys do not have special meaning.
|
||||
$content = array(
|
||||
'#title' => '<em>AJAX Dialog & contents</em>',
|
||||
'content' => array(
|
||||
'#markup' => 'Example message',
|
||||
),
|
||||
'cancel' => array(
|
||||
'#type' => 'link',
|
||||
'#title' => 'Cancel',
|
||||
'#url' => Url::fromRoute('<front>'),
|
||||
'#attributes' => array(
|
||||
// This is a special class to which JavaScript assigns dialog closing
|
||||
// behavior.
|
||||
'class' => array('dialog-cancel'),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a render array that will be rendered by AjaxRenderer.
|
||||
*
|
||||
* Verifies that the response incorporates JavaScript settings generated
|
||||
* during the page request by adding a dummy setting.
|
||||
*/
|
||||
public function render() {
|
||||
return [
|
||||
'#attached' => [
|
||||
'library' => [
|
||||
'core/drupalSettings',
|
||||
],
|
||||
'drupalSettings' => [
|
||||
'ajax' => 'test',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the used theme.
|
||||
*/
|
||||
public function theme() {
|
||||
return [
|
||||
'#markup' => 'Current theme: ' . \Drupal::theme()->getActiveTheme()->getName(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an AjaxResponse; settings command set last.
|
||||
*
|
||||
* Helps verifying AjaxResponse reorders commands to ensure correct execution.
|
||||
*/
|
||||
public function order() {
|
||||
$response = new AjaxResponse();
|
||||
// HTML insertion command.
|
||||
$response->addCommand(new HtmlCommand('body', 'Hello, world!'));
|
||||
$build['#attached']['library'][] = 'ajax_test/order';
|
||||
$response->setAttachments($build['#attached']);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an AjaxResponse with alert command.
|
||||
*
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* The current request object.
|
||||
*
|
||||
* @return \Drupal\Core\Ajax\AjaxResponse
|
||||
* The JSON response object.
|
||||
*/
|
||||
public function renderError(Request $request) {
|
||||
$message = '';
|
||||
$query = $request->query;
|
||||
if ($query->has('message')) {
|
||||
$message = $query->get('message');
|
||||
}
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new AlertCommand($message));
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a render array of form elements and links for dialog.
|
||||
*/
|
||||
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>');
|
||||
|
||||
// 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(
|
||||
'#type' => 'link',
|
||||
'#title' => 'Link 1 (modal)',
|
||||
'#url' => Url::fromRoute('ajax_test.dialog_contents'),
|
||||
'#attributes' => array(
|
||||
'class' => array('use-ajax'),
|
||||
'data-dialog-type' => 'modal',
|
||||
),
|
||||
);
|
||||
|
||||
// Dialog behavior applied to links rendered by links.html.twig.
|
||||
$build['links'] = array(
|
||||
'#theme' => 'links',
|
||||
'#links' => array(
|
||||
'link2' => array(
|
||||
'title' => 'Link 2 (modal)',
|
||||
'url' => Url::fromRoute('ajax_test.dialog_contents'),
|
||||
'attributes' => array(
|
||||
'class' => array('use-ajax'),
|
||||
'data-dialog-type' => 'modal',
|
||||
'data-dialog-options' => json_encode(array(
|
||||
'width' => 400,
|
||||
))
|
||||
),
|
||||
),
|
||||
'link3' => array(
|
||||
'title' => 'Link 3 (non-modal)',
|
||||
'url' => Url::fromRoute('ajax_test.dialog_contents'),
|
||||
'attributes' => array(
|
||||
'class' => array('use-ajax'),
|
||||
'data-dialog-type' => 'dialog',
|
||||
'data-dialog-options' => json_encode(array(
|
||||
'target' => 'ajax-test-dialog-wrapper-1',
|
||||
'width' => 800,
|
||||
))
|
||||
),
|
||||
),
|
||||
'link4' => array(
|
||||
'title' => 'Link 4 (close non-modal if open)',
|
||||
'url' => Url::fromRoute('ajax_test.dialog_close'),
|
||||
'attributes' => array(
|
||||
'class' => array('use-ajax'),
|
||||
'data-dialog-type' => 'modal',
|
||||
),
|
||||
),
|
||||
'link5' => array(
|
||||
'title' => 'Link 5 (form)',
|
||||
'url' => Url::fromRoute('ajax_test.dialog_form'),
|
||||
'attributes' => array(
|
||||
'class' => array('use-ajax'),
|
||||
'data-dialog-type' => 'modal',
|
||||
),
|
||||
),
|
||||
'link6' => array(
|
||||
'title' => 'Link 6 (entity form)',
|
||||
'url' => Url::fromRoute('contact.form_add'),
|
||||
'attributes' => array(
|
||||
'class' => array('use-ajax'),
|
||||
'data-dialog-type' => 'modal',
|
||||
'data-dialog-options' => json_encode(array(
|
||||
'width' => 800,
|
||||
'height' => 500,
|
||||
))
|
||||
),
|
||||
),
|
||||
'link7' => array(
|
||||
'title' => 'Link 7 (non-modal, no target)',
|
||||
'url' => Url::fromRoute('ajax_test.dialog_contents'),
|
||||
'attributes' => array(
|
||||
'class' => array('use-ajax'),
|
||||
'data-dialog-type' => 'dialog',
|
||||
'data-dialog-options' => json_encode(array(
|
||||
'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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an AjaxResponse with command to close dialog.
|
||||
*
|
||||
* @return \Drupal\Core\Ajax\AjaxResponse
|
||||
* The JSON response object.
|
||||
*/
|
||||
public function dialogClose() {
|
||||
$response = new AjaxResponse();
|
||||
$response->addCommand(new CloseDialogCommand('#ajax-test-dialog-wrapper-1'));
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\ajax_test\Form;
|
||||
|
||||
use Drupal\ajax_test\Controller\AjaxTestController;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Ajax\AjaxResponse;
|
||||
use Drupal\Core\Ajax\OpenModalDialogCommand;
|
||||
use Drupal\Core\Ajax\OpenDialogCommand;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Dummy form for testing DialogRenderer with _form routes.
|
||||
*/
|
||||
class AjaxTestDialogForm extends FormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'ajax_test_dialog_form';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
// 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(
|
||||
'#type' => 'hidden'
|
||||
);
|
||||
$form['button1'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'button1',
|
||||
'#value' => 'Button 1 (modal)',
|
||||
'#ajax' => array(
|
||||
'callback' => '::modal',
|
||||
),
|
||||
);
|
||||
$form['button2'] = array(
|
||||
'#type' => 'submit',
|
||||
'#name' => 'button2',
|
||||
'#value' => 'Button 2 (non-modal)',
|
||||
'#ajax' => array(
|
||||
'callback' => '::nonModal',
|
||||
),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$form_state->setRedirect('ajax_test.dialog_contents');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AJAX callback handler for AjaxTestDialogForm.
|
||||
*/
|
||||
public function modal(&$form, FormStateInterface $form_state) {
|
||||
return $this->dialog(TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX callback handler for AjaxTestDialogForm.
|
||||
*/
|
||||
public function nonModal(&$form, FormStateInterface $form_state) {
|
||||
return $this->dialog(FALSE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Util to render dialog in ajax callback.
|
||||
*
|
||||
* @param bool $is_modal
|
||||
* (optional) TRUE if modal, FALSE if plain dialog. Defaults to FALSE.
|
||||
*
|
||||
* @return \Drupal\Core\Ajax\AjaxResponse
|
||||
* An ajax response object.
|
||||
*/
|
||||
protected function dialog($is_modal = FALSE) {
|
||||
$content = AjaxTestController::dialogContents();
|
||||
$response = new AjaxResponse();
|
||||
$title = $this->t('AJAX Dialog & contents');
|
||||
|
||||
// Attach the library necessary for using the Open(Modal)DialogCommand and
|
||||
// set the attachments for this Ajax response.
|
||||
$content['#attached']['library'][] = 'core/drupal.dialog.ajax';
|
||||
|
||||
if ($is_modal) {
|
||||
$response->addCommand(new OpenModalDialogCommand($title, $content));
|
||||
}
|
||||
else {
|
||||
$selector = '#ajax-test-dialog-wrapper-1';
|
||||
$response->addCommand(new OpenDialogCommand($selector, $title, $content));
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\ajax_test\Form;
|
||||
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Dummy form for testing DialogRenderer with _form routes.
|
||||
*/
|
||||
class AjaxTestForm extends FormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'ajax_test_form';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
|
||||
$form['#action'] = \Drupal::url('ajax_test.dialog');
|
||||
|
||||
$form['description'] = array(
|
||||
'#markup' => '<p>' . $this->t("Ajax Form contents description.") . '</p>',
|
||||
);
|
||||
|
||||
$form['actions'] = array(
|
||||
'#type' => 'actions',
|
||||
);
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Do it'),
|
||||
);
|
||||
$form['actions']['preview'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Preview'),
|
||||
// No regular submit-handler. This form only works via JavaScript.
|
||||
'#submit' => array(),
|
||||
'#ajax' => array(
|
||||
// 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
|
||||
// implementing this method, because we can never let it be called from
|
||||
// JS; we'd have to manually call it from PHP, at which point we would
|
||||
// not actually be testing it.
|
||||
// Therefore we consciously choose to not implement this method, because
|
||||
// we cannot meaningfully test it anyway.
|
||||
'callback' => '::preview',
|
||||
'event' => 'click',
|
||||
),
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {}
|
||||
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Batch callbacks for the Batch API tests.
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
/**
|
||||
* Implements callback_batch_operation().
|
||||
*
|
||||
* Performs a simple batch operation.
|
||||
*/
|
||||
function _batch_test_callback_1($id, $sleep, &$context) {
|
||||
// No-op, but ensure the batch take a couple iterations.
|
||||
// Batch needs time to run for the test, so sleep a bit.
|
||||
usleep($sleep);
|
||||
// Track execution, and store some result for post-processing in the
|
||||
// 'finished' callback.
|
||||
batch_test_stack("op 1 id $id");
|
||||
$context['results'][1][] = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_operation().
|
||||
*
|
||||
* Performs a multistep batch operation.
|
||||
*/
|
||||
function _batch_test_callback_2($start, $total, $sleep, &$context) {
|
||||
// Initialize context with progress information.
|
||||
if (!isset($context['sandbox']['current'])) {
|
||||
$context['sandbox']['current'] = $start;
|
||||
$context['sandbox']['count'] = 0;
|
||||
}
|
||||
|
||||
// Process by groups of 5 (arbitrary value).
|
||||
$limit = 5;
|
||||
for ($i = 0; $i < $limit && $context['sandbox']['count'] < $total; $i++) {
|
||||
// No-op, but ensure the batch take a couple iterations.
|
||||
// Batch needs time to run for the test, so sleep a bit.
|
||||
usleep($sleep);
|
||||
// Track execution, and store some result for post-processing in the
|
||||
// 'finished' callback.
|
||||
$id = $context['sandbox']['current'] + $i;
|
||||
batch_test_stack("op 2 id $id");
|
||||
$context['results'][2][] = $id;
|
||||
|
||||
// Update progress information.
|
||||
$context['sandbox']['count']++;
|
||||
}
|
||||
$context['sandbox']['current'] += $i;
|
||||
|
||||
// Inform batch engine about progress.
|
||||
if ($context['sandbox']['count'] != $total) {
|
||||
$context['finished'] = $context['sandbox']['count'] / $total;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_operation().
|
||||
*/
|
||||
function _batch_test_callback_5($id, $sleep, &$context) {
|
||||
// No-op, but ensure the batch take a couple iterations.
|
||||
// Batch needs time to run for the test, so sleep a bit.
|
||||
usleep($sleep);
|
||||
// Track execution, and store some result for post-processing in the
|
||||
// 'finished' callback.
|
||||
batch_test_stack("op 5 id $id");
|
||||
$context['results'][5][] = $id;
|
||||
// This test is to test finished > 1
|
||||
$context['finished'] = 3.14;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_operation().
|
||||
*
|
||||
* Performs a batch operation setting up its own batch.
|
||||
*/
|
||||
function _batch_test_nested_batch_callback() {
|
||||
batch_test_stack('setting up batch 2');
|
||||
batch_set(_batch_test_batch_2());
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a common 'finished' callback for batches 1 to 4.
|
||||
*/
|
||||
function _batch_test_finished_helper($batch_id, $success, $results, $operations) {
|
||||
if ($results) {
|
||||
foreach ($results as $op => $op_results) {
|
||||
$messages[] = 'op ' . Html::escape($op) . ': processed ' . count($op_results) . ' elements';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$messages[] = 'none';
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
// Use item list template to render the messages.
|
||||
$error_message = [
|
||||
'#type' => 'inline_template',
|
||||
'#template' => 'results for batch {{ batch_id }}{{ errors }}',
|
||||
'#context' => [
|
||||
'batch_id' => $batch_id,
|
||||
'errors' => [
|
||||
'#theme' => 'item_list',
|
||||
'#items' => $messages,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
drupal_set_message(\Drupal::service('renderer')->renderPlain($error_message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_finished().
|
||||
*
|
||||
* Triggers 'finished' callback for batch 0.
|
||||
*/
|
||||
function _batch_test_finished_0($success, $results, $operations) {
|
||||
_batch_test_finished_helper(0, $success, $results, $operations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_finished().
|
||||
*
|
||||
* Triggers 'finished' callback for batch 1.
|
||||
*/
|
||||
function _batch_test_finished_1($success, $results, $operations) {
|
||||
_batch_test_finished_helper(1, $success, $results, $operations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_finished().
|
||||
*
|
||||
* Triggers 'finished' callback for batch 1.
|
||||
*/
|
||||
function _batch_test_finished_1_finished($success, $results, $operations) {
|
||||
_batch_test_finished_helper(1, $success, $results, $operations);
|
||||
return new RedirectResponse(Url::fromRoute('test_page_test.test_page', [], ['absolute' => TRUE])->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_finished().
|
||||
*
|
||||
* Triggers 'finished' callback for batch 2.
|
||||
*/
|
||||
function _batch_test_finished_2($success, $results, $operations) {
|
||||
_batch_test_finished_helper(2, $success, $results, $operations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_finished().
|
||||
*
|
||||
* Triggers 'finished' callback for batch 3.
|
||||
*/
|
||||
function _batch_test_finished_3($success, $results, $operations) {
|
||||
_batch_test_finished_helper(3, $success, $results, $operations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_finished().
|
||||
*
|
||||
* Triggers 'finished' callback for batch 4.
|
||||
*/
|
||||
function _batch_test_finished_4($success, $results, $operations) {
|
||||
_batch_test_finished_helper(4, $success, $results, $operations);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_finished().
|
||||
*
|
||||
* Triggers 'finished' callback for batch 5.
|
||||
*/
|
||||
function _batch_test_finished_5($success, $results, $operations) {
|
||||
_batch_test_finished_helper(5, $success, $results, $operations);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Batch API test'
|
||||
type: module
|
||||
description: 'Support module for Batch API tests.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
|
@ -0,0 +1,46 @@
|
|||
batch_test.test_form:
|
||||
title: Simple
|
||||
route_name: batch_test.test_form
|
||||
base_route: batch_test.test_form
|
||||
|
||||
batch_test.multistep:
|
||||
title: Multistep
|
||||
route_name: batch_test.multistep
|
||||
base_route: batch_test.test_form
|
||||
weight: 1
|
||||
|
||||
batch_test.chained:
|
||||
title: Chained
|
||||
route_name: batch_test.chained
|
||||
base_route: batch_test.test_form
|
||||
weight: 2
|
||||
|
||||
batch_test.programmatic:
|
||||
title: Chained
|
||||
route_name: batch_test.programmatic
|
||||
base_route: batch_test.test_form
|
||||
weight: 3
|
||||
|
||||
batch_test.no_form:
|
||||
title: 'No form'
|
||||
route_name: batch_test.no_form
|
||||
base_route: batch_test.test_form
|
||||
weight: 4
|
||||
|
||||
batch_test.large_percentage:
|
||||
title: 'Large percentage'
|
||||
route_name: batch_test.large_percentage
|
||||
base_route: batch_test.test_form
|
||||
weight: 5
|
||||
|
||||
batch_test.nested_programmatic:
|
||||
title: 'Nested programmatic'
|
||||
route_name: batch_test.nested_programmatic
|
||||
base_route: batch_test.test_form
|
||||
weight: 6
|
||||
|
||||
batch_test.redirect:
|
||||
title: 'Redirect'
|
||||
route_name: batch_test.redirect
|
||||
base_route: batch_test.test_form
|
||||
weight: 7
|
|
@ -0,0 +1,199 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Helper module for the Batch API tests.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Form\FormState;
|
||||
|
||||
/**
|
||||
* Batch operation: Submits form_test_mock_form().
|
||||
*/
|
||||
function _batch_test_nested_drupal_form_submit_callback($value) {
|
||||
$form_state = (new FormState())
|
||||
->setValue('test_value', $value);
|
||||
\Drupal::formBuilder()->submitForm('Drupal\batch_test\Form\BatchTestMockForm', $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch 0: Does nothing.
|
||||
*/
|
||||
function _batch_test_batch_0() {
|
||||
$batch = array(
|
||||
'operations' => array(),
|
||||
'finished' => '_batch_test_finished_0',
|
||||
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
|
||||
);
|
||||
return $batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch 1: Repeats a simple operation.
|
||||
*
|
||||
* Operations: op 1 from 1 to 10.
|
||||
*/
|
||||
function _batch_test_batch_1() {
|
||||
// Ensure the batch takes at least two iterations.
|
||||
$total = 10;
|
||||
$sleep = (1000000 / $total) * 2;
|
||||
|
||||
$operations = array();
|
||||
for ($i = 1; $i <= $total; $i++) {
|
||||
$operations[] = array('_batch_test_callback_1', array($i, $sleep));
|
||||
}
|
||||
$batch = array(
|
||||
'operations' => $operations,
|
||||
'finished' => '_batch_test_finished_1',
|
||||
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
|
||||
);
|
||||
return $batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch 2: Performs a single multistep operation.
|
||||
*
|
||||
* Operations: op 2 from 1 to 10.
|
||||
*/
|
||||
function _batch_test_batch_2() {
|
||||
// Ensure the batch takes at least two iterations.
|
||||
$total = 10;
|
||||
$sleep = (1000000 / $total) * 2;
|
||||
|
||||
$operations = array(
|
||||
array('_batch_test_callback_2', array(1, $total, $sleep)),
|
||||
);
|
||||
$batch = array(
|
||||
'operations' => $operations,
|
||||
'finished' => '_batch_test_finished_2',
|
||||
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
|
||||
);
|
||||
return $batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch 3: Performs both single and multistep operations.
|
||||
*
|
||||
* Operations:
|
||||
* - op 1 from 1 to 5,
|
||||
* - op 2 from 1 to 5,
|
||||
* - op 1 from 6 to 10,
|
||||
* - op 2 from 6 to 10.
|
||||
*/
|
||||
function _batch_test_batch_3() {
|
||||
// Ensure the batch takes at least two iterations.
|
||||
$total = 10;
|
||||
$sleep = (1000000 / $total) * 2;
|
||||
|
||||
$operations = array();
|
||||
for ($i = 1; $i <= round($total / 2); $i++) {
|
||||
$operations[] = array('_batch_test_callback_1', array($i, $sleep));
|
||||
}
|
||||
$operations[] = array('_batch_test_callback_2', array(1, $total / 2, $sleep));
|
||||
for ($i = round($total / 2) + 1; $i <= $total; $i++) {
|
||||
$operations[] = array('_batch_test_callback_1', array($i, $sleep));
|
||||
}
|
||||
$operations[] = array('_batch_test_callback_2', array(6, $total / 2, $sleep));
|
||||
$batch = array(
|
||||
'operations' => $operations,
|
||||
'finished' => '_batch_test_finished_3',
|
||||
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
|
||||
);
|
||||
return $batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch 4: Performs a batch within a batch.
|
||||
*
|
||||
* Operations:
|
||||
* - op 1 from 1 to 5,
|
||||
* - set batch 2 (op 2 from 1 to 10, should run at the end)
|
||||
* - op 1 from 6 to 10,
|
||||
*/
|
||||
function _batch_test_batch_4() {
|
||||
// Ensure the batch takes at least two iterations.
|
||||
$total = 10;
|
||||
$sleep = (1000000 / $total) * 2;
|
||||
|
||||
$operations = array();
|
||||
for ($i = 1; $i <= round($total / 2); $i++) {
|
||||
$operations[] = array('_batch_test_callback_1', array($i, $sleep));
|
||||
}
|
||||
$operations[] = array('_batch_test_nested_batch_callback', array());
|
||||
for ($i = round($total / 2) + 1; $i <= $total; $i++) {
|
||||
$operations[] = array('_batch_test_callback_1', array($i, $sleep));
|
||||
}
|
||||
$batch = array(
|
||||
'operations' => $operations,
|
||||
'finished' => '_batch_test_finished_4',
|
||||
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
|
||||
);
|
||||
return $batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch 5: Repeats a simple operation.
|
||||
*
|
||||
* Operations: op 1 from 1 to 10.
|
||||
*/
|
||||
function _batch_test_batch_5() {
|
||||
// Ensure the batch takes at least two iterations.
|
||||
$total = 10;
|
||||
$sleep = (1000000 / $total) * 2;
|
||||
|
||||
$operations = array();
|
||||
for ($i = 1; $i <= $total; $i++) {
|
||||
$operations[] = array('_batch_test_callback_5', array($i, $sleep));
|
||||
}
|
||||
$batch = array(
|
||||
'operations' => $operations,
|
||||
'finished' => '_batch_test_finished_5',
|
||||
'file' => drupal_get_path('module', 'batch_test') . '/batch_test.callbacks.inc',
|
||||
);
|
||||
return $batch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_operation().
|
||||
*
|
||||
* Tests the progress page theme.
|
||||
*/
|
||||
function _batch_test_theme_callback() {
|
||||
// Because drupalGet() steps through the full progressive batch before
|
||||
// returning control to the test function, we cannot test that the correct
|
||||
// theme is being used on the batch processing page by viewing that page
|
||||
// directly. Instead, we save the theme being used in a variable here, so
|
||||
// that it can be loaded and inspected in the thread running the test.
|
||||
$theme = \Drupal::theme()->getActiveTheme()->getName();
|
||||
batch_test_stack($theme);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the title on the progress page by performing a batch callback.
|
||||
*/
|
||||
function _batch_test_title_callback() {
|
||||
// Because drupalGet() steps through the full progressive batch before
|
||||
// returning control to the test function, we cannot test that the correct
|
||||
// title is being used on the batch processing page by viewing that page
|
||||
// directly. Instead, we save the title being used in a variable here, so
|
||||
// that it can be loaded and inspected in the thread running the test.
|
||||
$request = \Drupal::request();
|
||||
$route_match = \Drupal::routeMatch();
|
||||
$title = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());
|
||||
batch_test_stack($title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function: Stores or retrieves traced execution data.
|
||||
*/
|
||||
function batch_test_stack($data = NULL, $reset = FALSE) {
|
||||
if ($reset) {
|
||||
\Drupal::state()->delete('batch_test.stack');
|
||||
}
|
||||
if (!isset($data)) {
|
||||
return \Drupal::state()->get('batch_test.stack');
|
||||
}
|
||||
$stack = \Drupal::state()->get('batch_test.stack');
|
||||
$stack[] = $data;
|
||||
\Drupal::state()->set('batch_test.stack', $stack);
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
batch_test.redirect:
|
||||
path: '/batch-test/redirect'
|
||||
defaults:
|
||||
_controller: '\Drupal\batch_test\Controller\BatchTestController::testRedirect'
|
||||
_title: 'Redirect'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
batch_test.large_percentage:
|
||||
path: '/batch-test/large-percentage'
|
||||
defaults:
|
||||
_controller: '\Drupal\batch_test\Controller\BatchTestController::testLargePercentage'
|
||||
_title: 'Simple page with batch over 100% complete'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
batch_test.nested_programmatic:
|
||||
path: '/batch-test/nested-programmatic/{value}'
|
||||
defaults:
|
||||
_controller: '\Drupal\batch_test\Controller\BatchTestController::testNestedDrupalFormSubmit'
|
||||
_title: 'Nested programmatic'
|
||||
value: '1'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
batch_test.no_form:
|
||||
path: '/batch-test/no-form'
|
||||
defaults:
|
||||
_controller: '\Drupal\batch_test\Controller\BatchTestController::testNoForm'
|
||||
_title: 'Simple page'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
batch_test.finish_redirect:
|
||||
path: '/batch-test/finish-redirect'
|
||||
defaults:
|
||||
_controller: '\Drupal\batch_test\Controller\BatchTestController::testFinishRedirect'
|
||||
_title: 'Simple page with finish redirect call'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
batch_test.test_form:
|
||||
path: '/batch-test'
|
||||
defaults:
|
||||
_form: '\Drupal\batch_test\Form\BatchTestSimpleForm'
|
||||
_title: 'Batch test'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
batch_test.multistep:
|
||||
path: '/batch-test/multistep'
|
||||
defaults:
|
||||
_form: '\Drupal\batch_test\Form\BatchTestMultiStepForm'
|
||||
_title: 'Multistep'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
batch_test.chained:
|
||||
path: '/batch-test/chained'
|
||||
defaults:
|
||||
_form: '\Drupal\batch_test\Form\BatchTestChainedForm'
|
||||
_title: 'Chained'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
batch_test.programmatic:
|
||||
path: '/batch-test/programmatic/{value}'
|
||||
defaults:
|
||||
_controller: '\Drupal\batch_test\Controller\BatchTestController::testProgrammatic'
|
||||
_title: 'Programmatic'
|
||||
value: '1'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
batch_test.test_theme:
|
||||
path: '/admin/batch-test/test-theme'
|
||||
defaults:
|
||||
_controller: '\Drupal\batch_test\Controller\BatchTestController::testThemeBatch'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
batch_test.test_title:
|
||||
path: '/batch-test/test-title'
|
||||
defaults:
|
||||
_controller: '\Drupal\batch_test\Controller\BatchTestController::testTitleBatch'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\batch_test\Controller;
|
||||
|
||||
use Drupal\Core\Form\FormState;
|
||||
|
||||
/**
|
||||
* Controller routines for batch tests.
|
||||
*/
|
||||
class BatchTestController {
|
||||
|
||||
/**
|
||||
* Redirects successfully.
|
||||
*
|
||||
* @return array
|
||||
* Render array containing success message.
|
||||
*/
|
||||
public function testRedirect() {
|
||||
return array(
|
||||
'success' => array(
|
||||
'#markup' => 'Redirection successful.',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires a batch process without a form submission.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|null
|
||||
* A redirect response if the batch is progressive. No return value otherwise.
|
||||
*/
|
||||
public function testLargePercentage() {
|
||||
batch_test_stack(NULL, TRUE);
|
||||
|
||||
batch_set(_batch_test_batch_5());
|
||||
return batch_process('batch-test/redirect');
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits a form within a batch programmatically.
|
||||
*
|
||||
* @param int $value
|
||||
* Some value passed to a custom batch callback.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|null
|
||||
* A redirect response if the batch is progressive. No return value otherwise.
|
||||
*/
|
||||
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_set($batch);
|
||||
return batch_process('batch-test/redirect');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires a batch process without a form submission.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|null
|
||||
* A redirect response if the batch is progressive. No return value otherwise.
|
||||
*/
|
||||
public function testNoForm() {
|
||||
batch_test_stack(NULL, TRUE);
|
||||
|
||||
batch_set(_batch_test_batch_1());
|
||||
return batch_process('batch-test/redirect');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires a batch process without a form submission and a finish redirect.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|null
|
||||
* A redirect response if the batch is progressive. No return value otherwise.
|
||||
*/
|
||||
public function testFinishRedirect() {
|
||||
batch_test_stack(NULL, TRUE);
|
||||
|
||||
$batch = _batch_test_batch_1();
|
||||
$batch['finished'] = '_batch_test_finished_1_finished';
|
||||
batch_set($batch);
|
||||
return batch_process('batch-test/redirect');
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the 'Chained' form programmatically.
|
||||
*
|
||||
* Programmatic form: the page submits the 'Chained' form through
|
||||
* \Drupal::formBuilder()->submitForm().
|
||||
*
|
||||
* @param int $value
|
||||
* Some value passed to a the chained form.
|
||||
*
|
||||
* @return array
|
||||
* Render array containing markup.
|
||||
*/
|
||||
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(
|
||||
'#markup' => 'Got out of a programmatic batched form.',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a batch for testing theme used on the progress page.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|null
|
||||
* A redirect response if the batch is progressive. No return value otherwise.
|
||||
*/
|
||||
public function testThemeBatch() {
|
||||
batch_test_stack(NULL, TRUE);
|
||||
$batch = array(
|
||||
'operations' => array(
|
||||
array('_batch_test_theme_callback', array()),
|
||||
),
|
||||
);
|
||||
batch_set($batch);
|
||||
return batch_process('batch-test/redirect');
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a batch for testing the title shown on the progress page.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|null
|
||||
* A redirect response if the batch is progressive. No return value otherwise.
|
||||
*/
|
||||
public function testTitleBatch() {
|
||||
batch_test_stack(NULL, TRUE);
|
||||
$batch = [
|
||||
'title' => 'Batch Test',
|
||||
'operations' => [
|
||||
['_batch_test_title_callback', []],
|
||||
],
|
||||
];
|
||||
batch_set($batch);
|
||||
return batch_process('batch-test/redirect');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\batch_test\Form;
|
||||
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Generate form of id batch_test_chained_form.
|
||||
*/
|
||||
class BatchTestChainedForm extends FormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'batch_test_chained_form';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
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(
|
||||
'#type' => 'textfield',
|
||||
'#title' => 'Value',
|
||||
'#default_value' => 1,
|
||||
);
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => 'Submit',
|
||||
);
|
||||
$form['#submit'] = array(
|
||||
'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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission handler #1 for batch_test_chained_form
|
||||
*/
|
||||
public static function batchTestChainedFormSubmit1($form, FormStateInterface $form_state) {
|
||||
batch_test_stack(NULL, TRUE);
|
||||
|
||||
batch_test_stack('submit handler 1');
|
||||
batch_test_stack('value = ' . $form_state->getValue('value'));
|
||||
|
||||
$value = &$form_state->getValue('value');
|
||||
$value++;
|
||||
batch_set(_batch_test_batch_1());
|
||||
|
||||
$form_state->setRedirect('batch_test.redirect');
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission handler #2 for batch_test_chained_form
|
||||
*/
|
||||
public static function batchTestChainedFormSubmit2($form, FormStateInterface $form_state) {
|
||||
batch_test_stack('submit handler 2');
|
||||
batch_test_stack('value = ' . $form_state->getValue('value'));
|
||||
|
||||
$value = &$form_state->getValue('value');
|
||||
$value++;
|
||||
batch_set(_batch_test_batch_2());
|
||||
|
||||
$form_state->setRedirect('batch_test.redirect');
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission handler #3 for batch_test_chained_form
|
||||
*/
|
||||
public static function batchTestChainedFormSubmit3($form, FormStateInterface $form_state) {
|
||||
batch_test_stack('submit handler 3');
|
||||
batch_test_stack('value = ' . $form_state->getValue('value'));
|
||||
|
||||
$value = &$form_state->getValue('value');
|
||||
$value++;
|
||||
|
||||
$form_state->setRedirect('batch_test.redirect');
|
||||
}
|
||||
|
||||
/**
|
||||
* Form submission handler #4 for batch_test_chained_form
|
||||
*/
|
||||
public static function batchTestChainedFormSubmit4($form, FormStateInterface $form_state) {
|
||||
batch_test_stack('submit handler 4');
|
||||
batch_test_stack('value = ' . $form_state->getValue('value'));
|
||||
|
||||
$value = &$form_state->getValue('value');
|
||||
$value++;
|
||||
batch_set(_batch_test_batch_3());
|
||||
|
||||
$form_state->setRedirect('batch_test.redirect');
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue