Move into nested docroot
This commit is contained in:
parent
83a0d3a149
commit
c8b70abde9
13405 changed files with 0 additions and 0 deletions
|
@ -0,0 +1,6 @@
|
|||
name: 'Page Cache Form Test'
|
||||
type: module
|
||||
description: 'Support module for the Page Cache module tests.'
|
||||
core: 8.x
|
||||
package: Testing
|
||||
version: VERSION
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install hooks for page_cache_form_test.
|
||||
*/
|
||||
|
||||
function page_cache_form_test_install() {
|
||||
// Set an explicit module weight, to ensure that the form alter hook is
|
||||
// always called after page_cache_form_alter().
|
||||
module_set_weight('page_cache_form_test', 10);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides functionality for testing form caching.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
*/
|
||||
function page_cache_form_test_form_page_cache_form_test_alter(&$form, FormStateInterface $form_state, $form_id) {
|
||||
// This runs earlier than system_form_alter() so we fore-go the immutability
|
||||
// check to the process callback, by which time system_form_alter() has run.
|
||||
$form['#process'][] = 'page_cache_form_test_form_page_cache_form_test_process';
|
||||
}
|
||||
|
||||
/**
|
||||
* Process callback to check immutability.
|
||||
*/
|
||||
function page_cache_form_test_form_page_cache_form_test_process($form, FormStateInterface $form_state) {
|
||||
if (isset($form_state->getBuildInfo()['immutable']) && $form_state->getBuildInfo()['immutable']) {
|
||||
$form['#suffix'] = 'Immutable: TRUE';
|
||||
}
|
||||
else {
|
||||
$form['#suffix'] = 'Immutable: FALSE';
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_module_implements_alter().
|
||||
*/
|
||||
function page_cache_form_test_module_implements_alter(&$implementations, $hook) {
|
||||
if ($hook === 'form_alter' && \Drupal::state()->get('page_cache_bypass_form_immutability', FALSE)) {
|
||||
// Disable system_form_alter
|
||||
unset($implementations['system']);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
page_cache_form_test.test_immutability:
|
||||
path: '/page_cache_form_test_immutability'
|
||||
defaults:
|
||||
_form: '\Drupal\page_cache_form_test\Form\TestForm'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\page_cache_form_test\Form;
|
||||
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
class TestForm extends FormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'page_cache_form_test';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$form['#prefix'] = '<p>Llamas are awesome, but kittens are pretty cool too!</p>';
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) { }
|
||||
|
||||
}
|
Reference in a new issue