Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023
This commit is contained in:
parent
2720a9ec4b
commit
f3791f1da3
1898 changed files with 54300 additions and 11481 deletions
|
@ -5,7 +5,9 @@
|
|||
* Batch callbacks for the Batch API tests.
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
/**
|
||||
* Implements callback_batch_operation().
|
||||
|
@ -86,10 +88,9 @@ function _batch_test_nested_batch_callback() {
|
|||
* Provides a common 'finished' callback for batches 1 to 4.
|
||||
*/
|
||||
function _batch_test_finished_helper($batch_id, $success, $results, $operations) {
|
||||
$messages = array("results for batch $batch_id");
|
||||
if ($results) {
|
||||
foreach ($results as $op => $op_results) {
|
||||
$messages[] = 'op '. SafeMarkup::escape($op) . ': processed ' . count($op_results) . ' elements';
|
||||
$messages[] = 'op '. Html::escape($op) . ': processed ' . count($op_results) . ' elements';
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -102,7 +103,20 @@ function _batch_test_finished_helper($batch_id, $success, $results, $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)));
|
||||
}
|
||||
|
||||
drupal_set_message(SafeMarkup::set(implode('<br>', $messages)));
|
||||
// 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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,6 +137,16 @@ 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().
|
||||
*
|
||||
|
|
|
@ -31,6 +31,14 @@ batch_test.no_form:
|
|||
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:
|
||||
|
|
|
@ -72,6 +72,21 @@ class BatchTestController {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
common_test.l_active_class:
|
||||
path: '/common-test/type-link-active-class'
|
||||
defaults:
|
||||
_title: 'Test active link class'
|
||||
_controller: '\Drupal\common_test\Controller\CommonTestController::typeLinkActiveClass'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
services:
|
||||
main_content_renderer.json:
|
||||
class: Drupal\common_test\Render\MainContent\JsonRenderer
|
||||
arguments: ['@title_resolver', '@renderer']
|
||||
tags:
|
||||
- { name: render.main_content_renderer, format: json }
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\common_test\Controller;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
|
@ -89,7 +89,7 @@ class CommonTestController {
|
|||
*/
|
||||
public function destination() {
|
||||
$destination = \Drupal::destination()->getAsArray();
|
||||
$output = "The destination: " . SafeMarkup::checkPlain($destination['destination']);
|
||||
$output = "The destination: " . Html::escape($destination['destination']);
|
||||
return new Response($output);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\common_test\Render\MainContent\JsonRenderer.
|
||||
*/
|
||||
|
||||
namespace Drupal\common_test\Render\MainContent;
|
||||
|
||||
use Drupal\Core\Cache\CacheableJsonResponse;
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\Core\Controller\TitleResolverInterface;
|
||||
use Drupal\Core\Render\MainContent\MainContentRendererInterface;
|
||||
use Drupal\Core\Render\RendererInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Default main content renderer for JSON requests.
|
||||
*/
|
||||
class JsonRenderer implements MainContentRendererInterface {
|
||||
|
||||
/**
|
||||
* The title resolver.
|
||||
*
|
||||
* @var \Drupal\Core\Controller\TitleResolverInterface
|
||||
*/
|
||||
protected $titleResolver;
|
||||
|
||||
/**
|
||||
* The renderer service.
|
||||
*
|
||||
* @var \Drupal\Core\Render\RendererInterface
|
||||
*/
|
||||
protected $renderer;
|
||||
|
||||
/**
|
||||
* Constructs a new JsonRenderer.
|
||||
*
|
||||
* @param \Drupal\Core\Controller\TitleResolverInterface $title_resolver
|
||||
* The title resolver.
|
||||
* @param \Drupal\Core\Render\RendererInterface $renderer
|
||||
* The renderer service.
|
||||
*/
|
||||
public function __construct(TitleResolverInterface $title_resolver, RendererInterface $renderer) {
|
||||
$this->titleResolver = $title_resolver;
|
||||
$this->renderer = $renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match) {
|
||||
$json = [];
|
||||
|
||||
$json['content'] = (string) $this->renderer->renderRoot($main_content);
|
||||
if (!empty($main_content['#title'])) {
|
||||
$json['title'] = (string) $main_content['#title'];
|
||||
}
|
||||
else {
|
||||
$json['title'] = (string) $this->titleResolver->getTitle($request, $route_match->getRouteObject());
|
||||
}
|
||||
|
||||
$response = new CacheableJsonResponse($json, 200);
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($main_content));
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\database_test\Form;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\user\Entity\User;
|
||||
|
@ -56,8 +55,8 @@ class DatabaseTestForm extends FormBase {
|
|||
|
||||
foreach (User::loadMultiple($uids) as $account) {
|
||||
$options[$account->id()] = array(
|
||||
'title' => array('data' => array('#title' => SafeMarkup::checkPlain($account->getUsername()))),
|
||||
'username' => SafeMarkup::checkPlain($account->getUsername()),
|
||||
'title' => array('data' => array('#title' => $account->getUsername())),
|
||||
'username' => $account->getUsername(),
|
||||
'status' => $account->isActive() ? t('active') : t('blocked'),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* Install, update and uninstall functions for the entity_test module.
|
||||
*/
|
||||
|
||||
use Drupal\system\Tests\Update\DbUpdatesTrait;
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
|
@ -49,3 +51,6 @@ function entity_test_schema() {
|
|||
);
|
||||
return $schema;
|
||||
}
|
||||
|
||||
DbUpdatesTrait::includeUpdates('entity_test', 'entity_definition_updates');
|
||||
DbUpdatesTrait::includeUpdates('entity_test', 'status_report');
|
||||
|
|
|
@ -12,6 +12,7 @@ use Drupal\Core\Entity\EntityTypeInterface;
|
|||
use Drupal\Core\Field\BaseFieldDefinition;
|
||||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||
|
@ -119,14 +120,25 @@ function entity_test_entity_base_field_info(EntityTypeInterface $entity_type) {
|
|||
* Implements hook_entity_base_field_info_alter().
|
||||
*/
|
||||
function entity_test_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
|
||||
if ($entity_type->id() == 'entity_test_mulrev' && ($names = \Drupal::state()->get('entity_test.field_definitions.translatable'))) {
|
||||
$state = \Drupal::state();
|
||||
if ($entity_type->id() == 'entity_test_mulrev' && ($names = $state->get('entity_test.field_definitions.translatable'))) {
|
||||
foreach ($names as $name => $value) {
|
||||
$fields[$name]->setTranslatable($value);
|
||||
}
|
||||
}
|
||||
if ($entity_type->id() == 'node' && Drupal::state()->get('entity_test.node_remove_status_field')) {
|
||||
if ($entity_type->id() == 'node' && $state->get('entity_test.node_remove_status_field')) {
|
||||
unset($fields['status']);
|
||||
}
|
||||
if ($entity_type->id() == 'entity_test' && $state->get('entity_test.remove_name_field')) {
|
||||
unset($fields['name']);
|
||||
}
|
||||
// In 8001 we are assuming that a new definition with multiple cardinality has
|
||||
// been deployed.
|
||||
// @todo Remove this if we end up using state definitions at runtime. See
|
||||
// https://www.drupal.org/node/2554235.
|
||||
if ($entity_type->id() == 'entity_test' && $state->get('entity_test.db_updates.entity_definition_updates') == 8001) {
|
||||
$fields['user_id']->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -600,7 +612,7 @@ function entity_test_field_default_value(FieldableEntityInterface $entity, Field
|
|||
* @param string $hook
|
||||
* The hook name.
|
||||
* @param mixed $data
|
||||
* Arbitrary data associated to the hook invocation.
|
||||
* Arbitrary data associated with the hook invocation.
|
||||
*/
|
||||
function _entity_test_record_hooks($hook, $data) {
|
||||
$state = \Drupal::state();
|
||||
|
|
|
@ -4,7 +4,7 @@ entity.entity_test.canonical:
|
|||
_entity_view: 'entity_test.full'
|
||||
_title: 'Test full view mode'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
_entity_access: 'entity_test.view'
|
||||
|
||||
entity.entity_test.render_options:
|
||||
path: '/entity_test_converter/{foo}'
|
||||
|
@ -15,7 +15,7 @@ entity.entity_test.render_options:
|
|||
defaults:
|
||||
_entity_view: 'entity_test.full'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
_entity_access: 'foo.view'
|
||||
|
||||
entity.entity_test.render_no_view_mode:
|
||||
path: '/entity_test_no_view_mode/{entity_test}'
|
||||
|
|
|
@ -23,7 +23,6 @@ use Drupal\Core\Entity\EntityTypeInterface;
|
|||
* },
|
||||
* base_table = "entity_test_update",
|
||||
* revision_table = "entity_test_update_revision",
|
||||
* fieldable = TRUE,
|
||||
* persistent_cache = FALSE,
|
||||
* entity_keys = {
|
||||
* "id" = "id",
|
||||
|
|
|
@ -30,7 +30,7 @@ class EntityTestListBuilder extends EntityListBuilder {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildRow(EntityInterface $entity) {
|
||||
$row['label'] = $this->getLabel($entity);
|
||||
$row['label'] = $entity->label();
|
||||
$row['id'] = $entity->id();
|
||||
return $row + parent::buildRow($entity);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\entity_test;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityViewBuilder;
|
||||
|
||||
|
@ -36,7 +35,7 @@ class EntityTestViewBuilder extends EntityViewBuilder {
|
|||
foreach ($entities as $id => $entity) {
|
||||
$build[$id]['label'] = array(
|
||||
'#weight' => -100,
|
||||
'#markup' => SafeMarkup::checkPlain($entity->label()),
|
||||
'#plain_text' => $entity->label(),
|
||||
);
|
||||
$build[$id]['separator'] = array(
|
||||
'#weight' => -150,
|
||||
|
@ -44,7 +43,7 @@ class EntityTestViewBuilder extends EntityViewBuilder {
|
|||
);
|
||||
$build[$id]['view_mode'] = array(
|
||||
'#weight' => -200,
|
||||
'#markup' => SafeMarkup::checkPlain($view_mode),
|
||||
'#plain_text' => $view_mode,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\entity_test;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
|
@ -20,7 +19,7 @@ class EntityTestViewBuilderOverriddenView extends EntityTestViewBuilder {
|
|||
*/
|
||||
public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
|
||||
$build = [];
|
||||
$build[$entity->id()]['#markup'] = SafeMarkup::checkPlain($entity->label());
|
||||
$build[$entity->id()]['#plain_text'] = $entity->label();
|
||||
return $build;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,8 @@ class EntityTestRoutes {
|
|||
$routes["entity.$entity_type_id.admin_form"] = new Route(
|
||||
"$entity_type_id/structure/{bundle}",
|
||||
array('_controller' => '\Drupal\entity_test\Controller\EntityTestController::testAdmin'),
|
||||
array('_permission' => 'administer entity_test content')
|
||||
array('_permission' => 'administer entity_test content'),
|
||||
array('_admin_route' => TRUE)
|
||||
);
|
||||
}
|
||||
return $routes;
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Defines the 8001 db update for the "entity_definition_updates" group.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
|
||||
/**
|
||||
* Makes the 'user_id' field multiple and migrate its data.
|
||||
*/
|
||||
function entity_test_update_8001() {
|
||||
// To update the field schema we need to have no field data in the storage,
|
||||
// thus we retrieve it, delete it from storage, and write it back to the
|
||||
// storage after updating the schema.
|
||||
$database = \Drupal::database();
|
||||
|
||||
// Retrieve existing field data.
|
||||
$user_ids = $database->select('entity_test', 'et')
|
||||
->fields('et', ['id', 'user_id'])
|
||||
->execute()
|
||||
->fetchAllKeyed();
|
||||
|
||||
// Remove data from the storage.
|
||||
$database->update('entity_test')
|
||||
->fields(['user_id' => NULL])
|
||||
->execute();
|
||||
|
||||
// Update definitions and schema.
|
||||
$manager = \Drupal::entityDefinitionUpdateManager();
|
||||
$storage_definition = $manager->getFieldStorageDefinition('user_id', 'entity_test');
|
||||
$storage_definition->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
|
||||
$manager->updateFieldStorageDefinition($storage_definition);
|
||||
|
||||
// Restore entity data in the new schema.
|
||||
$insert_query = $database->insert('entity_test__user_id')
|
||||
->fields(['bundle', 'deleted', 'entity_id', 'revision_id', 'langcode', 'delta', 'user_id_target_id']);
|
||||
foreach ($user_ids as $id => $user_id) {
|
||||
$insert_query->values(['entity_test', 0, $id, $id, 'en', 0, $user_id]);
|
||||
}
|
||||
$insert_query->execute();
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Defines the 8002 db update for the "entity_definition_updates" group.
|
||||
*/
|
||||
|
||||
require_once 'entity_definition_updates_8001.inc';
|
||||
|
||||
/**
|
||||
* Makes the 'user_id' field single and migrate its data.
|
||||
*/
|
||||
function entity_test_update_8002() {
|
||||
// To update the field schema we need to have no field data in the storage,
|
||||
// thus we retrieve it, delete it from storage, and write it back to the
|
||||
// storage after updating the schema.
|
||||
$database = \Drupal::database();
|
||||
|
||||
// Retrieve existing entity data.
|
||||
$query = $database->select('entity_test__user_id', 'et')
|
||||
->fields('et', ['entity_id', 'user_id_target_id']);
|
||||
$query->condition('et.delta', 0);
|
||||
$user_ids = $query->execute()->fetchAllKeyed();
|
||||
|
||||
// Remove data from the storage.
|
||||
$database->truncate('entity_test__user_id')->execute();
|
||||
|
||||
// Update definitions and schema.
|
||||
$manager = \Drupal::entityDefinitionUpdateManager();
|
||||
$storage_definition = $manager->getFieldStorageDefinition('user_id', 'entity_test');
|
||||
$storage_definition->setCardinality(1);
|
||||
$manager->updateFieldStorageDefinition($storage_definition);
|
||||
|
||||
// Restore entity data in the new schema.
|
||||
foreach ($user_ids as $id => $user_id) {
|
||||
$database->update('entity_test')
|
||||
->fields(['user_id' => $user_id])
|
||||
->condition('id', $id)
|
||||
->execute();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Defines the 8001 db update for the "status_report" group.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test update.
|
||||
*/
|
||||
function entity_test_update_8001() {
|
||||
// Empty update, we just want to trigger an error in the status report.
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Defines the 8002 db update for the "status_report" group.
|
||||
*/
|
||||
|
||||
require_once 'status_report_8001.inc';
|
||||
|
||||
/**
|
||||
* Test update.
|
||||
*/
|
||||
function entity_test_update_8002() {
|
||||
// Empty update, we just want to trigger an update run.
|
||||
}
|
|
@ -6,3 +6,8 @@ services:
|
|||
# Set up a service with a missing class dependency.
|
||||
broken_class_with_missing_dependency:
|
||||
class: Drupal\error_service_test\LonelyMonkeyClass
|
||||
logger.broken:
|
||||
class: Drupal\error_service_test\Logger\TestLog
|
||||
tags:
|
||||
- { name: logger }
|
||||
- { name: backend_overridable }
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\error_service_test\Logger\TestLog.
|
||||
*/
|
||||
|
||||
namespace Drupal\error_service_test\Logger;
|
||||
|
||||
use Drupal\Core\Logger\RfcLoggerTrait;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Throws an exception while logging an exception.
|
||||
*
|
||||
* @see \Drupal\system\Tests\System\UncaughtExceptionTest::testLoggerException()
|
||||
*/
|
||||
class TestLog implements LoggerInterface {
|
||||
use RfcLoggerTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function log($level, $message, array $context = array()) {
|
||||
$trigger = [
|
||||
'%type' => 'Exception',
|
||||
'@message' => 'Deforestation',
|
||||
'%function' => 'Drupal\error_service_test\MonkeysInTheControlRoom->handle()',
|
||||
'severity_level' => 3,
|
||||
'channel' => 'php',
|
||||
];
|
||||
if (array_diff_assoc($trigger, $context) === []) {
|
||||
throw new \Exception('Oh, oh, frustrated monkeys!');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -57,6 +57,10 @@ class MonkeysInTheControlRoom implements HttpKernelInterface {
|
|||
throw new \Exception('Oh oh, bananas in the instruments.');
|
||||
}
|
||||
|
||||
if (\Drupal::state()->get('error_service_test.break_logger')) {
|
||||
throw new \Exception('Deforestation');
|
||||
}
|
||||
|
||||
return $this->app->handle($request, $type, $catch);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,8 +51,8 @@ class ErrorTestController extends ControllerBase {
|
|||
$monkey_love = $bananas;
|
||||
// This will generate a warning.
|
||||
$awesomely_big = 1/0;
|
||||
// This will generate a user error.
|
||||
trigger_error("Drupal is awesome", E_USER_WARNING);
|
||||
// This will generate a user error. Use & to check for double escaping.
|
||||
trigger_error("Drupal & awesome", E_USER_WARNING);
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class ErrorTestController extends ControllerBase {
|
|||
*/
|
||||
public function triggerException() {
|
||||
define('SIMPLETEST_COLLECT_ERRORS', FALSE);
|
||||
throw new \Exception("Drupal is awesome");
|
||||
throw new \Exception("Drupal & awesome");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -93,3 +93,14 @@ function form_test_user_register_form_rebuild($form, FormStateInterface $form_st
|
|||
drupal_set_message('Form rebuilt.');
|
||||
$form_state->setRebuild();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter() for form_test_vertical_tabs_access_form().
|
||||
*/
|
||||
function form_test_form_form_test_vertical_tabs_access_form_alter(&$form, &$form_state, $form_id) {
|
||||
$form['vertical_tabs1']['#access'] = FALSE;
|
||||
$form['vertical_tabs2']['#access'] = FALSE;
|
||||
$form['tabs3']['#access'] = TRUE;
|
||||
$form['fieldset1']['#access'] = FALSE;
|
||||
$form['container']['#access'] = FALSE;
|
||||
}
|
||||
|
|
|
@ -172,6 +172,14 @@ form_test.storage:
|
|||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
form_test.vertical_tabs_access:
|
||||
path: '/form_test/vertical-tabs-access'
|
||||
defaults:
|
||||
_form: '\Drupal\form_test\Form\FormTestVerticalTabsAccessForm'
|
||||
_title: 'Vertical tabs tests'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
form_test.state_clean:
|
||||
path: '/form_test/form-state-values-clean'
|
||||
defaults:
|
||||
|
|
|
@ -142,6 +142,15 @@ class FormTestDisabledElementsForm extends FormBase {
|
|||
'#date_timezone' => 'Europe/Berlin',
|
||||
);
|
||||
|
||||
$form['disabled_container']['disabled_container_date'] = array(
|
||||
'#type' => 'date',
|
||||
'#title' => 'date',
|
||||
'#default_value' => '2001-01-13',
|
||||
'#expected_value' => '2001-01-13',
|
||||
'#test_hijack_value' => '2013-01-01',
|
||||
'#date_timezone' => 'Europe/Berlin',
|
||||
);
|
||||
|
||||
|
||||
// Try to hijack the email field with a valid email.
|
||||
$form['disabled_container']['disabled_container_email'] = array(
|
||||
|
|
|
@ -33,7 +33,10 @@ class FormTestRequiredAttributeForm extends FormBase {
|
|||
'#title' => $type,
|
||||
);
|
||||
}
|
||||
|
||||
$form['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => 'Submit',
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\form_test\Form;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
|
@ -139,7 +139,7 @@ class FormTestStorageForm extends FormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
drupal_set_message("Title: " . SafeMarkup::checkPlain($form_state->getValue('title')));
|
||||
drupal_set_message("Title: " . Html::escape($form_state->getValue('title')));
|
||||
drupal_set_message("Form constructions: " . $_SESSION['constructions']);
|
||||
if ($form_state->has(['thing', 'changed'])) {
|
||||
drupal_set_message("The thing has been changed.");
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\form_test\Form;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
|
@ -57,7 +56,7 @@ class FormTestStoragePageCacheForm extends FormBase {
|
|||
*/
|
||||
function form_test_storage_page_cache_old_build_id($form) {
|
||||
if (isset($form['#build_id_old'])) {
|
||||
$form['test_build_id_old']['#markup'] = SafeMarkup::checkPlain($form['#build_id_old']);
|
||||
$form['test_build_id_old']['#plain_text'] = $form['#build_id_old'];
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\form_test\Form\FormTestVerticalTabsAccessForm.
|
||||
*/
|
||||
|
||||
namespace Drupal\form_test\Form;
|
||||
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
class FormTestVerticalTabsAccessForm extends FormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'form_test_vertical_tabs_access_form';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$form['vertical_tabs1'] = array(
|
||||
'#type' => 'vertical_tabs',
|
||||
);
|
||||
$form['tab1'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Tab 1'),
|
||||
'#collapsible' => TRUE,
|
||||
'#group' => 'vertical_tabs1',
|
||||
);
|
||||
$form['tab1']['field1'] = array(
|
||||
'#title' => t('Field 1'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => TRUE,
|
||||
);
|
||||
$form['tab2'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Tab 2'),
|
||||
'#collapsible' => TRUE,
|
||||
'#group' => 'vertical_tabs1',
|
||||
);
|
||||
$form['tab2']['field2'] = array(
|
||||
'#title' => t('Field 2'),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => 'field2',
|
||||
);
|
||||
|
||||
$form['fieldset1'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Fieldset'),
|
||||
);
|
||||
$form['fieldset1']['field3'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Field 3'),
|
||||
'#default_value' => TRUE,
|
||||
);
|
||||
|
||||
$form['container'] = array(
|
||||
'#type' => 'container',
|
||||
);
|
||||
$form['container']['field4'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Field 4'),
|
||||
'#default_value' => TRUE,
|
||||
);
|
||||
$form['container']['subcontainer'] = array(
|
||||
'#type' => 'container',
|
||||
);
|
||||
$form['container']['subcontainer']['field5'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Field 5'),
|
||||
'#default_value' => TRUE,
|
||||
);
|
||||
|
||||
$form['vertical_tabs2'] = array(
|
||||
'#type' => 'vertical_tabs',
|
||||
);
|
||||
$form['tab3'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Tab 3'),
|
||||
'#collapsible' => TRUE,
|
||||
'#group' => 'vertical_tabs2',
|
||||
);
|
||||
$form['tab3']['field6'] = array(
|
||||
'#title' => t('Field 6'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => TRUE,
|
||||
);
|
||||
|
||||
$form['actions'] = array(
|
||||
'#type' => 'actions',
|
||||
);
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Submit'),
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
$values = $form_state->getValues();
|
||||
if (empty($values['field1'])) {
|
||||
$form_state->setErrorByName('tab1][field1', t('This checkbox inside a vertical tab does not have its default value.'));
|
||||
}
|
||||
if ($values['field2'] != 'field2') {
|
||||
$form_state->setErrorByName('tab2][field2', t('This textfield inside a vertical tab does not have its default value.'));
|
||||
}
|
||||
if (empty($values['field3'])) {
|
||||
$form_state->setErrorByName('fieldset][field3', t('This checkbox inside a fieldset does not have its default value.'));
|
||||
}
|
||||
if (empty($values['field4'])) {
|
||||
$form_state->setErrorByName('container][field4', t('This checkbox inside a container does not have its default value.'));
|
||||
}
|
||||
if (empty($values['field5'])) {
|
||||
$form_state->setErrorByName('container][subcontainer][field5', t('This checkbox inside a nested container does not have its default value.'));
|
||||
}
|
||||
if (empty($values['field5'])) {
|
||||
$form_state->setErrorByName('tab3][field6', t('This checkbox inside a vertical tab whose fieldset access is allowed does not have its default value.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
drupal_set_message(t('The form submitted correctly.'));
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\form_test;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Form\ConfigFormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
|
@ -38,7 +37,7 @@ class FormTestArgumentsObject extends ConfigFormBase {
|
|||
|
||||
$form['bananas'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => SafeMarkup::checkPlain($arg),
|
||||
'#default_value' => $arg,
|
||||
'#title' => $this->t('Bananas'),
|
||||
);
|
||||
|
||||
|
|
|
@ -4,3 +4,9 @@ httpkernel_test.empty:
|
|||
_controller: '\Drupal\httpkernel_test\Controller\TestController::get'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
httpkernel_test.teapot:
|
||||
path: '/httpkernel-test/teapot'
|
||||
defaults:
|
||||
_controller: '\Drupal\httpkernel_test\Controller\TestController::teapot'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
|
|
@ -21,4 +21,21 @@ class TestController {
|
|||
return new Response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test special header and status code rendering.
|
||||
*
|
||||
* @return array
|
||||
* A render array using features of the 'http_header' directive.
|
||||
*/
|
||||
public function teapot() {
|
||||
$render = [];
|
||||
$render['#attached']['http_header'][] = ['X-Test-Teapot-Replace', 'This value gets replaced'];
|
||||
$render['#attached']['http_header'][] = ['X-Test-Teapot-Replace', 'Teapot replaced', TRUE];
|
||||
$render['#attached']['http_header'][] = ['X-Test-Teapot-No-Replace', 'This value is not replaced'];
|
||||
$render['#attached']['http_header'][] = ['X-Test-Teapot-No-Replace', 'This one is added', FALSE];
|
||||
$render['#attached']['http_header'][] = ['X-Test-Teapot', 'Teapot Mode Active'];
|
||||
$render['#attached']['http_header'][] = ['Status', "418 I'm a teapot."];
|
||||
return $render;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Schema for the configuration files of the Image Test module.
|
||||
|
||||
system.image.test_toolkit:
|
||||
type: mapping
|
||||
type: config_object
|
||||
label: 'Image test toolkit'
|
||||
mapping:
|
||||
test_parameter:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Schema for the configuration files of the Hook Menu Test module.
|
||||
|
||||
menu_test.menu_item:
|
||||
type: mapping
|
||||
type: config_object
|
||||
label: 'Menu test'
|
||||
mapping:
|
||||
title:
|
||||
|
|
|
@ -27,9 +27,9 @@ function menu_test_menu_links_discovered_alter(&$links) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu_local_tasks().
|
||||
* Implements hook_menu_local_tasks_alter().
|
||||
*/
|
||||
function menu_test_menu_local_tasks(&$data, $route_name) {
|
||||
function menu_test_menu_local_tasks_alter(&$data, $route_name) {
|
||||
if (in_array($route_name, array('menu_test.tasks_default'))) {
|
||||
$data['tabs'][0]['foo'] = array(
|
||||
'#theme' => 'menu_local_task',
|
||||
|
@ -50,32 +50,6 @@ function menu_test_menu_local_tasks(&$data, $route_name) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu_local_tasks_alter().
|
||||
*
|
||||
* If the menu_test.settings configuration 'tasks.alter' has been set, adds
|
||||
* several local tasks to menu-test/tasks.
|
||||
*/
|
||||
function menu_test_menu_local_tasks_alter(&$data, $route_name) {
|
||||
if (!\Drupal::config('menu_test.settings')->get('tasks.alter')) {
|
||||
return;
|
||||
}
|
||||
if (in_array($route_name, array('menu_test.tasks_default', 'menu_test.tasks_empty', 'menu_test.tasks_tasks'))) {
|
||||
// Rename the default local task from 'View' to 'Show'.
|
||||
// $data['tabs'] is expected to be keyed by link hrefs.
|
||||
// The default local task always links to its parent path, which means that
|
||||
// if the tab root path appears as key in $data['tabs'], then that key is
|
||||
// the default local task.
|
||||
$key = $route_name . '_tab';
|
||||
if (isset($data['tabs'][0][$key])) {
|
||||
$data['tabs'][0][$key]['#link']['title'] = 'Show it';
|
||||
}
|
||||
// Rename the 'foo' task to "Advanced settings" and put it last.
|
||||
$data['tabs'][0]['foo']['#link']['title'] = 'Advanced settings';
|
||||
$data['tabs'][0]['foo']['#weight'] = 110;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Page callback: Tests the theme negotiation functionality.
|
||||
*
|
||||
|
|
|
@ -57,7 +57,7 @@ class TestControllers {
|
|||
return ['#markup' => SafeMarkup::format("Sometimes there is a placeholder: '@placeholder'.", array('@placeholder' => $placeholder))];
|
||||
}
|
||||
else {
|
||||
return ['#markup' => SafeMarkup::format('Sometimes there is no placeholder.')];
|
||||
return ['#markup' => 'Sometimes there is no placeholder.'];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
name: module handler test multiple
|
||||
type: module
|
||||
description: Test module used to test adding modules with child module.
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
hidden: true
|
|
@ -0,0 +1,7 @@
|
|||
name: module handler test multiple child
|
||||
type: module
|
||||
description: Child of test module used to test adding modules with child module.
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
hidden: true
|
|
@ -10,6 +10,7 @@ namespace Drupal\system_test\Controller;
|
|||
use Drupal\Core\Access\AccessResult;
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Render\RendererInterface;
|
||||
use Drupal\Core\Render\SafeString;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
@ -101,7 +102,7 @@ class SystemTestController extends ControllerBase {
|
|||
public function drupalSetMessageTest() {
|
||||
// Set two messages.
|
||||
drupal_set_message('First message (removed).');
|
||||
drupal_set_message('Second message (not removed).');
|
||||
drupal_set_message(t('Second message with <em>markup!</em> (not removed).'));
|
||||
|
||||
// Remove the first.
|
||||
unset($_SESSION['messages']['status'][0]);
|
||||
|
@ -112,6 +113,23 @@ class SystemTestController extends ControllerBase {
|
|||
|
||||
drupal_set_message('Duplicated message', 'status', TRUE);
|
||||
drupal_set_message('Duplicated message', 'status', TRUE);
|
||||
|
||||
// Add a SafeString message.
|
||||
drupal_set_message(SafeString::create('SafeString with <em>markup!</em>'));
|
||||
// Test duplicate SafeString messages.
|
||||
drupal_set_message(SafeString::create('SafeString with <em>markup!</em>'));
|
||||
// Ensure that multiple SafeString messages work.
|
||||
drupal_set_message(SafeString::create('SafeString2 with <em>markup!</em>'));
|
||||
|
||||
// Test mixing of types.
|
||||
drupal_set_message(SafeString::create('Non duplicate SafeString / string.'));
|
||||
drupal_set_message('Non duplicate SafeString / string.');
|
||||
drupal_set_message(SafeString::create('Duplicate SafeString / string.'), 'status', TRUE);
|
||||
drupal_set_message('Duplicate SafeString / string.', 'status', TRUE);
|
||||
|
||||
// Test auto-escape of non safe strings.
|
||||
drupal_set_message('<em>This<span>markup will be</span> escaped</em>.');
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\test_page_test\Controller;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Html;
|
||||
|
||||
/**
|
||||
* Defines a test controller for page titles.
|
||||
|
@ -54,19 +54,13 @@ class Test {
|
|||
/**
|
||||
* Defines a controller with a cached render array.
|
||||
*
|
||||
* @param bool $mark_safe
|
||||
* Whether or not to mark the title as safe use SafeMarkup::checkPlain.
|
||||
*
|
||||
* @return array
|
||||
* A render array
|
||||
*/
|
||||
public function controllerWithCache($mark_safe = FALSE) {
|
||||
public function controllerWithCache() {
|
||||
$build = [];
|
||||
$build['#title'] = '<span>Cached title</span>';
|
||||
if ($mark_safe) {
|
||||
$build['#title'] = SafeMarkup::checkPlain($build['#title']);
|
||||
}
|
||||
$build['#cache']['keys'] = ['test_controller', 'with_title', $mark_safe];
|
||||
$build['#cache']['keys'] = ['test_controller', 'with_title'];
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
|
|
@ -2,3 +2,7 @@ test_page_test.test_page:
|
|||
route_name: test_page_test.test_page
|
||||
title: 'Test front page link'
|
||||
weight: 0
|
||||
test_page_test.front_page:
|
||||
title: 'Home'
|
||||
route_name: '<front>'
|
||||
menu_name: main
|
||||
|
|
|
@ -28,14 +28,6 @@ test_page_test.cached_controller:
|
|||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
test_page_test.cached_controller.safe:
|
||||
path: '/test-page-cached-controller-safe'
|
||||
defaults:
|
||||
_controller: '\Drupal\test_page_test\Controller\Test::controllerWithCache'
|
||||
mark_safe: true
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
test_page_test.dynamic_title:
|
||||
path: '/test-page-dynamic-title'
|
||||
defaults:
|
||||
|
|
|
@ -143,4 +143,25 @@ class ThemeTestController extends ControllerBase {
|
|||
return new JsonResponse(['theme_initialized' => $theme_initialized]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller for testing preprocess functions with theme suggestions.
|
||||
*/
|
||||
public function preprocessSuggestions() {
|
||||
return [
|
||||
[
|
||||
'#theme' => 'theme_test_preprocess_suggestions',
|
||||
'#foo' => 'suggestion',
|
||||
],
|
||||
[
|
||||
'#theme' => 'theme_test_preprocess_suggestions',
|
||||
'#foo' => 'kitten',
|
||||
],
|
||||
[
|
||||
'#theme' => 'theme_test_preprocess_suggestions',
|
||||
'#foo' => 'monkey',
|
||||
],
|
||||
['#theme' => 'theme_test_preprocess_suggestions__kitten__flamingo'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<div class="suggestion">{{ foo }}</div>
|
||||
{% if bar %}
|
||||
<div class="suggestion">{{ bar }}</div>
|
||||
{% endif %}
|
|
@ -55,6 +55,12 @@ function theme_test_theme($existing, $type, $theme, $path) {
|
|||
$info['test_theme_not_existing_function'] = array(
|
||||
'function' => 'test_theme_not_existing_function',
|
||||
);
|
||||
$items['theme_test_preprocess_suggestions'] = [
|
||||
'variables' => [
|
||||
'foo' => '',
|
||||
'bar' => '',
|
||||
],
|
||||
];
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
@ -89,6 +95,27 @@ function theme_theme_test_function_template_override($variables) {
|
|||
return 'theme_test_function_template_override test failed.';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme_suggestions_HOOK().
|
||||
*/
|
||||
function theme_test_theme_suggestions_theme_test_preprocess_suggestions($variables) {
|
||||
return ['theme_test_preprocess_suggestions__' . $variables['foo']];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK().
|
||||
*/
|
||||
function theme_test_preprocess_theme_test_preprocess_suggestions(&$variables) {
|
||||
$variables['foo'] = 'Theme hook implementor=theme_theme_test_preprocess_suggestions().';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a module overriding a default hook with a suggestion.
|
||||
*/
|
||||
function theme_test_preprocess_theme_test_preprocess_suggestions__monkey(&$variables) {
|
||||
$variables['foo'] = 'Monkey';
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares variables for test render element templates.
|
||||
*
|
||||
|
|
|
@ -103,3 +103,10 @@ theme_test.non_html:
|
|||
_controller: '\Drupal\theme_test\ThemeTestController::nonHtml'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
theme_test.preprocess_suggestions:
|
||||
path: '/theme-test/preprocess-suggestions'
|
||||
defaults:
|
||||
_controller: '\Drupal\theme_test\ThemeTestController::preprocessSuggestions'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
|
|
@ -7,10 +7,13 @@
|
|||
|
||||
namespace Drupal\twig_extension_test;
|
||||
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* Controller routines for Twig extension test routes.
|
||||
*/
|
||||
class TwigExtensionTestController {
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* Menu callback for testing Twig filters in a Twig template.
|
||||
|
@ -19,6 +22,11 @@ class TwigExtensionTestController {
|
|||
return array(
|
||||
'#theme' => 'twig_extension_test_filter',
|
||||
'#message' => 'Every animal is not a mineral.',
|
||||
'#safe_join_items' => [
|
||||
'<em>will be escaped</em>',
|
||||
$this->t('<em>will be markup</em>'),
|
||||
['#markup' => '<strong>will be rendered</strong>']
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
<div class="testfilter">
|
||||
{{ message|testfilter }}
|
||||
</div>
|
||||
<div>
|
||||
{{ safe_join_items|safe_join('<br/>') }}
|
||||
</div>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
function twig_extension_test_theme($existing, $type, $theme, $path) {
|
||||
return array(
|
||||
'twig_extension_test_filter' => array(
|
||||
'variables' => array('message' => NULL),
|
||||
'variables' => array('message' => NULL, 'safe_join_items' => NULL),
|
||||
'template' => 'twig_extension_test.filter',
|
||||
),
|
||||
'twig_extension_test_function' => array(
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\update_script_test\PathProcessor\BrokenInboundPathProcessor.
|
||||
*/
|
||||
|
||||
namespace Drupal\update_script_test\PathProcessor;
|
||||
|
||||
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Example path processor which breaks on inbound.
|
||||
*/
|
||||
class BrokenInboundPathProcessor implements InboundPathProcessorInterface {
|
||||
|
||||
/**
|
||||
* The state.
|
||||
*
|
||||
* @var \Drupal\Core\State\StateInterface
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* Constructs a new BrokenInboundPathProcessor instance.
|
||||
*
|
||||
* @param \Drupal\Core\State\StateInterface $state
|
||||
* The state.
|
||||
*/
|
||||
public function __construct(StateInterface $state) {
|
||||
$this->state = $state;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processInbound($path, Request $request) {
|
||||
if ($this->state->get('update_script_test_broken_inbound', FALSE)) {
|
||||
throw new \RuntimeException();
|
||||
}
|
||||
else {
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
services:
|
||||
update_script_test.broken_path_processor:
|
||||
class: Drupal\update_script_test\PathProcessor\BrokenInboundPathProcessor
|
||||
arguments: ['@state']
|
||||
tags:
|
||||
- { name: path_processor_inbound, priority: 1000 }
|
||||
|
|
@ -35,7 +35,14 @@ if ($schema_version >= 8001) {
|
|||
* Schema version 8001.
|
||||
*/
|
||||
function update_test_schema_update_8001() {
|
||||
$table = [
|
||||
'fields' => [
|
||||
'a' => ['type' => 'int', 'not null' => TRUE],
|
||||
'b' => ['type' => 'blob', 'not null' => FALSE],
|
||||
],
|
||||
];
|
||||
|
||||
// Add a column.
|
||||
db_add_index('update_test_schema_table', 'test', ['a']);
|
||||
db_add_index('update_test_schema_table', 'test', ['a'], $table);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue