updated core and modules
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
threshold:
|
||||
requirements_warning: 172800
|
||||
requirements_error: 1209600
|
||||
logging: 1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
uuid: ''
|
||||
name: ''
|
||||
name: 'Drupal'
|
||||
mail: ''
|
||||
slogan: ''
|
||||
page:
|
||||
|
||||
@@ -72,6 +72,9 @@ system.cron:
|
||||
requirements_error:
|
||||
type: integer
|
||||
label: 'Requirements error period'
|
||||
logging:
|
||||
type: integer
|
||||
label: 'Detailed cron logging'
|
||||
|
||||
system.date:
|
||||
type: config_object
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
.container-inline div,
|
||||
.container-inline label {
|
||||
display: inline;
|
||||
display: inline-block;
|
||||
}
|
||||
/* Details contents always need to be rendered as block. */
|
||||
.container-inline .details-wrapper {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @file
|
||||
* Styles for the system status counter component.
|
||||
*/
|
||||
|
||||
.system-status-counter__status-icon {
|
||||
display: inline-block;
|
||||
height: 25px;
|
||||
width: 25px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.system-status-counter__status-icon:before {
|
||||
content: "";
|
||||
background-size: 16px;
|
||||
background-position: center 2px;
|
||||
background-repeat: no-repeat;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.system-status-counter__status-icon--error:before {
|
||||
background-image: url(../../../../misc/icons/e32700/error.svg);
|
||||
}
|
||||
.system-status-counter__status-icon--warning:before {
|
||||
background-image: url(../../../../misc/icons/e29700/warning.svg);
|
||||
}
|
||||
.system-status-counter__status-icon--checked:before {
|
||||
background-image: url(../../../../misc/icons/73b355/check.svg);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @file
|
||||
* Styles for the system status report counters.
|
||||
*/
|
||||
|
||||
.system-status-report-counters__item {
|
||||
width: 100%;
|
||||
padding: .5em 0;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
background-color: rgba(0, 0, 0, 0.063);
|
||||
margin-bottom: .5em;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 60em) {
|
||||
.system-status-report-counters {
|
||||
flex-wrap: wrap;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.system-status-report-counters__item--half-width {
|
||||
width: 49%;
|
||||
}
|
||||
.system-status-report-counters__item--third-width {
|
||||
width: 33%;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* @file
|
||||
* Default styles for the System Status general info.
|
||||
*/
|
||||
|
||||
.system-status-general-info__item {
|
||||
border: 1px solid #ccc;
|
||||
margin-top: 1em;
|
||||
padding: 0 1em 1em;
|
||||
}
|
||||
|
||||
.system-status-general-info__item-title {
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
@@ -204,10 +204,11 @@ small .admin-link:after {
|
||||
.system-status-report__status-title {
|
||||
position: relative;
|
||||
vertical-align: top;
|
||||
width: 25%;
|
||||
width: 100%;
|
||||
padding: 10px 6px 10px 40px; /* LTR */
|
||||
box-sizing: border-box;
|
||||
font-weight: normal;
|
||||
background-color: transparent;
|
||||
}
|
||||
[dir="rtl"] .system-status-report__status-title {
|
||||
padding: 10px 40px 10px 6px;
|
||||
@@ -232,6 +233,9 @@ small .admin-link:after {
|
||||
.system-status-report__status-icon--warning:before {
|
||||
background-image: url(../../../misc/icons/e29700/warning.svg);
|
||||
}
|
||||
.system-status-report__entry__value {
|
||||
padding: 1em .5em;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appearance page.
|
||||
@@ -387,3 +391,6 @@ small .admin-link:after {
|
||||
[dir="rtl"] .system-themes-admin-form {
|
||||
clear: right;
|
||||
}
|
||||
.cron-description__run-cron {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# The menu_settings migration is in the menu_ui module.
|
||||
id: d6_menu
|
||||
label: Menus
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
plugin: menu
|
||||
process:
|
||||
id: menu_name
|
||||
label: title
|
||||
description: description
|
||||
destination:
|
||||
plugin: entity:menu
|
||||
@@ -0,0 +1,29 @@
|
||||
id: d7_global_theme_settings
|
||||
label: D7 global theme settings
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- theme_settings
|
||||
process:
|
||||
'features/logo': theme_settings/toggle_logo
|
||||
'features/name': theme_settings/toggle_name
|
||||
'features/slogan': theme_settings/toggle_slogan
|
||||
'features/node_user_picture': theme_settings/toggle_node_user_picture
|
||||
'features/comment_user_picture': theme_settings/toggle_comment_user_picture
|
||||
'features/comment_user_verification': theme_settings/toggle_comment_user_verification
|
||||
'features/favicon': theme_settings/toggle_favicon
|
||||
'logo/use_default': theme_settings/default_logo
|
||||
'logo/path': theme_settings/logo_path
|
||||
'favicon/use_default': theme_settings/default_favicon
|
||||
'favicon/path': theme_settings/favicon_path
|
||||
'favicon/mimetype': theme_settings/favicon_mimetype
|
||||
# Ignore settings not present in Drupal 8
|
||||
# theme_settings/logo_upload
|
||||
# theme_settings/favicon_upload
|
||||
# theme_settings/toggle_main_menu
|
||||
# theme_settings/toggle_secondary_menu
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.theme.global
|
||||
@@ -0,0 +1,20 @@
|
||||
id: d7_menu
|
||||
label: Menus
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: menu
|
||||
process:
|
||||
id:
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source: menu_name
|
||||
map:
|
||||
main-menu: main
|
||||
management: admin
|
||||
navigation: tools
|
||||
user-menu: account
|
||||
label: title
|
||||
description: description
|
||||
destination:
|
||||
plugin: entity:menu
|
||||
@@ -0,0 +1,12 @@
|
||||
id: d7_system_authorize
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- authorize_filetransfer_default
|
||||
process:
|
||||
filetransfer_default: authorize_filetransfer_default
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.authorize
|
||||
@@ -0,0 +1,15 @@
|
||||
id: d7_system_cron
|
||||
label: Drupal 7 cron settings
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- cron_threshold_warning
|
||||
- cron_threshold_error
|
||||
process:
|
||||
'threshold/requirements_warning': cron_threshold_warning
|
||||
'threshold/requirements_error': cron_threshold_error
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.cron
|
||||
@@ -0,0 +1,22 @@
|
||||
id: d7_system_date
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- site_default_country
|
||||
- date_first_day
|
||||
- date_default_timezone
|
||||
- configurable_timezones
|
||||
- empty_timezone_message
|
||||
- user_default_timezone
|
||||
process:
|
||||
'country/default': site_default_country
|
||||
first_day: date_first_day
|
||||
'timezone/default': date_default_timezone
|
||||
'timezone/user/configurable': configurable_timezones
|
||||
'timezone/user/warn': empty_timezone_message
|
||||
'timezone/user/default': user_default_timezone
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.date
|
||||
@@ -0,0 +1,20 @@
|
||||
id: d7_system_file
|
||||
label: Drupal 7 file system configuration
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- allow_insecure_uploads
|
||||
- file_temporary_path
|
||||
process:
|
||||
allow_insecure_uploads:
|
||||
plugin: static_map
|
||||
source: allow_insecure_uploads
|
||||
map:
|
||||
0: FALSE
|
||||
1: TRUE
|
||||
'path/temporary': file_temporary_path
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.file
|
||||
@@ -0,0 +1,17 @@
|
||||
id: d7_system_mail
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- mail_system
|
||||
process:
|
||||
'interface/default':
|
||||
plugin: static_map
|
||||
source: 'mail_system/default-system'
|
||||
map:
|
||||
DefaultMailSystem: php_mail
|
||||
MailTestCase: test_mail_collector
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.mail
|
||||
@@ -0,0 +1,19 @@
|
||||
id: d7_system_performance
|
||||
label: Drupal 7 performance configuration
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- preprocess_css
|
||||
- preprocess_js
|
||||
- cache_lifetime
|
||||
- page_compression
|
||||
process:
|
||||
'css/preprocess': preprocess_css
|
||||
'js/preprocess': preprocess_js
|
||||
'cache/page/max_age': cache_lifetime
|
||||
'response/gzip': page_compression
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.performance
|
||||
@@ -0,0 +1,44 @@
|
||||
id: d7_theme_settings
|
||||
label: D7 theme settings
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: d7_theme_settings
|
||||
constants:
|
||||
config_suffix: '.settings'
|
||||
process:
|
||||
# Build the configuration name from the variable name, i.e.
|
||||
# theme_bartik_settings becomes bartik.settings.
|
||||
theme_name:
|
||||
-
|
||||
plugin: explode
|
||||
source: name
|
||||
delimiter: _
|
||||
-
|
||||
plugin: extract
|
||||
index:
|
||||
- 1
|
||||
configuration_name:
|
||||
plugin: concat
|
||||
source:
|
||||
- '@theme_name'
|
||||
- constants/config_suffix
|
||||
toggle_logo: theme_settings/toggle_logo
|
||||
toggle_name: value/toggle_name
|
||||
toggle_slogan: value/toggle_slogan
|
||||
toggle_node_user_picture: value/toggle_node_user_picture
|
||||
toggle_comment_user_picture: value/toggle_comment_user_picture
|
||||
toggle_comment_user_verification: value/toggle_comment_user_verification
|
||||
toggle_favicon: value/toggle_favicon
|
||||
default_logo: value/default_logo
|
||||
logo_path: value/logo_path
|
||||
logo_upload: value/logo_upload
|
||||
default_favicon: value/default_favicon
|
||||
favicon_path: value/favicon_path
|
||||
favicon_mimetype: value/favicon_mimetype
|
||||
# Ignore settings not present in Drupal 8.
|
||||
# value/favicon_upload
|
||||
# value/toggle_main_menu
|
||||
# value/toggle_secondary_menu
|
||||
destination:
|
||||
plugin: d7_theme_settings
|
||||
@@ -0,0 +1,14 @@
|
||||
id: system_image
|
||||
label: Image toolkit configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- image_toolkit
|
||||
process:
|
||||
toolkit: image_toolkit
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.image
|
||||
@@ -0,0 +1,14 @@
|
||||
id: system_image_gd
|
||||
label: Image quality configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- image_jpeg_quality
|
||||
process:
|
||||
jpeg_quality: image_jpeg_quality
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.image.gd
|
||||
@@ -0,0 +1,22 @@
|
||||
id: system_logging
|
||||
label: System logging
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- error_level
|
||||
process:
|
||||
error_level:
|
||||
plugin: static_map
|
||||
source: error_level
|
||||
default_value: all
|
||||
map:
|
||||
0: hide
|
||||
1: some
|
||||
2: all
|
||||
3: verbose
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.logging
|
||||
@@ -0,0 +1,14 @@
|
||||
id: system_maintenance
|
||||
label: Maintenance page configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- site_offline_message
|
||||
process:
|
||||
message: site_offline_message
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.maintenance
|
||||
@@ -0,0 +1,16 @@
|
||||
id: system_rss
|
||||
label: RSS configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- feed_default_items
|
||||
- feed_item_length
|
||||
process:
|
||||
'items/limit': feed_default_items
|
||||
'items/view_mode': feed_item_length
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.rss
|
||||
@@ -0,0 +1,42 @@
|
||||
id: system_site
|
||||
label: Site configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: variable
|
||||
constants:
|
||||
slash: '/'
|
||||
variables:
|
||||
- site_name
|
||||
- site_mail
|
||||
- site_slogan
|
||||
- site_frontpage
|
||||
- site_403
|
||||
- site_404
|
||||
- drupal_weight_select_max
|
||||
- admin_compact_mode
|
||||
process:
|
||||
name: site_name
|
||||
mail: site_mail
|
||||
slogan: site_slogan
|
||||
'page/front':
|
||||
plugin: concat
|
||||
source:
|
||||
- constants/slash
|
||||
- site_frontpage
|
||||
'page/403':
|
||||
plugin: concat
|
||||
source:
|
||||
- constants/slash
|
||||
- site_403
|
||||
'page/404':
|
||||
plugin: concat
|
||||
source:
|
||||
- constants/slash
|
||||
- site_404
|
||||
weight_select_max: drupal_weight_select_max
|
||||
admin_compact_mode: admin_compact_mode
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.site
|
||||
@@ -23,13 +23,13 @@ class AdminController extends ControllerBase {
|
||||
}
|
||||
|
||||
uasort($module_info, 'system_sort_modules_by_info_name');
|
||||
$menu_items = array();
|
||||
$menu_items = [];
|
||||
|
||||
foreach ($module_info as $module => $info) {
|
||||
// Only display a section if there are any available tasks.
|
||||
if ($admin_tasks = system_get_module_admin_tasks($module, $info->info)) {
|
||||
// Sort links by title.
|
||||
uasort($admin_tasks, array('\Drupal\Component\Utility\SortArray', 'sortByTitleElement'));
|
||||
uasort($admin_tasks, ['\Drupal\Component\Utility\SortArray', 'sortByTitleElement']);
|
||||
// Move 'Configure permissions' links to the bottom of each section.
|
||||
$permission_key = "user.admin_permissions.$module";
|
||||
if (isset($admin_tasks[$permission_key])) {
|
||||
@@ -38,14 +38,14 @@ class AdminController extends ControllerBase {
|
||||
$admin_tasks[$permission_key] = $permission_task;
|
||||
}
|
||||
|
||||
$menu_items[$info->info['name']] = array($info->info['description'], $admin_tasks);
|
||||
$menu_items[$info->info['name']] = [$info->info['description'], $admin_tasks];
|
||||
}
|
||||
}
|
||||
|
||||
$output = array(
|
||||
$output = [
|
||||
'#theme' => 'system_admin_index',
|
||||
'#menu_items' => $menu_items,
|
||||
);
|
||||
];
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\system\Controller;
|
||||
|
||||
use Drupal\Core\Access\CsrfRequestHeaderAccessCheck;
|
||||
use Drupal\Core\Access\CsrfTokenGenerator;
|
||||
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Returns responses for CSRF token routes.
|
||||
*/
|
||||
class CsrfTokenController implements ContainerInjectionInterface {
|
||||
|
||||
/**
|
||||
* The CSRF token generator.
|
||||
*
|
||||
* @var \Drupal\Core\Access\CsrfTokenGenerator
|
||||
*/
|
||||
protected $tokenGenerator;
|
||||
|
||||
/**
|
||||
* Constructs a new CsrfTokenController object.
|
||||
*
|
||||
* @param \Drupal\Core\Access\CsrfTokenGenerator $token_generator
|
||||
* The CSRF token generator.
|
||||
*/
|
||||
public function __construct(CsrfTokenGenerator $token_generator) {
|
||||
$this->tokenGenerator = $token_generator;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('csrf_token')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a CSRF protecting session token.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* The response object.
|
||||
*/
|
||||
public function csrfToken() {
|
||||
return new Response($this->tokenGenerator->get(CsrfRequestHeaderAccessCheck::TOKEN_KEY), 200, ['Content-Type' => 'text/plain']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -150,7 +150,7 @@ class DbUpdateController extends ControllerBase {
|
||||
$_SESSION['update_ignore_warnings'] = TRUE;
|
||||
}
|
||||
|
||||
$regions = array();
|
||||
$regions = [];
|
||||
$requirements = update_check_requirements();
|
||||
$severity = drupal_requirements_severity($requirements);
|
||||
if ($severity == REQUIREMENT_ERROR || ($severity == REQUIREMENT_WARNING && empty($_SESSION['update_ignore_warnings']))) {
|
||||
@@ -212,32 +212,32 @@ class DbUpdateController extends ControllerBase {
|
||||
$this->keyValueExpirableFactory->get('update')->deleteAll();
|
||||
$this->keyValueExpirableFactory->get('update_available_release')->deleteAll();
|
||||
|
||||
$build['info_header'] = array(
|
||||
$build['info_header'] = [
|
||||
'#markup' => '<p>' . $this->t('Use this utility to update your database whenever a new release of Drupal or a module is installed.') . '</p><p>' . $this->t('For more detailed information, see the <a href="https://www.drupal.org/upgrade">upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.') . '</p>',
|
||||
);
|
||||
];
|
||||
|
||||
$info[] = $this->t("<strong>Back up your code</strong>. Hint: when backing up module code, do not leave that backup in the 'modules' or 'sites/*/modules' directories as this may confuse Drupal's auto-discovery mechanism.");
|
||||
$info[] = $this->t('Put your site into <a href=":url">maintenance mode</a>.', array(
|
||||
$info[] = $this->t('Put your site into <a href=":url">maintenance mode</a>.', [
|
||||
':url' => Url::fromRoute('system.site_maintenance_mode')->toString(TRUE)->getGeneratedUrl(),
|
||||
));
|
||||
]);
|
||||
$info[] = $this->t('<strong>Back up your database</strong>. This process will change your database values and in case of emergency you may need to revert to a backup.');
|
||||
$info[] = $this->t('Install your new files in the appropriate location, as described in the handbook.');
|
||||
$build['info'] = array(
|
||||
$build['info'] = [
|
||||
'#theme' => 'item_list',
|
||||
'#list_type' => 'ol',
|
||||
'#items' => $info,
|
||||
);
|
||||
$build['info_footer'] = array(
|
||||
];
|
||||
$build['info_footer'] = [
|
||||
'#markup' => '<p>' . $this->t('When you have performed the steps above, you may proceed.') . '</p>',
|
||||
);
|
||||
];
|
||||
|
||||
$build['link'] = array(
|
||||
$build['link'] = [
|
||||
'#type' => 'link',
|
||||
'#title' => $this->t('Continue'),
|
||||
'#attributes' => array('class' => array('button', 'button--primary')),
|
||||
'#attributes' => ['class' => ['button', 'button--primary']],
|
||||
// @todo Revisit once https://www.drupal.org/node/2548095 is in.
|
||||
'#url' => Url::fromUri('base://selection'),
|
||||
);
|
||||
];
|
||||
return $build;
|
||||
}
|
||||
|
||||
@@ -256,15 +256,15 @@ class DbUpdateController extends ControllerBase {
|
||||
|
||||
$count = 0;
|
||||
$incompatible_count = 0;
|
||||
$build['start'] = array(
|
||||
$build['start'] = [
|
||||
'#tree' => TRUE,
|
||||
'#type' => 'details',
|
||||
);
|
||||
];
|
||||
|
||||
// Ensure system.module's updates appear first.
|
||||
$build['start']['system'] = array();
|
||||
$build['start']['system'] = [];
|
||||
|
||||
$starting_updates = array();
|
||||
$starting_updates = [];
|
||||
$incompatible_updates_exist = FALSE;
|
||||
$updates_per_module = [];
|
||||
foreach (['update', 'post_update'] as $update_type) {
|
||||
@@ -278,30 +278,30 @@ class DbUpdateController extends ControllerBase {
|
||||
}
|
||||
foreach ($updates as $module => $update) {
|
||||
if (!isset($update['start'])) {
|
||||
$build['start'][$module] = array(
|
||||
$build['start'][$module] = [
|
||||
'#type' => 'item',
|
||||
'#title' => $module . ' module',
|
||||
'#markup' => $update['warning'],
|
||||
'#prefix' => '<div class="messages messages--warning">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
];
|
||||
$incompatible_updates_exist = TRUE;
|
||||
continue;
|
||||
}
|
||||
if (!empty($update['pending'])) {
|
||||
$updates_per_module += [$module => []];
|
||||
$updates_per_module[$module] = array_merge($updates_per_module[$module], $update['pending']);
|
||||
$build['start'][$module] = array(
|
||||
$build['start'][$module] = [
|
||||
'#type' => 'hidden',
|
||||
'#value' => $update['start'],
|
||||
);
|
||||
];
|
||||
// Store the previous items in order to merge normal updates and
|
||||
// post_update functions together.
|
||||
$build['start'][$module] = array(
|
||||
$build['start'][$module] = [
|
||||
'#theme' => 'item_list',
|
||||
'#items' => $updates_per_module[$module],
|
||||
'#title' => $module . ' module',
|
||||
);
|
||||
];
|
||||
|
||||
if ($update_type === 'update') {
|
||||
$starting_updates[$module] = $update['start'];
|
||||
@@ -329,7 +329,7 @@ class DbUpdateController extends ControllerBase {
|
||||
$build['start'][$module_update_key]['#items'][$data['number']] .= '<div class="warning">' . $text . '</div>';
|
||||
}
|
||||
// Move the module containing this update to the top of the list.
|
||||
$build['start'] = array($module_update_key => $build['start'][$module_update_key]) + $build['start'];
|
||||
$build['start'] = [$module_update_key => $build['start'][$module_update_key]] + $build['start'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,25 +341,25 @@ class DbUpdateController extends ControllerBase {
|
||||
if (empty($count)) {
|
||||
drupal_set_message($this->t('No pending updates.'));
|
||||
unset($build);
|
||||
$build['links'] = array(
|
||||
$build['links'] = [
|
||||
'#theme' => 'links',
|
||||
'#links' => $this->helpfulLinks($request),
|
||||
);
|
||||
];
|
||||
|
||||
// No updates to run, so caches won't get flushed later. Clear them now.
|
||||
drupal_flush_all_caches();
|
||||
}
|
||||
else {
|
||||
$build['help'] = array(
|
||||
$build['help'] = [
|
||||
'#markup' => '<p>' . $this->t('The version of Drupal you are updating from has been automatically detected.') . '</p>',
|
||||
'#weight' => -5,
|
||||
);
|
||||
];
|
||||
if ($incompatible_count) {
|
||||
$build['start']['#title'] = $this->formatPlural(
|
||||
$count,
|
||||
'1 pending update (@number_applied to be applied, @number_incompatible skipped)',
|
||||
'@count pending updates (@number_applied to be applied, @number_incompatible skipped)',
|
||||
array('@number_applied' => $count - $incompatible_count, '@number_incompatible' => $incompatible_count)
|
||||
['@number_applied' => $count - $incompatible_count, '@number_incompatible' => $incompatible_count]
|
||||
);
|
||||
}
|
||||
else {
|
||||
@@ -367,15 +367,15 @@ class DbUpdateController extends ControllerBase {
|
||||
}
|
||||
// @todo Simplify with https://www.drupal.org/node/2548095
|
||||
$base_url = str_replace('/update.php', '', $request->getBaseUrl());
|
||||
$url = (new Url('system.db_update', array('op' => 'run')))->setOption('base_url', $base_url);
|
||||
$build['link'] = array(
|
||||
$url = (new Url('system.db_update', ['op' => 'run']))->setOption('base_url', $base_url);
|
||||
$build['link'] = [
|
||||
'#type' => 'link',
|
||||
'#title' => $this->t('Apply pending updates'),
|
||||
'#attributes' => array('class' => array('button', 'button--primary')),
|
||||
'#attributes' => ['class' => ['button', 'button--primary']],
|
||||
'#weight' => 5,
|
||||
'#url' => $url,
|
||||
'#access' => $url->access($this->currentUser()),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $build;
|
||||
@@ -397,24 +397,24 @@ class DbUpdateController extends ControllerBase {
|
||||
// Report end result.
|
||||
$dblog_exists = $this->moduleHandler->moduleExists('dblog');
|
||||
if ($dblog_exists && $this->account->hasPermission('access site reports')) {
|
||||
$log_message = $this->t('All errors have been <a href=":url">logged</a>.', array(
|
||||
$log_message = $this->t('All errors have been <a href=":url">logged</a>.', [
|
||||
':url' => Url::fromRoute('dblog.overview')->setOption('base_url', $base_url)->toString(TRUE)->getGeneratedUrl(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
else {
|
||||
$log_message = $this->t('All errors have been logged.');
|
||||
}
|
||||
|
||||
if (!empty($_SESSION['update_success'])) {
|
||||
$message = '<p>' . $this->t('Updates were attempted. If you see no failures below, you may proceed happily back to your <a href=":url">site</a>. Otherwise, you may need to update your database manually.', array(':url' => Url::fromRoute('<front>')->setOption('base_url', $base_url)->toString(TRUE)->getGeneratedUrl())) . ' ' . $log_message . '</p>';
|
||||
$message = '<p>' . $this->t('Updates were attempted. If you see no failures below, you may proceed happily back to your <a href=":url">site</a>. Otherwise, you may need to update your database manually.', [':url' => Url::fromRoute('<front>')->setOption('base_url', $base_url)->toString(TRUE)->getGeneratedUrl()]) . ' ' . $log_message . '</p>';
|
||||
}
|
||||
else {
|
||||
$last = reset($_SESSION['updates_remaining']);
|
||||
list($module, $version) = array_pop($last);
|
||||
$message = '<p class="error">' . $this->t('The update process was aborted prematurely while running <strong>update #@version in @module.module</strong>.', array(
|
||||
$message = '<p class="error">' . $this->t('The update process was aborted prematurely while running <strong>update #@version in @module.module</strong>.', [
|
||||
'@version' => $version,
|
||||
'@module' => $module,
|
||||
)) . ' ' . $log_message;
|
||||
]) . ' ' . $log_message;
|
||||
if ($dblog_exists) {
|
||||
$message .= ' ' . $this->t('You may need to check the <code>watchdog</code> database table manually.');
|
||||
}
|
||||
@@ -425,23 +425,23 @@ class DbUpdateController extends ControllerBase {
|
||||
$message .= '<p>' . $this->t("<strong>Reminder: don't forget to set the <code>\$settings['update_free_access']</code> value in your <code>settings.php</code> file back to <code>FALSE</code>.</strong>") . '</p>';
|
||||
}
|
||||
|
||||
$build['message'] = array(
|
||||
$build['message'] = [
|
||||
'#markup' => $message,
|
||||
);
|
||||
$build['links'] = array(
|
||||
];
|
||||
$build['links'] = [
|
||||
'#theme' => 'links',
|
||||
'#links' => $this->helpfulLinks($request),
|
||||
);
|
||||
];
|
||||
|
||||
// Output a list of info messages.
|
||||
if (!empty($_SESSION['update_results'])) {
|
||||
$all_messages = array();
|
||||
$all_messages = [];
|
||||
foreach ($_SESSION['update_results'] as $module => $updates) {
|
||||
if ($module != '#abort') {
|
||||
$module_has_message = FALSE;
|
||||
$info_messages = array();
|
||||
$info_messages = [];
|
||||
foreach ($updates as $name => $queries) {
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
foreach ($queries as $query) {
|
||||
// If there is no message for this update, don't show anything.
|
||||
if (empty($query['query'])) {
|
||||
@@ -449,16 +449,16 @@ class DbUpdateController extends ControllerBase {
|
||||
}
|
||||
|
||||
if ($query['success']) {
|
||||
$messages[] = array(
|
||||
'#wrapper_attributes' => array('class' => array('success')),
|
||||
$messages[] = [
|
||||
'#wrapper_attributes' => ['class' => ['success']],
|
||||
'#markup' => $query['query'],
|
||||
);
|
||||
];
|
||||
}
|
||||
else {
|
||||
$messages[] = array(
|
||||
'#wrapper_attributes' => array('class' => array('failure')),
|
||||
$messages[] = [
|
||||
'#wrapper_attributes' => ['class' => ['failure']],
|
||||
'#markup' => '<strong>' . $this->t('Failed:') . '</strong> ' . $query['query'],
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,32 +470,32 @@ class DbUpdateController extends ControllerBase {
|
||||
else {
|
||||
$title = $this->t('Update @name', ['@name' => trim($name, '_')]);
|
||||
}
|
||||
$info_messages[] = array(
|
||||
$info_messages[] = [
|
||||
'#theme' => 'item_list',
|
||||
'#items' => $messages,
|
||||
'#title' => $title,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// If there were any messages then prefix them with the module name
|
||||
// and add it to the global message list.
|
||||
if ($module_has_message) {
|
||||
$all_messages[] = array(
|
||||
$all_messages[] = [
|
||||
'#type' => 'container',
|
||||
'#prefix' => '<h3>' . $this->t('@module module', array('@module' => $module)) . '</h3>',
|
||||
'#prefix' => '<h3>' . $this->t('@module module', ['@module' => $module]) . '</h3>',
|
||||
'#children' => $info_messages,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($all_messages) {
|
||||
$build['query_messages'] = array(
|
||||
$build['query_messages'] = [
|
||||
'#type' => 'container',
|
||||
'#children' => $all_messages,
|
||||
'#attributes' => array('class' => array('update-results')),
|
||||
'#attributes' => ['class' => ['update-results']],
|
||||
'#prefix' => '<h2>' . $this->t('The following updates returned messages:') . '</h2>',
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
unset($_SESSION['update_results']);
|
||||
@@ -515,17 +515,17 @@ class DbUpdateController extends ControllerBase {
|
||||
* A render array.
|
||||
*/
|
||||
public function requirements($severity, array $requirements, Request $request) {
|
||||
$options = $severity == REQUIREMENT_WARNING ? array('continue' => 1) : array();
|
||||
$options = $severity == REQUIREMENT_WARNING ? ['continue' => 1] : [];
|
||||
// @todo Revisit once https://www.drupal.org/node/2548095 is in. Something
|
||||
// like Url::fromRoute('system.db_update')->setOptions() should then be
|
||||
// possible.
|
||||
$try_again_url = Url::fromUri($request->getUriForPath(''))->setOptions(['query' => $options])->toString(TRUE)->getGeneratedUrl();
|
||||
|
||||
$build['status_report'] = array(
|
||||
'#theme' => 'status_report',
|
||||
$build['status_report'] = [
|
||||
'#type' => 'status_report',
|
||||
'#requirements' => $requirements,
|
||||
'#suffix' => $this->t('Check the messages and <a href=":url">try again</a>.', array(':url' => $try_again_url))
|
||||
);
|
||||
'#suffix' => $this->t('Check the messages and <a href=":url">try again</a>.', [':url' => $try_again_url])
|
||||
];
|
||||
|
||||
$build['#title'] = $this->t('Requirements problem');
|
||||
return $build;
|
||||
@@ -543,19 +543,19 @@ class DbUpdateController extends ControllerBase {
|
||||
*/
|
||||
protected function updateTasksList($active = NULL) {
|
||||
// Default list of tasks.
|
||||
$tasks = array(
|
||||
$tasks = [
|
||||
'requirements' => $this->t('Verify requirements'),
|
||||
'info' => $this->t('Overview'),
|
||||
'selection' => $this->t('Review updates'),
|
||||
'run' => $this->t('Run updates'),
|
||||
'results' => $this->t('Review log'),
|
||||
);
|
||||
];
|
||||
|
||||
$task_list = array(
|
||||
$task_list = [
|
||||
'#theme' => 'maintenance_task_list',
|
||||
'#items' => $tasks,
|
||||
'#active' => $active,
|
||||
);
|
||||
];
|
||||
return $task_list;
|
||||
}
|
||||
|
||||
@@ -576,7 +576,7 @@ class DbUpdateController extends ControllerBase {
|
||||
$this->state->set('system.maintenance_mode', TRUE);
|
||||
}
|
||||
|
||||
$operations = array();
|
||||
$operations = [];
|
||||
|
||||
// Resolve any update dependencies to determine the actual updates that will
|
||||
// be run and the order they will be run in.
|
||||
@@ -587,9 +587,9 @@ class DbUpdateController extends ControllerBase {
|
||||
// batch API can pass in to the batch operation each time it is called. (We
|
||||
// do not store the entire update dependency array here because it is
|
||||
// potentially very large.)
|
||||
$dependency_map = array();
|
||||
$dependency_map = [];
|
||||
foreach ($updates as $function => $update) {
|
||||
$dependency_map[$function] = !empty($update['reverse_paths']) ? array_keys($update['reverse_paths']) : array();
|
||||
$dependency_map[$function] = !empty($update['reverse_paths']) ? array_keys($update['reverse_paths']) : [];
|
||||
}
|
||||
|
||||
// Determine updates to be performed.
|
||||
@@ -602,7 +602,7 @@ class DbUpdateController extends ControllerBase {
|
||||
drupal_set_installed_schema_version($update['module'], $update['number'] - 1);
|
||||
unset($start[$update['module']]);
|
||||
}
|
||||
$operations[] = array('update_do_one', array($update['module'], $update['number'], $dependency_map[$function]));
|
||||
$operations[] = ['update_do_one', [$update['module'], $update['number'], $dependency_map[$function]]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -618,12 +618,12 @@ class DbUpdateController extends ControllerBase {
|
||||
}
|
||||
|
||||
$batch['operations'] = $operations;
|
||||
$batch += array(
|
||||
$batch += [
|
||||
'title' => $this->t('Updating'),
|
||||
'init_message' => $this->t('Starting updates'),
|
||||
'error_message' => $this->t('An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.'),
|
||||
'finished' => array('\Drupal\system\Controller\DbUpdateController', 'batchFinished'),
|
||||
);
|
||||
'finished' => ['\Drupal\system\Controller\DbUpdateController', 'batchFinished'],
|
||||
];
|
||||
batch_set($batch);
|
||||
|
||||
// @todo Revisit once https://www.drupal.org/node/2548095 is in.
|
||||
@@ -673,15 +673,15 @@ class DbUpdateController extends ControllerBase {
|
||||
protected function helpfulLinks(Request $request) {
|
||||
// @todo Simplify with https://www.drupal.org/node/2548095
|
||||
$base_url = str_replace('/update.php', '', $request->getBaseUrl());
|
||||
$links['front'] = array(
|
||||
$links['front'] = [
|
||||
'title' => $this->t('Front page'),
|
||||
'url' => Url::fromRoute('<front>')->setOption('base_url', $base_url),
|
||||
);
|
||||
];
|
||||
if ($this->account->hasPermission('access administration pages')) {
|
||||
$links['admin-pages'] = array(
|
||||
$links['admin-pages'] = [
|
||||
'title' => $this->t('Administration pages'),
|
||||
'url' => Url::fromRoute('system.admin')->setOption('base_url', $base_url),
|
||||
);
|
||||
];
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
@@ -693,7 +693,7 @@ class DbUpdateController extends ControllerBase {
|
||||
* The module updates that can be performed.
|
||||
*/
|
||||
protected function getModuleUpdates() {
|
||||
$return = array();
|
||||
$return = [];
|
||||
$updates = update_get_update_list();
|
||||
foreach ($updates as $module => $update) {
|
||||
$return[$module] = $update['start'];
|
||||
|
||||
@@ -77,7 +77,7 @@ class EntityAutocompleteController extends ControllerBase {
|
||||
* or if it does not match the stored data.
|
||||
*/
|
||||
public function handleAutocomplete(Request $request, $target_type, $selection_handler, $selection_settings_key) {
|
||||
$matches = array();
|
||||
$matches = [];
|
||||
// Get the typed string from the URL, if it exists.
|
||||
if ($input = $request->query->get('q')) {
|
||||
$typed_string = Tags::explode($input);
|
||||
|
||||
@@ -25,7 +25,7 @@ class Http4xxController extends ControllerBase {
|
||||
* The default 403 content.
|
||||
*
|
||||
* @return array
|
||||
* A render array containing the message to display for 404 pages.
|
||||
* A render array containing the message to display for 403 pages.
|
||||
*/
|
||||
public function on403() {
|
||||
return [
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Drupal\system\Controller;
|
||||
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Entity\Query\QueryFactory;
|
||||
use Drupal\Core\Extension\ThemeHandlerInterface;
|
||||
use Drupal\Core\Form\FormBuilderInterface;
|
||||
use Drupal\Core\Menu\MenuLinkTreeInterface;
|
||||
@@ -19,13 +18,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
*/
|
||||
class SystemController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* The entity query factory object.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\Query\QueryFactory
|
||||
*/
|
||||
protected $queryFactory;
|
||||
|
||||
/**
|
||||
* System Manager Service.
|
||||
*
|
||||
@@ -66,20 +58,17 @@ class SystemController extends ControllerBase {
|
||||
*
|
||||
* @param \Drupal\system\SystemManager $systemManager
|
||||
* System manager service.
|
||||
* @param \Drupal\Core\Entity\Query\QueryFactory $queryFactory
|
||||
* The entity query object.
|
||||
* @param \Drupal\Core\Theme\ThemeAccessCheck $theme_access
|
||||
* The theme access checker service.
|
||||
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
|
||||
* The form builder.
|
||||
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
|
||||
* The theme handler.
|
||||
* @param \Drupal\Core\Menu\MenuLinkTreeInterface
|
||||
* @param \Drupal\Core\Menu\MenuLinkTreeInterface $menu_link_tree
|
||||
* The menu link tree service.
|
||||
*/
|
||||
public function __construct(SystemManager $systemManager, QueryFactory $queryFactory, ThemeAccessCheck $theme_access, FormBuilderInterface $form_builder, ThemeHandlerInterface $theme_handler, MenuLinkTreeInterface $menu_link_tree) {
|
||||
public function __construct(SystemManager $systemManager, ThemeAccessCheck $theme_access, FormBuilderInterface $form_builder, ThemeHandlerInterface $theme_handler, MenuLinkTreeInterface $menu_link_tree) {
|
||||
$this->systemManager = $systemManager;
|
||||
$this->queryFactory = $queryFactory;
|
||||
$this->themeAccess = $theme_access;
|
||||
$this->formBuilder = $form_builder;
|
||||
$this->themeHandler = $theme_handler;
|
||||
@@ -92,7 +81,6 @@ class SystemController extends ControllerBase {
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('system.manager'),
|
||||
$container->get('entity.query'),
|
||||
$container->get('access_check.theme'),
|
||||
$container->get('form_builder'),
|
||||
$container->get('theme_handler'),
|
||||
@@ -112,19 +100,19 @@ class SystemController extends ControllerBase {
|
||||
public function overview($link_id) {
|
||||
// Check for status report errors.
|
||||
if ($this->systemManager->checkRequirements() && $this->currentUser()->hasPermission('administer site configuration')) {
|
||||
drupal_set_message($this->t('One or more problems were detected with your Drupal installation. Check the <a href=":status">status report</a> for more information.', array(':status' => $this->url('system.status'))), 'error');
|
||||
drupal_set_message($this->t('One or more problems were detected with your Drupal installation. Check the <a href=":status">status report</a> for more information.', [':status' => $this->url('system.status')]), 'error');
|
||||
}
|
||||
// Load all menu links below it.
|
||||
$parameters = new MenuTreeParameters();
|
||||
$parameters->setRoot($link_id)->excludeRoot()->setTopLevelOnly()->onlyEnabledLinks();
|
||||
$tree = $this->menuLinkTree->load(NULL, $parameters);
|
||||
$manipulators = array(
|
||||
array('callable' => 'menu.default_tree_manipulators:checkAccess'),
|
||||
array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
|
||||
);
|
||||
$manipulators = [
|
||||
['callable' => 'menu.default_tree_manipulators:checkAccess'],
|
||||
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
|
||||
];
|
||||
$tree = $this->menuLinkTree->transform($tree, $manipulators);
|
||||
$tree_access_cacheability = new CacheableMetadata();
|
||||
$blocks = array();
|
||||
$blocks = [];
|
||||
foreach ($tree as $key => $element) {
|
||||
$tree_access_cacheability = $tree_access_cacheability->merge(CacheableMetadata::createFromObject($element->access));
|
||||
|
||||
@@ -136,10 +124,10 @@ class SystemController extends ControllerBase {
|
||||
$link = $element->link;
|
||||
$block['title'] = $link->getTitle();
|
||||
$block['description'] = $link->getDescription();
|
||||
$block['content'] = array(
|
||||
$block['content'] = [
|
||||
'#theme' => 'admin_block_content',
|
||||
'#content' => $this->systemManager->getAdminBlock($link),
|
||||
);
|
||||
];
|
||||
|
||||
if (!empty($block['content']['#content'])) {
|
||||
$blocks[$key] = $block;
|
||||
@@ -173,7 +161,7 @@ class SystemController extends ControllerBase {
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
*/
|
||||
public function compactPage($mode) {
|
||||
user_cookie_save(array('admin_compact_mode' => ($mode == 'on')));
|
||||
user_cookie_save(['admin_compact_mode' => ($mode == 'on')]);
|
||||
return $this->redirect('<front>');
|
||||
}
|
||||
|
||||
@@ -199,9 +187,9 @@ class SystemController extends ControllerBase {
|
||||
uasort($themes, 'system_sort_modules_by_info_name');
|
||||
|
||||
$theme_default = $config->get('default');
|
||||
$theme_groups = array('installed' => array(), 'uninstalled' => array());
|
||||
$theme_groups = ['installed' => [], 'uninstalled' => []];
|
||||
$admin_theme = $config->get('admin');
|
||||
$admin_theme_options = array();
|
||||
$admin_theme_options = [];
|
||||
|
||||
foreach ($themes as &$theme) {
|
||||
if (!empty($theme->info['hidden'])) {
|
||||
@@ -218,17 +206,17 @@ class SystemController extends ControllerBase {
|
||||
$theme_keys[] = $theme->getName();
|
||||
}
|
||||
else {
|
||||
$theme_keys = array($theme->getName());
|
||||
$theme_keys = [$theme->getName()];
|
||||
}
|
||||
// Look for a screenshot in the current theme or in its closest ancestor.
|
||||
foreach (array_reverse($theme_keys) as $theme_key) {
|
||||
if (isset($themes[$theme_key]) && file_exists($themes[$theme_key]->info['screenshot'])) {
|
||||
$theme->screenshot = array(
|
||||
$theme->screenshot = [
|
||||
'uri' => $themes[$theme_key]->info['screenshot'],
|
||||
'alt' => $this->t('Screenshot for @theme theme', array('@theme' => $theme->info['name'])),
|
||||
'title' => $this->t('Screenshot for @theme theme', array('@theme' => $theme->info['name'])),
|
||||
'attributes' => array('class' => array('screenshot')),
|
||||
);
|
||||
'alt' => $this->t('Screenshot for @theme theme', ['@theme' => $theme->info['name']]),
|
||||
'title' => $this->t('Screenshot for @theme theme', ['@theme' => $theme->info['name']]),
|
||||
'attributes' => ['class' => ['screenshot']],
|
||||
];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -245,16 +233,16 @@ class SystemController extends ControllerBase {
|
||||
// Confirm that the theme engine is available.
|
||||
$theme->incompatible_engine = isset($theme->info['engine']) && !isset($theme->owner);
|
||||
}
|
||||
$theme->operations = array();
|
||||
$theme->operations = [];
|
||||
if (!empty($theme->status) || !$theme->incompatible_core && !$theme->incompatible_php && !$theme->incompatible_base && !$theme->incompatible_engine) {
|
||||
// Create the operations links.
|
||||
$query['theme'] = $theme->getName();
|
||||
if ($this->themeAccess->checkAccess($theme->getName())) {
|
||||
$theme->operations[] = array(
|
||||
$theme->operations[] = [
|
||||
'title' => $this->t('Settings'),
|
||||
'url' => Url::fromRoute('system.theme_settings_theme', ['theme' => $theme->getName()]),
|
||||
'attributes' => array('title' => $this->t('Settings for @theme theme', array('@theme' => $theme->info['name']))),
|
||||
);
|
||||
'attributes' => ['title' => $this->t('Settings for @theme theme', ['@theme' => $theme->info['name']])],
|
||||
];
|
||||
}
|
||||
if (!empty($theme->status)) {
|
||||
if (!$theme->is_default) {
|
||||
@@ -269,45 +257,45 @@ class SystemController extends ControllerBase {
|
||||
}
|
||||
}
|
||||
if ($theme_uninstallable) {
|
||||
$theme->operations[] = array(
|
||||
$theme->operations[] = [
|
||||
'title' => $this->t('Uninstall'),
|
||||
'url' => Url::fromRoute('system.theme_uninstall'),
|
||||
'query' => $query,
|
||||
'attributes' => array('title' => $this->t('Uninstall @theme theme', array('@theme' => $theme->info['name']))),
|
||||
);
|
||||
'attributes' => ['title' => $this->t('Uninstall @theme theme', ['@theme' => $theme->info['name']])],
|
||||
];
|
||||
}
|
||||
$theme->operations[] = array(
|
||||
$theme->operations[] = [
|
||||
'title' => $this->t('Set as default'),
|
||||
'url' => Url::fromRoute('system.theme_set_default'),
|
||||
'query' => $query,
|
||||
'attributes' => array('title' => $this->t('Set @theme as default theme', array('@theme' => $theme->info['name']))),
|
||||
);
|
||||
'attributes' => ['title' => $this->t('Set @theme as default theme', ['@theme' => $theme->info['name']])],
|
||||
];
|
||||
}
|
||||
$admin_theme_options[$theme->getName()] = $theme->info['name'];
|
||||
}
|
||||
else {
|
||||
$theme->operations[] = array(
|
||||
$theme->operations[] = [
|
||||
'title' => $this->t('Install'),
|
||||
'url' => Url::fromRoute('system.theme_install'),
|
||||
'query' => $query,
|
||||
'attributes' => array('title' => $this->t('Install @theme theme', array('@theme' => $theme->info['name']))),
|
||||
);
|
||||
$theme->operations[] = array(
|
||||
'attributes' => ['title' => $this->t('Install @theme theme', ['@theme' => $theme->info['name']])],
|
||||
];
|
||||
$theme->operations[] = [
|
||||
'title' => $this->t('Install and set as default'),
|
||||
'url' => Url::fromRoute('system.theme_set_default'),
|
||||
'query' => $query,
|
||||
'attributes' => array('title' => $this->t('Install @theme as default theme', array('@theme' => $theme->info['name']))),
|
||||
);
|
||||
'attributes' => ['title' => $this->t('Install @theme as default theme', ['@theme' => $theme->info['name']])],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Add notes to default and administration theme.
|
||||
$theme->notes = array();
|
||||
$theme->notes = [];
|
||||
if ($theme->is_default) {
|
||||
$theme->notes[] = $this->t('default theme');
|
||||
}
|
||||
if ($theme->is_admin) {
|
||||
$theme->notes[] = $this->t('admin theme');
|
||||
$theme->notes[] = $this->t('administration theme');
|
||||
}
|
||||
|
||||
// Sort installed and uninstalled themes into their own groups.
|
||||
@@ -315,9 +303,9 @@ class SystemController extends ControllerBase {
|
||||
}
|
||||
|
||||
// There are two possible theme groups.
|
||||
$theme_group_titles = array(
|
||||
$theme_group_titles = [
|
||||
'installed' => $this->formatPlural(count($theme_groups['installed']), 'Installed theme', 'Installed themes'),
|
||||
);
|
||||
];
|
||||
if (!empty($theme_groups['uninstalled'])) {
|
||||
$theme_group_titles['uninstalled'] = $this->formatPlural(count($theme_groups['uninstalled']), 'Uninstalled theme', 'Uninstalled themes');
|
||||
}
|
||||
@@ -325,12 +313,12 @@ class SystemController extends ControllerBase {
|
||||
uasort($theme_groups['installed'], 'system_sort_themes');
|
||||
$this->moduleHandler()->alter('system_themes_page', $theme_groups);
|
||||
|
||||
$build = array();
|
||||
$build[] = array(
|
||||
$build = [];
|
||||
$build[] = [
|
||||
'#theme' => 'system_themes_page',
|
||||
'#theme_groups' => $theme_groups,
|
||||
'#theme_group_titles' => $theme_group_titles,
|
||||
);
|
||||
];
|
||||
$build[] = $this->formBuilder->getForm('Drupal\system\Form\ThemeAdminForm', $admin_theme_options);
|
||||
|
||||
return $build;
|
||||
|
||||
@@ -47,7 +47,7 @@ class SystemInfoController implements ContainerInjectionInterface {
|
||||
*/
|
||||
public function status() {
|
||||
$requirements = $this->systemManager->listRequirements();
|
||||
return array('#theme' => 'status_report', '#requirements' => $requirements);
|
||||
return ['#type' => 'status_report_page', '#requirements' => $requirements];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ class SystemInfoController implements ContainerInjectionInterface {
|
||||
$output = ob_get_clean();
|
||||
}
|
||||
else {
|
||||
$output = t('The phpinfo() function has been disabled for security reasons. For more information, visit <a href=":phpinfo">Enabling and disabling phpinfo()</a> handbook page.', array(':phpinfo' => 'https://www.drupal.org/node/243993'));
|
||||
$output = t('The phpinfo() function has been disabled for security reasons. For more information, visit <a href=":phpinfo">Enabling and disabling phpinfo()</a> handbook page.', [':phpinfo' => 'https://www.drupal.org/node/243993']);
|
||||
}
|
||||
return new Response($output);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class ThemeController extends ControllerBase {
|
||||
* the token is invalid.
|
||||
*/
|
||||
public function uninstall(Request $request) {
|
||||
$theme = $request->get('theme');
|
||||
$theme = $request->query->get('theme');
|
||||
$config = $this->config('system.theme');
|
||||
|
||||
if (isset($theme)) {
|
||||
@@ -71,15 +71,15 @@ class ThemeController extends ControllerBase {
|
||||
if (!empty($themes[$theme])) {
|
||||
// Do not uninstall the default or admin theme.
|
||||
if ($theme === $config->get('default') || $theme === $config->get('admin')) {
|
||||
drupal_set_message($this->t('%theme is the default theme and cannot be uninstalled.', array('%theme' => $themes[$theme]->info['name'])), 'error');
|
||||
drupal_set_message($this->t('%theme is the default theme and cannot be uninstalled.', ['%theme' => $themes[$theme]->info['name']]), 'error');
|
||||
}
|
||||
else {
|
||||
$this->themeHandler->uninstall(array($theme));
|
||||
drupal_set_message($this->t('The %theme theme has been uninstalled.', array('%theme' => $themes[$theme]->info['name'])));
|
||||
$this->themeHandler->uninstall([$theme]);
|
||||
drupal_set_message($this->t('The %theme theme has been uninstalled.', ['%theme' => $themes[$theme]->info['name']]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
drupal_set_message($this->t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
|
||||
drupal_set_message($this->t('The %theme theme was not found.', ['%theme' => $theme]), 'error');
|
||||
}
|
||||
|
||||
return $this->redirect('system.themes_page');
|
||||
@@ -102,16 +102,16 @@ class ThemeController extends ControllerBase {
|
||||
* the token is invalid.
|
||||
*/
|
||||
public function install(Request $request) {
|
||||
$theme = $request->get('theme');
|
||||
$theme = $request->query->get('theme');
|
||||
|
||||
if (isset($theme)) {
|
||||
try {
|
||||
if ($this->themeHandler->install(array($theme))) {
|
||||
if ($this->themeHandler->install([$theme])) {
|
||||
$themes = $this->themeHandler->listInfo();
|
||||
drupal_set_message($this->t('The %theme theme has been installed.', array('%theme' => $themes[$theme]->info['name'])));
|
||||
drupal_set_message($this->t('The %theme theme has been installed.', ['%theme' => $themes[$theme]->info['name']]));
|
||||
}
|
||||
else {
|
||||
drupal_set_message($this->t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
|
||||
drupal_set_message($this->t('The %theme theme was not found.', ['%theme' => $theme]), 'error');
|
||||
}
|
||||
}
|
||||
catch (PreExistingConfigException $e) {
|
||||
@@ -121,10 +121,10 @@ class ThemeController extends ControllerBase {
|
||||
count($config_objects),
|
||||
'Unable to install @extension, %config_names already exists in active configuration.',
|
||||
'Unable to install @extension, %config_names already exist in active configuration.',
|
||||
array(
|
||||
[
|
||||
'%config_names' => implode(', ', $config_objects),
|
||||
'@extension' => $theme,
|
||||
)),
|
||||
]),
|
||||
'error'
|
||||
);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ class ThemeController extends ControllerBase {
|
||||
|
||||
// Check if the specified theme is one recognized by the system.
|
||||
// Or try to install the theme.
|
||||
if (isset($themes[$theme]) || $this->themeHandler->install(array($theme))) {
|
||||
if (isset($themes[$theme]) || $this->themeHandler->install([$theme])) {
|
||||
$themes = $this->themeHandler->listInfo();
|
||||
|
||||
// Set the default theme.
|
||||
@@ -171,17 +171,17 @@ class ThemeController extends ControllerBase {
|
||||
// theme.
|
||||
$admin_theme = $config->get('admin');
|
||||
if ($admin_theme != 0 && $admin_theme != $theme) {
|
||||
drupal_set_message($this->t('Please note that the administration theme is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', array(
|
||||
drupal_set_message($this->t('Please note that the administration theme is still set to the %admin_theme theme; consequently, the theme on this page remains unchanged. All non-administrative sections of the site, however, will show the selected %selected_theme theme by default.', [
|
||||
'%admin_theme' => $themes[$admin_theme]->info['name'],
|
||||
'%selected_theme' => $themes[$theme]->info['name'],
|
||||
)));
|
||||
]));
|
||||
}
|
||||
else {
|
||||
drupal_set_message($this->t('%theme is now the default theme.', array('%theme' => $themes[$theme]->info['name'])));
|
||||
drupal_set_message($this->t('%theme is now the default theme.', ['%theme' => $themes[$theme]->info['name']]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
drupal_set_message($this->t('The %theme theme was not found.', array('%theme' => $theme)), 'error');
|
||||
drupal_set_message($this->t('The %theme theme was not found.', ['%theme' => $theme]), 'error');
|
||||
}
|
||||
|
||||
return $this->redirect('system.themes_page');
|
||||
|
||||
@@ -23,7 +23,7 @@ class DateFormatAccessControlHandler extends EntityAccessControlHandler {
|
||||
return AccessResult::allowed();
|
||||
}
|
||||
// Locked date formats cannot be updated or deleted.
|
||||
elseif (in_array($operation, array('update', 'delete'))) {
|
||||
elseif (in_array($operation, ['update', 'delete'])) {
|
||||
if ($entity->isLocked()) {
|
||||
return AccessResult::forbidden()->addCacheableDependency($entity);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\system\Element;
|
||||
|
||||
use Drupal\Core\Render\Element\RenderElement;
|
||||
use Drupal\Core\Render\Element\StatusReport;
|
||||
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
|
||||
|
||||
/**
|
||||
* Creates status report page element.
|
||||
*
|
||||
* @RenderElement("status_report_page")
|
||||
*/
|
||||
class StatusReportPage extends RenderElement {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getInfo() {
|
||||
$class = get_class($this);
|
||||
return [
|
||||
'#theme' => 'status_report_page',
|
||||
'#pre_render' => [
|
||||
[$class, 'preRenderCounters'],
|
||||
[$class, 'preRenderGeneralInfo'],
|
||||
[$class, 'preRenderRequirements'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* #pre_render callback to get general info out of requirements.
|
||||
*/
|
||||
public static function preRenderGeneralInfo($element) {
|
||||
$element['#general_info'] = [
|
||||
'#theme' => 'status_report_general_info',
|
||||
];
|
||||
// Loop through requirements and pull out items.
|
||||
foreach ($element['#requirements'] as $key => $requirement) {
|
||||
switch ($key) {
|
||||
case 'cron':
|
||||
foreach ($requirement['description'] as &$description_elements) {
|
||||
foreach ($description_elements as &$description_element) {
|
||||
if (isset($description_element['#url']) && $description_element['#url']->getRouteName() == 'system.run_cron') {
|
||||
$description_element['#attributes']['class'][] = 'button';
|
||||
$description_element['#attributes']['class'][] = 'button--small';
|
||||
$description_element['#attributes']['class'][] = 'button--primary';
|
||||
$description_element['#attributes']['class'][] = 'system-status-general-info__run-cron';
|
||||
}
|
||||
}
|
||||
}
|
||||
// Intentional fall-through.
|
||||
|
||||
case 'drupal':
|
||||
case 'webserver':
|
||||
case 'database_system':
|
||||
case 'database_system_version':
|
||||
case 'php':
|
||||
case 'php_memory_limit':
|
||||
$element['#general_info']['#' . $key] = $requirement;
|
||||
if (isset($requirement['severity']) && $requirement['severity'] < REQUIREMENT_WARNING) {
|
||||
unset($element['#requirements'][$key]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* #pre_render callback to create counter elements.
|
||||
*/
|
||||
public static function preRenderCounters($element) {
|
||||
// Count number of items with different severity for summary.
|
||||
$counters = [
|
||||
'error' => [
|
||||
'amount' => 0,
|
||||
'text' => t('Error'),
|
||||
'text_plural' => t('Errors'),
|
||||
],
|
||||
'warning' => [
|
||||
'amount' => 0,
|
||||
'text' => t('Warning'),
|
||||
'text_plural' => t('Warnings'),
|
||||
],
|
||||
'checked' => [
|
||||
'amount' => 0,
|
||||
'text' => t('Checked'),
|
||||
'text_plural' => t('Checked'),
|
||||
],
|
||||
];
|
||||
|
||||
$severities = StatusReport::getSeverities();
|
||||
foreach ($element['#requirements'] as $key => &$requirement) {
|
||||
$severity = $severities[REQUIREMENT_INFO];
|
||||
if (isset($requirement['severity'])) {
|
||||
$severity = $severities[(int) $requirement['severity']];
|
||||
}
|
||||
elseif (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install') {
|
||||
$severity = $severities[REQUIREMENT_OK];
|
||||
}
|
||||
|
||||
if (isset($counters[$severity['status']])) {
|
||||
$counters[$severity['status']]['amount']++;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($counters as $key => $counter) {
|
||||
if ($counter['amount'] === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$text = new PluralTranslatableMarkup($counter['amount'], $counter['text'], $counter['text_plural']);
|
||||
|
||||
$element['#counters'][$key] = [
|
||||
'#theme' => 'status_report_counter',
|
||||
'#amount' => $counter['amount'],
|
||||
'#text' => $text,
|
||||
'#severity' => $key,
|
||||
];
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* #pre_render callback to create status report requirements.
|
||||
*/
|
||||
public static function preRenderRequirements($element) {
|
||||
$element['#requirements'] = [
|
||||
'#type' => 'status_report',
|
||||
'#requirements' => $element['#requirements'],
|
||||
];
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,7 +57,7 @@ class Action extends ConfigEntityBase implements ActionConfigEntityInterface, En
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $configuration = array();
|
||||
protected $configuration = [];
|
||||
|
||||
/**
|
||||
* The plugin ID of the action.
|
||||
@@ -90,7 +90,7 @@ class Action extends ConfigEntityBase implements ActionConfigEntityInterface, En
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPluginCollections() {
|
||||
return array('configuration' => $this->getPluginCollection());
|
||||
return ['configuration' => $this->getPluginCollection()];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ class AdminRouteSubscriber extends RouteSubscriberBase {
|
||||
// Use a lower priority than \Drupal\field_ui\Routing\RouteSubscriber or
|
||||
// \Drupal\views\EventSubscriber\RouteSubscriber to ensure we add the option
|
||||
// to their routes.
|
||||
$events[RoutingEvents::ALTER] = array('onAlterRoutes', -200);
|
||||
$events[RoutingEvents::ALTER] = ['onAlterRoutes', -200];
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class FileDownloadController extends ControllerBase {
|
||||
|
||||
if (file_stream_wrapper_valid_scheme($scheme) && file_exists($uri)) {
|
||||
// Let other modules provide headers and controls access to the file.
|
||||
$headers = $this->moduleHandler()->invokeAll('file_download', array($uri));
|
||||
$headers = $this->moduleHandler()->invokeAll('file_download', [$uri]);
|
||||
|
||||
foreach ($headers as $result) {
|
||||
if ($result == -1) {
|
||||
|
||||
@@ -10,11 +10,13 @@ use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Drupal\Core\Form\ConfigFormBaseTrait;
|
||||
|
||||
/**
|
||||
* Configure cron settings for this site.
|
||||
*/
|
||||
class CronForm extends FormBase {
|
||||
use ConfigFormBaseTrait;
|
||||
|
||||
/**
|
||||
* Stores the state storage service.
|
||||
@@ -65,6 +67,13 @@ class CronForm extends FormBase {
|
||||
$this->moduleHandler = $module_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEditableConfigNames() {
|
||||
return ['system.cron'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -89,29 +98,49 @@ class CronForm extends FormBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$form['description'] = array(
|
||||
$form['description'] = [
|
||||
'#markup' => '<p>' . t('Cron takes care of running periodic tasks like checking for updates and indexing content for search.') . '</p>',
|
||||
);
|
||||
$form['run'] = array(
|
||||
];
|
||||
$form['run'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Run cron'),
|
||||
);
|
||||
$status = '<p>' . $this->t('Last run: %time ago.', array('%time' => $this->dateFormatter->formatTimeDiffSince($this->state->get('system.cron_last')))) . '</p>';
|
||||
$form['status'] = array(
|
||||
];
|
||||
$status = '<p>' . $this->t('Last run: %time ago.', ['%time' => $this->dateFormatter->formatTimeDiffSince($this->state->get('system.cron_last'))]) . '</p>';
|
||||
$form['status'] = [
|
||||
'#markup' => $status,
|
||||
);
|
||||
];
|
||||
|
||||
$cron_url = $this->url('system.cron', array('key' => $this->state->get('system.cron_key')), array('absolute' => TRUE));
|
||||
$form['cron_url'] = array(
|
||||
'#markup' => '<p>' . t('To run cron from outside the site, go to <a href=":cron">@cron</a>', array(':cron' => $cron_url, '@cron' => $cron_url)) . '</p>',
|
||||
);
|
||||
$cron_url = $this->url('system.cron', ['key' => $this->state->get('system.cron_key')], ['absolute' => TRUE]);
|
||||
$form['cron_url'] = [
|
||||
'#markup' => '<p>' . t('To run cron from outside the site, go to <a href=":cron">@cron</a>', [':cron' => $cron_url, '@cron' => $cron_url]) . '</p>',
|
||||
];
|
||||
|
||||
if (!$this->moduleHandler->moduleExists('automated_cron')) {
|
||||
$form['cron'] = array(
|
||||
$form['automated_cron'] = [
|
||||
'#markup' => $this->t('Enable the <em>Automated Cron</em> module to allow cron execution at the end of a server response.'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$form['cron'] = [
|
||||
'#title' => t('Cron settings'),
|
||||
'#type' => 'details',
|
||||
'#open' => TRUE,
|
||||
];
|
||||
|
||||
$form['cron']['logging'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Detailed cron logging'),
|
||||
'#default_value' => $this->config('system.cron')->get('logging'),
|
||||
'#description' => 'Run times of individual cron jobs will be written to watchdog',
|
||||
];
|
||||
|
||||
$form['actions']['#type'] = 'actions';
|
||||
$form['actions']['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save configuration'),
|
||||
'#button_type' => 'primary',
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -119,6 +148,11 @@ class CronForm extends FormBase {
|
||||
* Runs cron and reloads the page.
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->config('system.cron')
|
||||
->set('logging', $form_state->getValue('logging'))
|
||||
->save();
|
||||
drupal_set_message(t('The configuration options have been saved.'));
|
||||
|
||||
// Run cron manually from Cron form.
|
||||
if ($this->cron->run()) {
|
||||
drupal_set_message(t('Cron ran successfully.'));
|
||||
|
||||
@@ -41,9 +41,9 @@ class DateFormatDeleteForm extends EntityDeleteForm {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getQuestion() {
|
||||
return t('Are you sure you want to delete the format %name : %format?', array(
|
||||
return t('Are you sure you want to delete the format %name : %format?', [
|
||||
'%name' => $this->entity->label(),
|
||||
'%format' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id()))
|
||||
'%format' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id())]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class DateFormatEditForm extends DateFormatFormBase {
|
||||
public function form(array $form, FormStateInterface $form_state) {
|
||||
$form = parent::form($form, $form_state);
|
||||
|
||||
$now = t('Displayed as %date', array('%date' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id())));
|
||||
$now = t('Displayed as %date', ['%date' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id())]);
|
||||
$form['date_format_pattern']['#field_suffix'] = ' <small data-drupal-date-formatter="preview">' . $now . '</small>';
|
||||
$form['date_format_pattern']['#default_value'] = $this->entity->getPattern();
|
||||
|
||||
|
||||
@@ -76,26 +76,26 @@ abstract class DateFormatFormBase extends EntityForm {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function form(array $form, FormStateInterface $form_state) {
|
||||
$form['label'] = array(
|
||||
$form['label'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => 'Name',
|
||||
'#maxlength' => 100,
|
||||
'#description' => t('Name of the date format'),
|
||||
'#default_value' => $this->entity->label(),
|
||||
);
|
||||
];
|
||||
|
||||
$form['id'] = array(
|
||||
$form['id'] = [
|
||||
'#type' => 'machine_name',
|
||||
'#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'),
|
||||
'#disabled' => !$this->entity->isNew(),
|
||||
'#default_value' => $this->entity->id(),
|
||||
'#machine_name' => array(
|
||||
'exists' => array($this, 'exists'),
|
||||
'#machine_name' => [
|
||||
'exists' => [$this, 'exists'],
|
||||
'replace_pattern' => '([^a-z0-9_]+)|(^custom$)',
|
||||
'error' => $this->t('The machine-readable name must be unique, and can only contain lowercase letters, numbers, and underscores. Additionally, it can not be the reserved word "custom".'),
|
||||
),
|
||||
);
|
||||
$form['date_format_pattern'] = array(
|
||||
],
|
||||
];
|
||||
$form['date_format_pattern'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Format string'),
|
||||
'#maxlength' => 100,
|
||||
@@ -105,14 +105,14 @@ abstract class DateFormatFormBase extends EntityForm {
|
||||
'data-drupal-date-formatter' => 'source',
|
||||
],
|
||||
'#field_suffix' => ' <small class="js-hide" data-drupal-date-formatter="preview">' . $this->t('Displayed as %date_format', ['%date_format' => '']) . '</small>',
|
||||
);
|
||||
];
|
||||
|
||||
$form['langcode'] = array(
|
||||
$form['langcode'] = [
|
||||
'#type' => 'language_select',
|
||||
'#title' => t('Language'),
|
||||
'#languages' => LanguageInterface::STATE_ALL,
|
||||
'#default_value' => $this->entity->language()->getId(),
|
||||
);
|
||||
];
|
||||
$form['#attached']['drupalSettings']['dateFormats'] = $this->dateFormatter->getSampleDateFormats();
|
||||
$form['#attached']['library'][] = 'system/drupal.system.date';
|
||||
return parent::form($form, $form_state);
|
||||
|
||||
@@ -77,59 +77,59 @@ class FileSystemForm extends ConfigFormBase {
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$config = $this->config('system.file');
|
||||
$form['file_public_path'] = array(
|
||||
$form['file_public_path'] = [
|
||||
'#type' => 'item',
|
||||
'#title' => t('Public file system path'),
|
||||
'#markup' => PublicStream::basePath(),
|
||||
'#description' => t('A local file system path where public files will be stored. This directory must exist and be writable by Drupal. This directory must be relative to the Drupal installation directory and be accessible over the web. This must be changed in settings.php'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['file_public_base_url'] = array(
|
||||
$form['file_public_base_url'] = [
|
||||
'#type' => 'item',
|
||||
'#title' => t('Public file base URL'),
|
||||
'#markup' => PublicStream::baseUrl(),
|
||||
'#description' => t('The base URL that will be used for public file URLs. This can be changed in settings.php'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['file_private_path'] = array(
|
||||
$form['file_private_path'] = [
|
||||
'#type' => 'item',
|
||||
'#title' => t('Private file system path'),
|
||||
'#markup' => (PrivateStream::basePath() ? PrivateStream::basePath() : t('Not set')),
|
||||
'#description' => t('An existing local file system path for storing private files. It should be writable by Drupal and not accessible over the web. This must be changed in settings.php'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['file_temporary_path'] = array(
|
||||
$form['file_temporary_path'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Temporary directory'),
|
||||
'#default_value' => $config->get('path.temporary'),
|
||||
'#maxlength' => 255,
|
||||
'#description' => t('A local file system path where temporary files will be stored. This directory should not be accessible over the web.'),
|
||||
'#after_build' => array('system_check_directory'),
|
||||
);
|
||||
'#after_build' => ['system_check_directory'],
|
||||
];
|
||||
// Any visible, writeable wrapper can potentially be used for the files
|
||||
// directory, including a remote file system that integrates with a CDN.
|
||||
$options = $this->streamWrapperManager->getDescriptions(StreamWrapperInterface::WRITE_VISIBLE);
|
||||
|
||||
if (!empty($options)) {
|
||||
$form['file_default_scheme'] = array(
|
||||
$form['file_default_scheme'] = [
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Default download method'),
|
||||
'#default_value' => $config->get('default_scheme'),
|
||||
'#options' => $options,
|
||||
'#description' => t('This setting is used as the preferred download method. The use of public files is more efficient, but does not provide any access control.'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
$intervals = array(0, 21600, 43200, 86400, 604800, 2419200, 7776000);
|
||||
$period = array_combine($intervals, array_map(array($this->dateFormatter, 'formatInterval'), $intervals));
|
||||
$intervals = [0, 21600, 43200, 86400, 604800, 2419200, 7776000];
|
||||
$period = array_combine($intervals, array_map([$this->dateFormatter, 'formatInterval'], $intervals));
|
||||
$period[0] = t('Never');
|
||||
$form['temporary_maximum_age'] = array(
|
||||
$form['temporary_maximum_age'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Delete orphaned files after'),
|
||||
'#default_value' => $config->get('temporary_maximum_age'),
|
||||
'#options' => $period,
|
||||
'#description' => t('Orphaned files are not referenced from any content but remain in the file system and may appear in administrative listings. <strong>Warning:</strong> If enabled, orphaned files will be permanently deleted and may not be recoverable.'),
|
||||
);
|
||||
];
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class ImageToolkitForm extends ConfigFormBase {
|
||||
*
|
||||
* @var \Drupal\Core\ImageToolkit\ImageToolkitInterface[]
|
||||
*/
|
||||
protected $availableToolkits = array();
|
||||
protected $availableToolkits = [];
|
||||
|
||||
/**
|
||||
* Constructs a ImageToolkitForm object.
|
||||
@@ -66,30 +66,30 @@ class ImageToolkitForm extends ConfigFormBase {
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$current_toolkit = $this->config('system.image')->get('toolkit');
|
||||
|
||||
$form['image_toolkit'] = array(
|
||||
$form['image_toolkit'] = [
|
||||
'#type' => 'radios',
|
||||
'#title' => $this->t('Select an image processing toolkit'),
|
||||
'#default_value' => $current_toolkit,
|
||||
'#options' => array(),
|
||||
);
|
||||
'#options' => [],
|
||||
];
|
||||
|
||||
// If we have more than one image toolkit, allow the user to select the one
|
||||
// to use, and load each of the toolkits' settings form.
|
||||
foreach ($this->availableToolkits as $id => $toolkit) {
|
||||
$definition = $toolkit->getPluginDefinition();
|
||||
$form['image_toolkit']['#options'][$id] = $definition['title'];
|
||||
$form['image_toolkit_settings'][$id] = array(
|
||||
$form['image_toolkit_settings'][$id] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('@toolkit settings', array('@toolkit' => $definition['title'])),
|
||||
'#title' => $this->t('@toolkit settings', ['@toolkit' => $definition['title']]),
|
||||
'#open' => TRUE,
|
||||
'#tree' => TRUE,
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
':radio[name="image_toolkit"]' => array('value' => $id),
|
||||
),
|
||||
),
|
||||
);
|
||||
$form['image_toolkit_settings'][$id] += $toolkit->buildConfigurationForm(array(), $form_state);
|
||||
'#states' => [
|
||||
'visible' => [
|
||||
':radio[name="image_toolkit"]' => ['value' => $id],
|
||||
],
|
||||
],
|
||||
];
|
||||
$form['image_toolkit_settings'][$id] += $toolkit->buildConfigurationForm([], $form_state);
|
||||
}
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
|
||||
@@ -29,18 +29,18 @@ class LoggingForm extends ConfigFormBase {
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$config = $this->config('system.logging');
|
||||
$form['error_level'] = array(
|
||||
$form['error_level'] = [
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Error messages to display'),
|
||||
'#default_value' => $config->get('error_level'),
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
ERROR_REPORTING_HIDE => t('None'),
|
||||
ERROR_REPORTING_DISPLAY_SOME => t('Errors and warnings'),
|
||||
ERROR_REPORTING_DISPLAY_ALL => t('All messages'),
|
||||
ERROR_REPORTING_DISPLAY_VERBOSE => t('All messages, with backtrace information'),
|
||||
),
|
||||
],
|
||||
'#description' => t('It is recommended that sites running on production environments do not display any errors.'),
|
||||
);
|
||||
];
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class ModulesListConfirmForm extends ConfirmFormBase {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $modules = array();
|
||||
protected $modules = [];
|
||||
|
||||
/**
|
||||
* The module installer.
|
||||
@@ -120,10 +120,10 @@ class ModulesListConfirmForm extends ConfirmFormBase {
|
||||
}
|
||||
|
||||
$items = $this->buildMessageList();
|
||||
$form['message'] = array(
|
||||
$form['message'] = [
|
||||
'#theme' => 'item_list',
|
||||
'#items' => $items,
|
||||
);
|
||||
];
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
}
|
||||
@@ -177,10 +177,10 @@ class ModulesListConfirmForm extends ConfirmFormBase {
|
||||
count($config_objects),
|
||||
'Unable to install @extension, %config_names already exists in active configuration.',
|
||||
'Unable to install @extension, %config_names already exist in active configuration.',
|
||||
array(
|
||||
[
|
||||
'%config_names' => implode(', ', $config_objects),
|
||||
'@extension' => $this->modules['install'][$e->getExtension()]
|
||||
)),
|
||||
]),
|
||||
'error'
|
||||
);
|
||||
return;
|
||||
@@ -194,10 +194,10 @@ class ModulesListConfirmForm extends ConfirmFormBase {
|
||||
}
|
||||
|
||||
$module_names = array_values($this->modules['install']);
|
||||
drupal_set_message($this->formatPlural(count($module_names), 'Module %name has been enabled.', '@count modules have been enabled: %names.', array(
|
||||
drupal_set_message($this->formatPlural(count($module_names), 'Module %name has been enabled.', '@count modules have been enabled: %names.', [
|
||||
'%name' => $module_names[0],
|
||||
'%names' => implode(', ', $module_names),
|
||||
)));
|
||||
]));
|
||||
}
|
||||
|
||||
$form_state->setRedirectUrl($this->getCancelUrl());
|
||||
|
||||
@@ -119,26 +119,26 @@ class ModulesListForm extends FormBase {
|
||||
// Include system.admin.inc so we can use the sort callbacks.
|
||||
$this->moduleHandler->loadInclude('system', 'inc', 'system.admin');
|
||||
|
||||
$form['filters'] = array(
|
||||
$form['filters'] = [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array('table-filter', 'js-show'),
|
||||
),
|
||||
);
|
||||
'#attributes' => [
|
||||
'class' => ['table-filter', 'js-show'],
|
||||
],
|
||||
];
|
||||
|
||||
$form['filters']['text'] = array(
|
||||
$form['filters']['text'] = [
|
||||
'#type' => 'search',
|
||||
'#title' => $this->t('Filter modules'),
|
||||
'#title_display' => 'invisible',
|
||||
'#size' => 30,
|
||||
'#placeholder' => $this->t('Filter by name or description'),
|
||||
'#description' => $this->t('Enter a part of the module name or description'),
|
||||
'#attributes' => array(
|
||||
'class' => array('table-filter-text'),
|
||||
'#attributes' => [
|
||||
'class' => ['table-filter-text'],
|
||||
'data-table' => '#system-modules',
|
||||
'autocomplete' => 'off',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Sort all modules by their names.
|
||||
$modules = system_rebuild_module_data();
|
||||
@@ -150,20 +150,21 @@ class ModulesListForm extends FormBase {
|
||||
if (empty($module->info['hidden'])) {
|
||||
$package = $module->info['package'];
|
||||
$form['modules'][$package][$filename] = $this->buildRow($modules, $module, $distribution);
|
||||
$form['modules'][$package][$filename]['#parents'] = ['modules', $filename];
|
||||
}
|
||||
}
|
||||
|
||||
// Add a wrapper around every package.
|
||||
foreach (Element::children($form['modules']) as $package) {
|
||||
$form['modules'][$package] += array(
|
||||
$form['modules'][$package] += [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t($package),
|
||||
'#open' => TRUE,
|
||||
'#theme' => 'system_modules_details',
|
||||
'#attributes' => array('class' => array('package-listing')),
|
||||
'#attributes' => ['class' => ['package-listing']],
|
||||
// Ensure that the "Core" package comes first.
|
||||
'#weight' => $package == 'Core' ? -10 : NULL,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// If testing modules are shown, collapse the corresponding package by
|
||||
@@ -173,15 +174,15 @@ class ModulesListForm extends FormBase {
|
||||
}
|
||||
|
||||
// Lastly, sort all packages by title.
|
||||
uasort($form['modules'], array('\Drupal\Component\Utility\SortArray', 'sortByTitleProperty'));
|
||||
uasort($form['modules'], ['\Drupal\Component\Utility\SortArray', 'sortByTitleProperty']);
|
||||
|
||||
$form['#attached']['library'][] = 'system/drupal.system.modules';
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
$form['actions'] = ['#type' => 'actions'];
|
||||
$form['actions']['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Install'),
|
||||
'#button_type' => 'primary',
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -200,9 +201,9 @@ class ModulesListForm extends FormBase {
|
||||
*/
|
||||
protected function buildRow(array $modules, Extension $module, $distribution) {
|
||||
// Set the basic properties.
|
||||
$row['#required'] = array();
|
||||
$row['#requires'] = array();
|
||||
$row['#required_by'] = array();
|
||||
$row['#required'] = [];
|
||||
$row['#requires'] = [];
|
||||
$row['#required_by'] = [];
|
||||
|
||||
$row['name']['#markup'] = $module->info['name'];
|
||||
$row['description']['#markup'] = $this->t($module->info['description']);
|
||||
@@ -212,48 +213,48 @@ class ModulesListForm extends FormBase {
|
||||
// implementation exists then the module provides an overview page, rather
|
||||
// than checking to see if the page exists, which is costly.
|
||||
if ($this->moduleHandler->moduleExists('help') && $module->status && in_array($module->getName(), $this->moduleHandler->getImplementations('help'))) {
|
||||
$row['links']['help'] = array(
|
||||
$row['links']['help'] = [
|
||||
'#type' => 'link',
|
||||
'#title' => $this->t('Help'),
|
||||
'#url' => Url::fromRoute('help.page', ['name' => $module->getName()]),
|
||||
'#options' => array('attributes' => array('class' => array('module-link', 'module-link-help'), 'title' => $this->t('Help'))),
|
||||
);
|
||||
'#options' => ['attributes' => ['class' => ['module-link', 'module-link-help'], 'title' => $this->t('Help')]],
|
||||
];
|
||||
}
|
||||
|
||||
// Generate link for module's permission, if the user has access to it.
|
||||
if ($module->status && $this->currentUser->hasPermission('administer permissions') && $this->permissionHandler->moduleProvidesPermissions($module->getName())) {
|
||||
$row['links']['permissions'] = array(
|
||||
$row['links']['permissions'] = [
|
||||
'#type' => 'link',
|
||||
'#title' => $this->t('Permissions'),
|
||||
'#url' => Url::fromRoute('user.admin_permissions'),
|
||||
'#options' => array('fragment' => 'module-' . $module->getName(), 'attributes' => array('class' => array('module-link', 'module-link-permissions'), 'title' => $this->t('Configure permissions'))),
|
||||
);
|
||||
'#options' => ['fragment' => 'module-' . $module->getName(), 'attributes' => ['class' => ['module-link', 'module-link-permissions'], 'title' => $this->t('Configure permissions')]],
|
||||
];
|
||||
}
|
||||
|
||||
// Generate link for module's configuration page, if it has one.
|
||||
if ($module->status && isset($module->info['configure'])) {
|
||||
$route_parameters = isset($module->info['configure_parameters']) ? $module->info['configure_parameters'] : array();
|
||||
$route_parameters = isset($module->info['configure_parameters']) ? $module->info['configure_parameters'] : [];
|
||||
if ($this->accessManager->checkNamedRoute($module->info['configure'], $route_parameters, $this->currentUser)) {
|
||||
$row['links']['configure'] = array(
|
||||
$row['links']['configure'] = [
|
||||
'#type' => 'link',
|
||||
'#title' => $this->t('Configure <span class="visually-hidden">the @module module</span>', ['@module' => $module->info['name']]),
|
||||
'#url' => Url::fromRoute($module->info['configure'], $route_parameters),
|
||||
'#options' => array(
|
||||
'attributes' => array(
|
||||
'class' => array('module-link', 'module-link-configure'),
|
||||
),
|
||||
),
|
||||
);
|
||||
'#options' => [
|
||||
'attributes' => [
|
||||
'class' => ['module-link', 'module-link-configure'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Present a checkbox for installing and indicating the status of a module.
|
||||
$row['enable'] = array(
|
||||
$row['enable'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Install'),
|
||||
'#default_value' => (bool) $module->status,
|
||||
'#disabled' => (bool) $module->status,
|
||||
);
|
||||
];
|
||||
|
||||
// Disable the checkbox for required modules.
|
||||
if (!empty($module->info['required'])) {
|
||||
@@ -267,24 +268,24 @@ class ModulesListForm extends FormBase {
|
||||
|
||||
// Initialize an empty array of reasons why the module is incompatible. Add
|
||||
// each reason as a separate element of the array.
|
||||
$reasons = array();
|
||||
$reasons = [];
|
||||
|
||||
// Check the core compatibility.
|
||||
if ($module->info['core'] != \Drupal::CORE_COMPATIBILITY) {
|
||||
$compatible = FALSE;
|
||||
$reasons[] = $this->t('This version is not compatible with Drupal @core_version and should be replaced.', array(
|
||||
$reasons[] = $this->t('This version is not compatible with Drupal @core_version and should be replaced.', [
|
||||
'@core_version' => \Drupal::CORE_COMPATIBILITY,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
// Ensure this module is compatible with the currently installed version of PHP.
|
||||
if (version_compare(phpversion(), $module->info['php']) < 0) {
|
||||
$compatible = FALSE;
|
||||
$required = $module->info['php'] . (substr_count($module->info['php'], '.') < 2 ? '.*' : '');
|
||||
$reasons[] = $this->t('This module requires PHP version @php_required and is incompatible with PHP version @php_version.', array(
|
||||
$reasons[] = $this->t('This module requires PHP version @php_required and is incompatible with PHP version @php_version.', [
|
||||
'@php_required' => $required,
|
||||
'@php_version' => phpversion(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
// If this module is not compatible, disable the checkbox.
|
||||
@@ -298,7 +299,7 @@ class ModulesListForm extends FormBase {
|
||||
// If this module requires other modules, add them to the array.
|
||||
foreach ($module->requires as $dependency => $version) {
|
||||
if (!isset($modules[$dependency])) {
|
||||
$row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">missing</span>)', array('@module' => Unicode::ucfirst($dependency)));
|
||||
$row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">missing</span>)', ['@module' => Unicode::ucfirst($dependency)]);
|
||||
$row['enable']['#disabled'] = TRUE;
|
||||
}
|
||||
// Only display visible modules.
|
||||
@@ -307,25 +308,25 @@ class ModulesListForm extends FormBase {
|
||||
// Disable the module's checkbox if it is incompatible with the
|
||||
// dependency's version.
|
||||
if ($incompatible_version = drupal_check_incompatibility($version, str_replace(\Drupal::CORE_COMPATIBILITY . '-', '', $modules[$dependency]->info['version']))) {
|
||||
$row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">incompatible with</span> version @version)', array(
|
||||
$row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">incompatible with</span> version @version)', [
|
||||
'@module' => $name . $incompatible_version,
|
||||
'@version' => $modules[$dependency]->info['version'],
|
||||
));
|
||||
]);
|
||||
$row['enable']['#disabled'] = TRUE;
|
||||
}
|
||||
// Disable the checkbox if the dependency is incompatible with this
|
||||
// version of Drupal core.
|
||||
elseif ($modules[$dependency]->info['core'] != \Drupal::CORE_COMPATIBILITY) {
|
||||
$row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', array(
|
||||
$row['#requires'][$dependency] = $this->t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', [
|
||||
'@module' => $name,
|
||||
));
|
||||
]);
|
||||
$row['enable']['#disabled'] = TRUE;
|
||||
}
|
||||
elseif ($modules[$dependency]->status) {
|
||||
$row['#requires'][$dependency] = $this->t('@module', array('@module' => $name));
|
||||
$row['#requires'][$dependency] = $this->t('@module', ['@module' => $name]);
|
||||
}
|
||||
else {
|
||||
$row['#requires'][$dependency] = $this->t('@module (<span class="admin-disabled">disabled</span>)', array('@module' => $name));
|
||||
$row['#requires'][$dependency] = $this->t('@module (<span class="admin-disabled">disabled</span>)', ['@module' => $name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -335,11 +336,11 @@ class ModulesListForm extends FormBase {
|
||||
foreach ($module->required_by as $dependent => $version) {
|
||||
if (isset($modules[$dependent]) && empty($modules[$dependent]->info['hidden'])) {
|
||||
if ($modules[$dependent]->status == 1 && $module->status == 1) {
|
||||
$row['#required_by'][$dependent] = $this->t('@module', array('@module' => $modules[$dependent]->info['name']));
|
||||
$row['#required_by'][$dependent] = $this->t('@module', ['@module' => $modules[$dependent]->info['name']]);
|
||||
$row['enable']['#disabled'] = TRUE;
|
||||
}
|
||||
else {
|
||||
$row['#required_by'][$dependent] = $this->t('@module (<span class="admin-disabled">disabled</span>)', array('@module' => $modules[$dependent]->info['name']));
|
||||
$row['#required_by'][$dependent] = $this->t('@module (<span class="admin-disabled">disabled</span>)', ['@module' => $modules[$dependent]->info['name']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -357,33 +358,29 @@ class ModulesListForm extends FormBase {
|
||||
* An array of modules to install and their dependencies.
|
||||
*/
|
||||
protected function buildModuleList(FormStateInterface $form_state) {
|
||||
$packages = $form_state->getValue('modules');
|
||||
|
||||
// Build a list of modules to install.
|
||||
$modules = array(
|
||||
'install' => array(),
|
||||
'dependencies' => array(),
|
||||
$modules = [
|
||||
'install' => [],
|
||||
'dependencies' => [],
|
||||
'experimental' => [],
|
||||
);
|
||||
];
|
||||
|
||||
// Required modules have to be installed.
|
||||
// @todo This should really not be handled here.
|
||||
$data = system_rebuild_module_data();
|
||||
foreach ($data as $name => $module) {
|
||||
if (!empty($module->required) && !$this->moduleHandler->moduleExists($name)) {
|
||||
// If the module is installed there is nothing to do.
|
||||
if ($this->moduleHandler->moduleExists($name)) {
|
||||
continue;
|
||||
}
|
||||
// Required modules have to be installed.
|
||||
if (!empty($module->required)) {
|
||||
$modules['install'][$name] = $module->info['name'];
|
||||
}
|
||||
}
|
||||
|
||||
// First, build a list of all modules that were selected.
|
||||
foreach ($packages as $package => $items) {
|
||||
foreach ($items as $name => $checkbox) {
|
||||
if ($checkbox['enable'] && !$this->moduleHandler->moduleExists($name)) {
|
||||
$modules['install'][$name] = $data[$name]->info['name'];
|
||||
// Identify experimental modules.
|
||||
if ($package == 'Core (Experimental)') {
|
||||
$modules['experimental'][$name] = $data[$name]->info['name'];
|
||||
}
|
||||
// Selected modules should be installed.
|
||||
elseif (($checkbox = $form_state->getValue(['modules', $name], FALSE)) && $checkbox['enable']) {
|
||||
$modules['install'][$name] = $data[$name]->info['name'];
|
||||
// Identify experimental modules.
|
||||
if ($data[$name]->info['package'] == 'Core (Experimental)') {
|
||||
$modules['experimental'][$name] = $data[$name]->info['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -411,6 +408,7 @@ class ModulesListForm extends FormBase {
|
||||
foreach (array_keys($modules['install']) as $module) {
|
||||
if (!drupal_check_module($module)) {
|
||||
unset($modules['install'][$module]);
|
||||
unset($modules['experimental'][$module]);
|
||||
foreach (array_keys($data[$module]->required_by) as $dependent) {
|
||||
unset($modules['install'][$dependent]);
|
||||
unset($modules['dependencies'][$dependent]);
|
||||
@@ -449,10 +447,10 @@ class ModulesListForm extends FormBase {
|
||||
try {
|
||||
$this->moduleInstaller->install(array_keys($modules['install']));
|
||||
$module_names = array_values($modules['install']);
|
||||
drupal_set_message($this->formatPlural(count($module_names), 'Module %name has been enabled.', '@count modules have been enabled: %names.', array(
|
||||
drupal_set_message($this->formatPlural(count($module_names), 'Module %name has been enabled.', '@count modules have been enabled: %names.', [
|
||||
'%name' => $module_names[0],
|
||||
'%names' => implode(', ', $module_names),
|
||||
)));
|
||||
]));
|
||||
}
|
||||
catch (PreExistingConfigException $e) {
|
||||
$config_objects = $e->flattenConfigObjects($e->getConfigObjects());
|
||||
@@ -461,10 +459,10 @@ class ModulesListForm extends FormBase {
|
||||
count($config_objects),
|
||||
'Unable to install @extension, %config_names already exists in active configuration.',
|
||||
'Unable to install @extension, %config_names already exist in active configuration.',
|
||||
array(
|
||||
[
|
||||
'%config_names' => implode(', ', $config_objects),
|
||||
'@extension' => $modules['install'][$e->getExtension()]
|
||||
)),
|
||||
]),
|
||||
'error'
|
||||
);
|
||||
return;
|
||||
|
||||
@@ -51,7 +51,7 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $modules = array();
|
||||
protected $modules = [];
|
||||
|
||||
/**
|
||||
* Constructs a ModulesUninstallConfirmForm object.
|
||||
@@ -135,12 +135,12 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase {
|
||||
|
||||
$data = system_rebuild_module_data();
|
||||
$form['text']['#markup'] = '<p>' . $this->t('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') . '</p>';
|
||||
$form['modules'] = array(
|
||||
$form['modules'] = [
|
||||
'#theme' => 'item_list',
|
||||
'#items' => array_map(function ($module) use ($data) {
|
||||
return $data[$module]->info['name'];
|
||||
}, $this->modules),
|
||||
);
|
||||
];
|
||||
|
||||
// List the dependent entities.
|
||||
$this->addDependencyListsToForm($form, 'module', $this->modules, $this->configManager, $this->entityManager);
|
||||
|
||||
@@ -85,28 +85,28 @@ class ModulesUninstallForm extends FormBase {
|
||||
// Include system.admin.inc so we can use the sort callbacks.
|
||||
$this->moduleHandler->loadInclude('system', 'inc', 'system.admin');
|
||||
|
||||
$form['filters'] = array(
|
||||
$form['filters'] = [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array('table-filter', 'js-show'),
|
||||
),
|
||||
);
|
||||
'#attributes' => [
|
||||
'class' => ['table-filter', 'js-show'],
|
||||
],
|
||||
];
|
||||
|
||||
$form['filters']['text'] = array(
|
||||
$form['filters']['text'] = [
|
||||
'#type' => 'search',
|
||||
'#title' => $this->t('Filter modules'),
|
||||
'#title_display' => 'invisible',
|
||||
'#size' => 30,
|
||||
'#placeholder' => $this->t('Filter by name or description'),
|
||||
'#description' => $this->t('Enter a part of the module name or description'),
|
||||
'#attributes' => array(
|
||||
'class' => array('table-filter-text'),
|
||||
'#attributes' => [
|
||||
'class' => ['table-filter-text'],
|
||||
'data-table' => '#system-modules-uninstall',
|
||||
'autocomplete' => 'off',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$form['modules'] = array();
|
||||
$form['modules'] = [];
|
||||
|
||||
// Only build the rest of the form if there are any modules available to
|
||||
// uninstall;
|
||||
@@ -120,18 +120,18 @@ class ModulesUninstallForm extends FormBase {
|
||||
uasort($uninstallable, 'system_sort_modules_by_info_name');
|
||||
$validation_reasons = $this->moduleInstaller->validateUninstall(array_keys($uninstallable));
|
||||
|
||||
$form['uninstall'] = array('#tree' => TRUE);
|
||||
$form['uninstall'] = ['#tree' => TRUE];
|
||||
foreach ($uninstallable as $module_key => $module) {
|
||||
$name = $module->info['name'] ?: $module->getName();
|
||||
$form['modules'][$module->getName()]['#module_name'] = $name;
|
||||
$form['modules'][$module->getName()]['name']['#markup'] = $name;
|
||||
$form['modules'][$module->getName()]['description']['#markup'] = $this->t($module->info['description']);
|
||||
|
||||
$form['uninstall'][$module->getName()] = array(
|
||||
$form['uninstall'][$module->getName()] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Uninstall @module module', array('@module' => $name)),
|
||||
'#title' => $this->t('Uninstall @module module', ['@module' => $name]),
|
||||
'#title_display' => 'invisible',
|
||||
);
|
||||
];
|
||||
|
||||
// If a validator returns reasons not to uninstall a module,
|
||||
// list the reasons and disable the check box.
|
||||
@@ -152,11 +152,11 @@ class ModulesUninstallForm extends FormBase {
|
||||
}
|
||||
|
||||
$form['#attached']['library'][] = 'system/drupal.system.modules';
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
$form['actions'] = ['#type' => 'actions'];
|
||||
$form['actions']['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Uninstall'),
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ class ModulesUninstallForm extends FormBase {
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
// Form submitted, but no modules selected.
|
||||
if (!array_filter($form_state->getValue('uninstall'))) {
|
||||
$form_state->setErrorByName('uninstall', $this->t('No modules selected.'));
|
||||
$form_state->setErrorByName('', $this->t('No modules selected.'));
|
||||
$form_state->setRedirect('system.modules_uninstall');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,64 +100,64 @@ class PerformanceForm extends ConfigFormBase {
|
||||
|
||||
$config = $this->config('system.performance');
|
||||
|
||||
$form['clear_cache'] = array(
|
||||
$form['clear_cache'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Clear cache'),
|
||||
'#open' => TRUE,
|
||||
);
|
||||
];
|
||||
|
||||
$form['clear_cache']['clear'] = array(
|
||||
$form['clear_cache']['clear'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Clear all caches'),
|
||||
'#submit' => array('::submitCacheClear'),
|
||||
);
|
||||
'#submit' => ['::submitCacheClear'],
|
||||
];
|
||||
|
||||
$form['caching'] = array(
|
||||
$form['caching'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Caching'),
|
||||
'#open' => TRUE,
|
||||
'#description' => $this->t('Note: Drupal provides an internal page cache module that is recommended for small to medium-sized websites.'),
|
||||
);
|
||||
];
|
||||
// Identical options to the ones for block caching.
|
||||
// @see \Drupal\Core\Block\BlockBase::buildConfigurationForm()
|
||||
$period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400);
|
||||
$period = array_map(array($this->dateFormatter, 'formatInterval'), array_combine($period, $period));
|
||||
$period = [0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400];
|
||||
$period = array_map([$this->dateFormatter, 'formatInterval'], array_combine($period, $period));
|
||||
$period[0] = '<' . t('no caching') . '>';
|
||||
$form['caching']['page_cache_maximum_age'] = array(
|
||||
$form['caching']['page_cache_maximum_age'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Page cache maximum age'),
|
||||
'#default_value' => $config->get('cache.page.max_age'),
|
||||
'#options' => $period,
|
||||
'#description' => t('The maximum time a page can be cached by browsers and proxies. This is used as the value for max-age in Cache-Control headers.'),
|
||||
);
|
||||
];
|
||||
|
||||
$directory = 'public://';
|
||||
$is_writable = is_dir($directory) && is_writable($directory);
|
||||
$disabled = !$is_writable;
|
||||
$disabled_message = '';
|
||||
if (!$is_writable) {
|
||||
$disabled_message = ' ' . t('<strong class="error">Set up the <a href=":file-system">public files directory</a> to make these optimizations available.</strong>', array(':file-system' => $this->url('system.file_system_settings')));
|
||||
$disabled_message = ' ' . t('<strong class="error">Set up the <a href=":file-system">public files directory</a> to make these optimizations available.</strong>', [':file-system' => $this->url('system.file_system_settings')]);
|
||||
}
|
||||
|
||||
$form['bandwidth_optimization'] = array(
|
||||
$form['bandwidth_optimization'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Bandwidth optimization'),
|
||||
'#open' => TRUE,
|
||||
'#description' => t('External resources can be optimized automatically, which can reduce both the size and number of requests made to your website.') . $disabled_message,
|
||||
);
|
||||
];
|
||||
|
||||
$form['bandwidth_optimization']['preprocess_css'] = array(
|
||||
$form['bandwidth_optimization']['preprocess_css'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Aggregate CSS files'),
|
||||
'#default_value' => $config->get('css.preprocess'),
|
||||
'#disabled' => $disabled,
|
||||
);
|
||||
$form['bandwidth_optimization']['preprocess_js'] = array(
|
||||
];
|
||||
$form['bandwidth_optimization']['preprocess_js'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Aggregate JavaScript files'),
|
||||
'#default_value' => $config->get('js.preprocess'),
|
||||
'#disabled' => $disabled,
|
||||
);
|
||||
];
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\system\Form;
|
||||
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Core\Form\ConfirmFormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Provides a form removing module content entities data before uninstallation.
|
||||
*/
|
||||
class PrepareModulesEntityUninstallForm extends ConfirmFormBase {
|
||||
|
||||
/**
|
||||
* The entity type ID of the entities to delete.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $entityTypeId;
|
||||
|
||||
/**
|
||||
* The entity type manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
||||
*/
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* Constructs a PrepareModulesEntityUninstallForm object.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
||||
* The entity type manager.
|
||||
*/
|
||||
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
|
||||
$this->entityTypeManager = $entity_type_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('entity_type.manager')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'system_prepare_modules_entity_uninstall';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getQuestion() {
|
||||
$entity_type = $this->entityTypeManager->getDefinition($this->entityTypeId);
|
||||
|
||||
return $this->t('Are you sure you want to delete all @entity_type_plural?', ['@entity_type_plural' => $entity_type->getPluralLabel()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDescription() {
|
||||
return $this->t('This action cannot be undone.<br />Make a backup of your database if you want to be able to restore these items.');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfirmText() {
|
||||
$entity_type = $this->entityTypeManager->getDefinition($this->entityTypeId);
|
||||
|
||||
return $this->t('Delete all @entity_type_plural', ['@entity_type_plural' => $entity_type->getPluralLabel()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCancelUrl() {
|
||||
return Url::fromRoute('system.modules_uninstall');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state, $entity_type_id = NULL) {
|
||||
$this->entityTypeId = $entity_type_id;
|
||||
if (!$this->entityTypeManager->hasDefinition($this->entityTypeId)) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$form = parent::buildForm($form, $form_state);
|
||||
|
||||
$storage = $this->entityTypeManager->getStorage($entity_type_id);
|
||||
$count = $storage->getQuery()->count()->execute();
|
||||
|
||||
$form['entity_type_id'] = [
|
||||
'#type' => 'value',
|
||||
'#value' => $entity_type_id,
|
||||
];
|
||||
|
||||
// Display a list of the 10 entity labels, if possible.
|
||||
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
|
||||
if ($count == 0) {
|
||||
$form['total'] = [
|
||||
'#markup' => $this->t(
|
||||
'There are 0 @entity_type_plural to delete.',
|
||||
['@entity_type_plural' => $entity_type->getPluralLabel()]
|
||||
),
|
||||
];
|
||||
}
|
||||
elseif ($entity_type->hasKey('label')) {
|
||||
$recent_entity_ids = $storage->getQuery()
|
||||
->sort($entity_type->getKey('id'), 'DESC')
|
||||
->pager(10)
|
||||
->execute();
|
||||
$recent_entities = $storage->loadMultiple($recent_entity_ids);
|
||||
|
||||
$labels = [];
|
||||
foreach ($recent_entities as $entity) {
|
||||
$labels[] = $entity->label();
|
||||
}
|
||||
|
||||
if ($labels) {
|
||||
$form['recent_entity_labels'] = [
|
||||
'#theme' => 'item_list',
|
||||
'#items' => $labels,
|
||||
];
|
||||
$more_count = $count - count($labels);
|
||||
$form['total'] = [
|
||||
'#markup' => $this->formatPlural(
|
||||
$more_count,
|
||||
'And <strong>@count</strong> more @entity_type_singular.',
|
||||
'And <strong>@count</strong> more @entity_type_plural.',
|
||||
[
|
||||
'@entity_type_singular' => $entity_type->getSingularLabel(),
|
||||
'@entity_type_plural' => $entity_type->getPluralLabel(),
|
||||
]
|
||||
),
|
||||
'#access' => (bool) $more_count,
|
||||
];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$form['total'] = [
|
||||
'#markup' => $this->formatPlural(
|
||||
$count,
|
||||
'This will delete <strong>@count</strong> @entity_type_singular.',
|
||||
'This will delete <strong>@count</strong> @entity_type_plural.',
|
||||
[
|
||||
'@entity_type_singular' => $entity_type->getSingularLabel(),
|
||||
'@entity_type_plural' => $entity_type->getPluralLabel(),
|
||||
]
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
$form['description']['#prefix'] = '<p>';
|
||||
$form['description']['#suffix'] = '</p>';
|
||||
$form['description']['#weight'] = 5;
|
||||
|
||||
// Only show the delete button if there are entities to delete.
|
||||
$form['actions']['submit']['#access'] = (bool) $count;
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$entity_type_id = $form_state->getValue('entity_type_id');
|
||||
|
||||
$entity_type_plural = $this->entityTypeManager->getDefinition($entity_type_id)->getPluralLabel();
|
||||
$batch = [
|
||||
'title' => t('Deleting @entity_type_plural', [
|
||||
'@entity_type_plural' => $entity_type_plural,
|
||||
]),
|
||||
'operations' => [
|
||||
[
|
||||
[__CLASS__, 'deleteContentEntities'], [$entity_type_id],
|
||||
],
|
||||
],
|
||||
'finished' => [__CLASS__, 'moduleBatchFinished'],
|
||||
'progress_message' => '',
|
||||
];
|
||||
batch_set($batch);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the content entities of the specified entity type.
|
||||
*
|
||||
* @param string $entity_type_id
|
||||
* The entity type ID from which data will be deleted.
|
||||
* @param array|\ArrayAccess $context
|
||||
* The batch context array, passed by reference.
|
||||
*
|
||||
* @internal
|
||||
* This batch callback is only meant to be used by this form.
|
||||
*/
|
||||
public static function deleteContentEntities($entity_type_id, &$context) {
|
||||
$storage = \Drupal::entityTypeManager()->getStorage($entity_type_id);
|
||||
|
||||
// Set the entity type ID in the results array so we can access it in the
|
||||
// batch finished callback.
|
||||
$context['results']['entity_type_id'] = $entity_type_id;
|
||||
|
||||
if (!isset($context['sandbox']['progress'])) {
|
||||
$context['sandbox']['progress'] = 0;
|
||||
$context['sandbox']['max'] = $storage->getQuery()->count()->execute();
|
||||
}
|
||||
|
||||
$entity_type = \Drupal::entityTypeManager()->getDefinition($entity_type_id);
|
||||
$entity_ids = $storage->getQuery()
|
||||
->sort($entity_type->getKey('id'), 'ASC')
|
||||
->range(0, 10)
|
||||
->execute();
|
||||
if ($entities = $storage->loadMultiple($entity_ids)) {
|
||||
$storage->delete($entities);
|
||||
}
|
||||
// Sometimes deletes cause secondary deletes. For example, deleting a
|
||||
// taxonomy term can cause it's children to be be deleted too.
|
||||
$context['sandbox']['progress'] = $context['sandbox']['max'] - $storage->getQuery()->count()->execute();
|
||||
|
||||
// Inform the batch engine that we are not finished and provide an
|
||||
// estimation of the completion level we reached.
|
||||
if (count($entity_ids) > 0 && $context['sandbox']['progress'] != $context['sandbox']['max']) {
|
||||
$context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
|
||||
$context['message'] = t('Deleting items... Completed @percentage% (@current of @total).', ['@percentage' => round(100 * $context['sandbox']['progress'] / $context['sandbox']['max']), '@current' => $context['sandbox']['progress'], '@total' => $context['sandbox']['max']]);
|
||||
|
||||
}
|
||||
else {
|
||||
$context['finished'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_finished().
|
||||
*
|
||||
* Finishes the module batch, redirect to the uninstall page and output the
|
||||
* successful data deletion message.
|
||||
*/
|
||||
public static function moduleBatchFinished($success, $results, $operations) {
|
||||
$entity_type_plural = \Drupal::entityTypeManager()->getDefinition($results['entity_type_id'])->getPluralLabel();
|
||||
drupal_set_message(t('All @entity_type_plural have been deleted.', ['@entity_type_plural' => $entity_type_plural]));
|
||||
|
||||
return new RedirectResponse(Url::fromRoute('system.modules_uninstall')->setAbsolute()->toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -67,76 +67,76 @@ class RegionalForm extends ConfigFormBase {
|
||||
// Date settings:
|
||||
$zones = system_time_zones();
|
||||
|
||||
$form['locale'] = array(
|
||||
$form['locale'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Locale'),
|
||||
'#open' => TRUE,
|
||||
);
|
||||
];
|
||||
|
||||
$form['locale']['site_default_country'] = array(
|
||||
$form['locale']['site_default_country'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Default country'),
|
||||
'#empty_value' => '',
|
||||
'#default_value' => $system_date->get('country.default'),
|
||||
'#options' => $countries,
|
||||
'#attributes' => array('class' => array('country-detect')),
|
||||
);
|
||||
'#attributes' => ['class' => ['country-detect']],
|
||||
];
|
||||
|
||||
$form['locale']['date_first_day'] = array(
|
||||
$form['locale']['date_first_day'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('First day of week'),
|
||||
'#default_value' => $system_date->get('first_day'),
|
||||
'#options' => array(0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')),
|
||||
);
|
||||
'#options' => [0 => t('Sunday'), 1 => t('Monday'), 2 => t('Tuesday'), 3 => t('Wednesday'), 4 => t('Thursday'), 5 => t('Friday'), 6 => t('Saturday')],
|
||||
];
|
||||
|
||||
$form['timezone'] = array(
|
||||
$form['timezone'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Time zones'),
|
||||
'#open' => TRUE,
|
||||
);
|
||||
];
|
||||
|
||||
$form['timezone']['date_default_timezone'] = array(
|
||||
$form['timezone']['date_default_timezone'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Default time zone'),
|
||||
'#default_value' => $system_date->get('timezone.default') ?: date_default_timezone_get(),
|
||||
'#options' => $zones,
|
||||
);
|
||||
];
|
||||
|
||||
$configurable_timezones = $system_date->get('timezone.user.configurable');
|
||||
$form['timezone']['configurable_timezones'] = array(
|
||||
$form['timezone']['configurable_timezones'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Users may set their own time zone'),
|
||||
'#default_value' => $configurable_timezones,
|
||||
);
|
||||
];
|
||||
|
||||
$form['timezone']['configurable_timezones_wrapper'] = array(
|
||||
$form['timezone']['configurable_timezones_wrapper'] = [
|
||||
'#type' => 'container',
|
||||
'#states' => array(
|
||||
'#states' => [
|
||||
// Hide the user configured timezone settings when users are forced to use
|
||||
// the default setting.
|
||||
'invisible' => array(
|
||||
'input[name="configurable_timezones"]' => array('checked' => FALSE),
|
||||
),
|
||||
),
|
||||
);
|
||||
$form['timezone']['configurable_timezones_wrapper']['empty_timezone_message'] = array(
|
||||
'invisible' => [
|
||||
'input[name="configurable_timezones"]' => ['checked' => FALSE],
|
||||
],
|
||||
],
|
||||
];
|
||||
$form['timezone']['configurable_timezones_wrapper']['empty_timezone_message'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Remind users at login if their time zone is not set'),
|
||||
'#default_value' => $system_date->get('timezone.user.warn'),
|
||||
'#description' => t('Only applied if users may set their own time zone.')
|
||||
);
|
||||
];
|
||||
|
||||
$form['timezone']['configurable_timezones_wrapper']['user_default_timezone'] = array(
|
||||
$form['timezone']['configurable_timezones_wrapper']['user_default_timezone'] = [
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Time zone for new users'),
|
||||
'#default_value' => $system_date->get('timezone.user.default'),
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
DRUPAL_USER_TIMEZONE_DEFAULT => t('Default time zone'),
|
||||
DRUPAL_USER_TIMEZONE_EMPTY => t('Empty time zone'),
|
||||
DRUPAL_USER_TIMEZONE_SELECT => t('Users may set their own time zone at registration'),
|
||||
),
|
||||
],
|
||||
'#description' => t('Only applied if users may set their own time zone.')
|
||||
);
|
||||
];
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
}
|
||||
|
||||
@@ -29,31 +29,31 @@ class RssFeedsForm extends ConfigFormBase {
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$rss_config = $this->config('system.rss');
|
||||
$form['feed_description'] = array(
|
||||
$form['feed_description'] = [
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Feed description'),
|
||||
'#default_value' => $rss_config->get('channel.description'),
|
||||
'#description' => t('Description of your site, included in each feed.')
|
||||
);
|
||||
$options = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30);
|
||||
$form['feed_default_items'] = array(
|
||||
];
|
||||
$options = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30];
|
||||
$form['feed_default_items'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Number of items in each feed'),
|
||||
'#default_value' => $rss_config->get('items.limit'),
|
||||
'#options' => array_combine($options, $options),
|
||||
'#description' => t('Default number of items to include in each feed.')
|
||||
);
|
||||
$form['feed_view_mode'] = array(
|
||||
];
|
||||
$form['feed_view_mode'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => t('Feed content'),
|
||||
'#default_value' => $rss_config->get('items.view_mode'),
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
'title' => t('Titles only'),
|
||||
'teaser' => t('Titles plus teaser'),
|
||||
'fulltext' => t('Full text'),
|
||||
),
|
||||
],
|
||||
'#description' => t('Global setting for the default display of content items in each feed.')
|
||||
);
|
||||
];
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
}
|
||||
|
||||
@@ -92,63 +92,63 @@ class SiteInformationForm extends ConfigFormBase {
|
||||
$site_mail = ini_get('sendmail_from');
|
||||
}
|
||||
|
||||
$form['site_information'] = array(
|
||||
$form['site_information'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Site details'),
|
||||
'#open' => TRUE,
|
||||
);
|
||||
$form['site_information']['site_name'] = array(
|
||||
];
|
||||
$form['site_information']['site_name'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Site name'),
|
||||
'#default_value' => $site_config->get('name'),
|
||||
'#required' => TRUE,
|
||||
);
|
||||
$form['site_information']['site_slogan'] = array(
|
||||
];
|
||||
$form['site_information']['site_slogan'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Slogan'),
|
||||
'#default_value' => $site_config->get('slogan'),
|
||||
'#description' => t("How this is used depends on your site's theme."),
|
||||
);
|
||||
$form['site_information']['site_mail'] = array(
|
||||
];
|
||||
$form['site_information']['site_mail'] = [
|
||||
'#type' => 'email',
|
||||
'#title' => t('Email address'),
|
||||
'#default_value' => $site_mail,
|
||||
'#description' => t("The <em>From</em> address in automated emails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this email being flagged as spam.)"),
|
||||
'#required' => TRUE,
|
||||
);
|
||||
$form['front_page'] = array(
|
||||
];
|
||||
$form['front_page'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Front page'),
|
||||
'#open' => TRUE,
|
||||
);
|
||||
];
|
||||
$front_page = $site_config->get('page.front') != '/user/login' ? $this->aliasManager->getAliasByPath($site_config->get('page.front')) : '';
|
||||
$form['front_page']['site_frontpage'] = array(
|
||||
$form['front_page']['site_frontpage'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Default front page'),
|
||||
'#default_value' => $front_page,
|
||||
'#size' => 40,
|
||||
'#description' => t('Optionally, specify a relative URL to display as the front page. Leave blank to display the default front page.'),
|
||||
'#field_prefix' => $this->requestContext->getCompleteBaseUrl(),
|
||||
);
|
||||
$form['error_page'] = array(
|
||||
];
|
||||
$form['error_page'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Error pages'),
|
||||
'#open' => TRUE,
|
||||
);
|
||||
$form['error_page']['site_403'] = array(
|
||||
];
|
||||
$form['error_page']['site_403'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Default 403 (access denied) page'),
|
||||
'#default_value' => $site_config->get('page.403'),
|
||||
'#size' => 40,
|
||||
'#description' => t('This page is displayed when the requested document is denied to the current user. Leave blank to display a generic "access denied" page.'),
|
||||
);
|
||||
$form['error_page']['site_404'] = array(
|
||||
];
|
||||
$form['error_page']['site_404'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Default 404 (not found) page'),
|
||||
'#default_value' => $site_config->get('page.404'),
|
||||
'#size' => 40,
|
||||
'#description' => t('This page is displayed when no other content matches the requested document. Leave blank to display a generic "page not found" page.'),
|
||||
);
|
||||
];
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ class SiteInformationForm extends ConfigFormBase {
|
||||
|
||||
}
|
||||
if (!$this->pathValidator->isValid($form_state->getValue('site_frontpage'))) {
|
||||
$form_state->setErrorByName('site_frontpage', $this->t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state->getValue('site_frontpage'))));
|
||||
$form_state->setErrorByName('site_frontpage', $this->t("The path '%path' is either invalid or you do not have access to it.", ['%path' => $form_state->getValue('site_frontpage')]));
|
||||
}
|
||||
// Get the normal paths of both error pages.
|
||||
if (!$form_state->isValueEmpty('site_403')) {
|
||||
@@ -189,11 +189,11 @@ class SiteInformationForm extends ConfigFormBase {
|
||||
}
|
||||
// Validate 403 error path.
|
||||
if (!$form_state->isValueEmpty('site_403') && !$this->pathValidator->isValid($form_state->getValue('site_403'))) {
|
||||
$form_state->setErrorByName('site_403', $this->t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state->getValue('site_403'))));
|
||||
$form_state->setErrorByName('site_403', $this->t("The path '%path' is either invalid or you do not have access to it.", ['%path' => $form_state->getValue('site_403')]));
|
||||
}
|
||||
// Validate 404 error path.
|
||||
if (!$form_state->isValueEmpty('site_404') && !$this->pathValidator->isValid($form_state->getValue('site_404'))) {
|
||||
$form_state->setErrorByName('site_404', $this->t("The path '%path' is either invalid or you do not have access to it.", array('%path' => $form_state->getValue('site_404'))));
|
||||
$form_state->setErrorByName('site_404', $this->t("The path '%path' is either invalid or you do not have access to it.", ['%path' => $form_state->getValue('site_404')]));
|
||||
}
|
||||
|
||||
parent::validateForm($form, $form_state);
|
||||
|
||||
@@ -6,6 +6,7 @@ use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\Core\Form\ConfigFormBase;
|
||||
use Drupal\user\PermissionHandlerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
@@ -20,6 +21,13 @@ class SiteMaintenanceModeForm extends ConfigFormBase {
|
||||
*/
|
||||
protected $state;
|
||||
|
||||
/**
|
||||
* The permission handler.
|
||||
*
|
||||
* @var \Drupal\user\PermissionHandlerInterface
|
||||
*/
|
||||
protected $permissionHandler;
|
||||
|
||||
/**
|
||||
* Constructs a new SiteMaintenanceModeForm.
|
||||
*
|
||||
@@ -27,10 +35,13 @@ class SiteMaintenanceModeForm extends ConfigFormBase {
|
||||
* The factory for configuration objects.
|
||||
* @param \Drupal\Core\State\StateInterface $state
|
||||
* The state keyvalue collection to use.
|
||||
* @param \Drupal\user\PermissionHandlerInterface $permission_handler
|
||||
* The permission handler.
|
||||
*/
|
||||
public function __construct(ConfigFactoryInterface $config_factory, StateInterface $state) {
|
||||
public function __construct(ConfigFactoryInterface $config_factory, StateInterface $state, PermissionHandlerInterface $permission_handler) {
|
||||
parent::__construct($config_factory);
|
||||
$this->state = $state;
|
||||
$this->permissionHandler = $permission_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,7 +50,8 @@ class SiteMaintenanceModeForm extends ConfigFormBase {
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('config.factory'),
|
||||
$container->get('state')
|
||||
$container->get('state'),
|
||||
$container->get('user.permissions')
|
||||
);
|
||||
}
|
||||
/**
|
||||
@@ -61,17 +73,19 @@ class SiteMaintenanceModeForm extends ConfigFormBase {
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$config = $this->config('system.maintenance');
|
||||
$form['maintenance_mode'] = array(
|
||||
$permissions = $this->permissionHandler->getPermissions();
|
||||
$permission_label = $permissions['access site in maintenance mode']['title'];
|
||||
$form['maintenance_mode'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Put site into maintenance mode'),
|
||||
'#default_value' => $this->state->get('system.maintenance_mode'),
|
||||
'#description' => t('Visitors will only see the maintenance mode message. Only users with the "Access site in maintenance mode" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', array(':permissions-url' => $this->url('user.admin_permissions'), ':user-login' => $this->url('user.login'))),
|
||||
);
|
||||
$form['maintenance_mode_message'] = array(
|
||||
'#description' => t('Visitors will only see the maintenance mode message. Only users with the "@permission-label" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', ['@permission-label' => $permission_label, ':permissions-url' => $this->url('user.admin_permissions'), ':user-login' => $this->url('user.login')]),
|
||||
];
|
||||
$form['maintenance_mode_message'] = [
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Message to display when in maintenance mode'),
|
||||
'#default_value' => $config->get('message'),
|
||||
);
|
||||
];
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
}
|
||||
|
||||
@@ -29,24 +29,24 @@ class ThemeAdminForm extends ConfigFormBase {
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state, array $theme_options = NULL) {
|
||||
// Administration theme settings.
|
||||
$form['admin_theme'] = array(
|
||||
$form['admin_theme'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Administration theme'),
|
||||
'#open' => TRUE,
|
||||
);
|
||||
$form['admin_theme']['admin_theme'] = array(
|
||||
];
|
||||
$form['admin_theme']['admin_theme'] = [
|
||||
'#type' => 'select',
|
||||
'#options' => array(0 => $this->t('Default theme')) + $theme_options,
|
||||
'#options' => [0 => $this->t('Default theme')] + $theme_options,
|
||||
'#title' => $this->t('Administration theme'),
|
||||
'#description' => $this->t('Choose "Default theme" to always use the same theme as the rest of the site.'),
|
||||
'#default_value' => $this->config('system.theme')->get('admin'),
|
||||
);
|
||||
$form['admin_theme']['actions'] = array('#type' => 'actions');
|
||||
$form['admin_theme']['actions']['submit'] = array(
|
||||
];
|
||||
$form['admin_theme']['actions'] = ['#type' => 'actions'];
|
||||
$form['admin_theme']['actions']['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Save configuration'),
|
||||
'#button_type' => 'primary',
|
||||
);
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Form\ConfigFormBase;
|
||||
use Drupal\Core\Theme\ThemeManagerInterface;
|
||||
|
||||
/**
|
||||
* Displays theme configuration for entire site and individual themes.
|
||||
@@ -46,6 +47,13 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
*/
|
||||
protected $editableConfig = [];
|
||||
|
||||
/**
|
||||
* The theme manager.
|
||||
*
|
||||
* @var \Drupal\Core\Theme\ThemeManagerInterface
|
||||
*/
|
||||
protected $themeManager;
|
||||
|
||||
/**
|
||||
* Constructs a ThemeSettingsForm object.
|
||||
*
|
||||
@@ -58,12 +66,13 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
* @param \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface $mime_type_guesser
|
||||
* The MIME type guesser instance to use.
|
||||
*/
|
||||
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, MimeTypeGuesserInterface $mime_type_guesser) {
|
||||
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler, MimeTypeGuesserInterface $mime_type_guesser, ThemeManagerInterface $theme_manager) {
|
||||
parent::__construct($config_factory);
|
||||
|
||||
$this->moduleHandler = $module_handler;
|
||||
$this->themeHandler = $theme_handler;
|
||||
$this->mimeTypeGuesser = $mime_type_guesser;
|
||||
$this->themeManager = $theme_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +83,8 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
$container->get('config.factory'),
|
||||
$container->get('module_handler'),
|
||||
$container->get('theme_handler'),
|
||||
$container->get('file.mime_type.guesser')
|
||||
$container->get('file.mime_type.guesser'),
|
||||
$container->get('theme.manager')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -122,25 +132,25 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
// by https://www.drupal.org/node/2402467.
|
||||
$this->editableConfig = [$config_key];
|
||||
|
||||
$form['var'] = array(
|
||||
$form['var'] = [
|
||||
'#type' => 'hidden',
|
||||
'#value' => $var
|
||||
);
|
||||
$form['config_key'] = array(
|
||||
];
|
||||
$form['config_key'] = [
|
||||
'#type' => 'hidden',
|
||||
'#value' => $config_key
|
||||
);
|
||||
];
|
||||
|
||||
// Toggle settings
|
||||
$toggles = array(
|
||||
$toggles = [
|
||||
'node_user_picture' => t('User pictures in posts'),
|
||||
'comment_user_picture' => t('User pictures in comments'),
|
||||
'comment_user_verification' => t('User verification status in comments'),
|
||||
'favicon' => t('Shortcut icon'),
|
||||
);
|
||||
];
|
||||
|
||||
// Some features are not always available
|
||||
$disabled = array();
|
||||
$disabled = [];
|
||||
if (!user_picture_enabled()) {
|
||||
$disabled['toggle_node_user_picture'] = TRUE;
|
||||
$disabled['toggle_comment_user_picture'] = TRUE;
|
||||
@@ -150,15 +160,14 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
$disabled['toggle_comment_user_verification'] = TRUE;
|
||||
}
|
||||
|
||||
$form['theme_settings'] = array(
|
||||
$form['theme_settings'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Toggle display'),
|
||||
'#title' => t('Page element display'),
|
||||
'#open' => TRUE,
|
||||
'#description' => t('Enable or disable the display of certain page elements.'),
|
||||
);
|
||||
];
|
||||
foreach ($toggles as $name => $title) {
|
||||
if ((!$theme) || in_array($name, $features)) {
|
||||
$form['theme_settings']['toggle_' . $name] = array('#type' => 'checkbox', '#title' => $title, '#default_value' => theme_get_setting('features.' . $name, $theme));
|
||||
$form['theme_settings']['toggle_' . $name] = ['#type' => 'checkbox', '#title' => $title, '#default_value' => theme_get_setting('features.' . $name, $theme)];
|
||||
// Disable checkboxes for features not supported in the current configuration.
|
||||
if (isset($disabled['toggle_' . $name])) {
|
||||
$form['theme_settings']['toggle_' . $name]['#disabled'] = TRUE;
|
||||
@@ -174,82 +183,82 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
|
||||
// Logo settings, only available when file.module is enabled.
|
||||
if ((!$theme || in_array('logo', $features)) && $this->moduleHandler->moduleExists('file')) {
|
||||
$form['logo'] = array(
|
||||
$form['logo'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Logo image settings'),
|
||||
'#title' => t('Logo image'),
|
||||
'#open' => TRUE,
|
||||
);
|
||||
$form['logo']['default_logo'] = array(
|
||||
];
|
||||
$form['logo']['default_logo'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use the default logo supplied by the theme'),
|
||||
'#title' => t('Use the logo supplied by the theme'),
|
||||
'#default_value' => theme_get_setting('logo.use_default', $theme),
|
||||
'#tree' => FALSE,
|
||||
);
|
||||
$form['logo']['settings'] = array(
|
||||
];
|
||||
$form['logo']['settings'] = [
|
||||
'#type' => 'container',
|
||||
'#states' => array(
|
||||
'#states' => [
|
||||
// Hide the logo settings when using the default logo.
|
||||
'invisible' => array(
|
||||
'input[name="default_logo"]' => array('checked' => TRUE),
|
||||
),
|
||||
),
|
||||
);
|
||||
$form['logo']['settings']['logo_path'] = array(
|
||||
'invisible' => [
|
||||
'input[name="default_logo"]' => ['checked' => TRUE],
|
||||
],
|
||||
],
|
||||
];
|
||||
$form['logo']['settings']['logo_path'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Path to custom logo'),
|
||||
'#default_value' => theme_get_setting('logo.path', $theme),
|
||||
);
|
||||
$form['logo']['settings']['logo_upload'] = array(
|
||||
];
|
||||
$form['logo']['settings']['logo_upload'] = [
|
||||
'#type' => 'file',
|
||||
'#title' => t('Upload logo image'),
|
||||
'#maxlength' => 40,
|
||||
'#description' => t("If you don't have direct file access to the server, use this field to upload your logo.")
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if (((!$theme) || in_array('favicon', $features)) && $this->moduleHandler->moduleExists('file')) {
|
||||
$form['favicon'] = array(
|
||||
$form['favicon'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Shortcut icon settings'),
|
||||
'#title' => t('Favicon'),
|
||||
'#open' => TRUE,
|
||||
'#description' => t("Your shortcut icon, or 'favicon', is displayed in the address bar and bookmarks of most browsers."),
|
||||
'#states' => array(
|
||||
'#description' => t("Your shortcut icon, or favicon, is displayed in the address bar and bookmarks of most browsers."),
|
||||
'#states' => [
|
||||
// Hide the shortcut icon settings fieldset when shortcut icon display
|
||||
// is disabled.
|
||||
'invisible' => array(
|
||||
'input[name="toggle_favicon"]' => array('checked' => FALSE),
|
||||
),
|
||||
),
|
||||
);
|
||||
$form['favicon']['default_favicon'] = array(
|
||||
'invisible' => [
|
||||
'input[name="toggle_favicon"]' => ['checked' => FALSE],
|
||||
],
|
||||
],
|
||||
];
|
||||
$form['favicon']['default_favicon'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use the default shortcut icon supplied by the theme'),
|
||||
'#title' => t('Use the favicon supplied by the theme'),
|
||||
'#default_value' => theme_get_setting('favicon.use_default', $theme),
|
||||
);
|
||||
$form['favicon']['settings'] = array(
|
||||
];
|
||||
$form['favicon']['settings'] = [
|
||||
'#type' => 'container',
|
||||
'#states' => array(
|
||||
'#states' => [
|
||||
// Hide the favicon settings when using the default favicon.
|
||||
'invisible' => array(
|
||||
'input[name="default_favicon"]' => array('checked' => TRUE),
|
||||
),
|
||||
),
|
||||
);
|
||||
$form['favicon']['settings']['favicon_path'] = array(
|
||||
'invisible' => [
|
||||
'input[name="default_favicon"]' => ['checked' => TRUE],
|
||||
],
|
||||
],
|
||||
];
|
||||
$form['favicon']['settings']['favicon_path'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Path to custom icon'),
|
||||
'#default_value' => theme_get_setting('favicon.path', $theme),
|
||||
);
|
||||
$form['favicon']['settings']['favicon_upload'] = array(
|
||||
];
|
||||
$form['favicon']['settings']['favicon_upload'] = [
|
||||
'#type' => 'file',
|
||||
'#title' => t('Upload icon image'),
|
||||
'#title' => t('Upload favicon image'),
|
||||
'#description' => t("If you don't have direct file access to the server, use this field to upload your shortcut icon.")
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// Inject human-friendly values and form element descriptions for logo and
|
||||
// favicon.
|
||||
foreach (array('logo' => 'logo.svg', 'favicon' => 'favicon.ico') as $type => $default) {
|
||||
foreach (['logo' => 'logo.svg', 'favicon' => 'favicon.ico'] as $type => $default) {
|
||||
if (isset($form[$type]['settings'][$type . '_path'])) {
|
||||
$element = &$form[$type]['settings'][$type . '_path'];
|
||||
|
||||
@@ -264,20 +273,20 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
|
||||
// Prepare local file path for description.
|
||||
if ($original_path && isset($friendly_path)) {
|
||||
$local_file = strtr($original_path, array('public:/' => PublicStream::basePath()));
|
||||
$local_file = strtr($original_path, ['public:/' => PublicStream::basePath()]);
|
||||
}
|
||||
elseif ($theme) {
|
||||
$local_file = drupal_get_path('theme', $theme) . '/' . $default;
|
||||
}
|
||||
else {
|
||||
$local_file = \Drupal::theme()->getActiveTheme()->getPath() . '/' . $default;
|
||||
$local_file = $this->themeManager->getActiveTheme()->getPath() . '/' . $default;
|
||||
}
|
||||
|
||||
$element['#description'] = t('Examples: <code>@implicit-public-file</code> (for a file in the public filesystem), <code>@explicit-file</code>, or <code>@local-file</code>.', array(
|
||||
$element['#description'] = t('Examples: <code>@implicit-public-file</code> (for a file in the public filesystem), <code>@explicit-file</code>, or <code>@local-file</code>.', [
|
||||
'@implicit-public-file' => isset($friendly_path) ? $friendly_path : $default,
|
||||
'@explicit-file' => file_uri_scheme($original_path) !== FALSE ? $original_path : 'public://' . $default,
|
||||
'@local-file' => $local_file,
|
||||
));
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,12 +294,12 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
// Call engine-specific settings.
|
||||
$function = $themes[$theme]->prefix . '_engine_settings';
|
||||
if (function_exists($function)) {
|
||||
$form['engine_specific'] = array(
|
||||
$form['engine_specific'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Theme-engine-specific settings'),
|
||||
'#open' => TRUE,
|
||||
'#description' => t('These settings only exist for the themes based on the %engine theme engine.', array('%engine' => $themes[$theme]->prefix)),
|
||||
);
|
||||
'#description' => t('These settings only exist for the themes based on the %engine theme engine.', ['%engine' => $themes[$theme]->prefix]),
|
||||
];
|
||||
$function($form, $form_state);
|
||||
}
|
||||
|
||||
@@ -300,17 +309,17 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
$theme_keys[] = $theme;
|
||||
}
|
||||
else {
|
||||
$theme_keys = array($theme);
|
||||
$theme_keys = [$theme];
|
||||
}
|
||||
|
||||
// Save the name of the current theme (if any), so that we can temporarily
|
||||
// override the current theme and allow theme_get_setting() to work
|
||||
// without having to pass the theme name to it.
|
||||
$default_active_theme = \Drupal::theme()->getActiveTheme();
|
||||
$default_active_theme = $this->themeManager->getActiveTheme();
|
||||
$default_theme = $default_active_theme->getName();
|
||||
/** @var \Drupal\Core\Theme\ThemeInitialization $theme_initialization */
|
||||
$theme_initialization = \Drupal::service('theme.initialization');
|
||||
\Drupal::theme()->setActiveTheme($theme_initialization->getActiveThemeByName($theme));
|
||||
$this->themeManager->setActiveTheme($theme_initialization->getActiveThemeByName($theme));
|
||||
|
||||
// Process the theme and all its base themes.
|
||||
foreach ($theme_keys as $theme) {
|
||||
@@ -329,10 +338,10 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
|
||||
// Restore the original current theme.
|
||||
if (isset($default_theme)) {
|
||||
\Drupal::theme()->setActiveTheme($default_active_theme);
|
||||
$this->themeManager->setActiveTheme($default_active_theme);
|
||||
}
|
||||
else {
|
||||
\Drupal::theme()->resetActiveTheme();
|
||||
$this->themeManager->resetActiveTheme();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,7 +356,7 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
|
||||
if ($this->moduleHandler->moduleExists('file')) {
|
||||
// Handle file uploads.
|
||||
$validators = array('file_validate_is_image' => array());
|
||||
$validators = ['file_validate_is_image' => []];
|
||||
|
||||
// Check for a new uploaded logo.
|
||||
$file = file_save_upload('logo_upload', $validators, FALSE, 0);
|
||||
@@ -363,7 +372,7 @@ class ThemeSettingsForm extends ConfigFormBase {
|
||||
}
|
||||
}
|
||||
|
||||
$validators = array('file_validate_extensions' => array('ico png gif jpg jpeg apng svg'));
|
||||
$validators = ['file_validate_extensions' => ['ico png gif jpg jpeg apng svg']];
|
||||
|
||||
// Check for a new uploaded favicon.
|
||||
$file = file_save_upload('favicon_upload', $validators, FALSE, 0);
|
||||
|
||||
@@ -4,9 +4,11 @@ namespace Drupal\system;
|
||||
|
||||
use Drupal\Component\Transliteration\TransliterationInterface;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Access\CsrfTokenGenerator;
|
||||
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
@@ -21,14 +23,24 @@ class MachineNameController implements ContainerInjectionInterface {
|
||||
*/
|
||||
protected $transliteration;
|
||||
|
||||
/**
|
||||
* The token generator.
|
||||
*
|
||||
* @var \Drupal\Core\Access\CsrfTokenGenerator
|
||||
*/
|
||||
protected $tokenGenerator;
|
||||
|
||||
/**
|
||||
* Constructs a MachineNameController object.
|
||||
*
|
||||
* @param \Drupal\Component\Transliteration\TransliterationInterface $transliteration
|
||||
* The transliteration helper.
|
||||
* @param \Drupal\Core\Access\CsrfTokenGenerator $token_generator
|
||||
* The token generator.
|
||||
*/
|
||||
public function __construct(TransliterationInterface $transliteration) {
|
||||
public function __construct(TransliterationInterface $transliteration, CsrfTokenGenerator $token_generator) {
|
||||
$this->transliteration = $transliteration;
|
||||
$this->tokenGenerator = $token_generator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +48,8 @@ class MachineNameController implements ContainerInjectionInterface {
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('transliteration')
|
||||
$container->get('transliteration'),
|
||||
$container->get('csrf_token')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -54,6 +67,7 @@ class MachineNameController implements ContainerInjectionInterface {
|
||||
$text = $request->query->get('text');
|
||||
$langcode = $request->query->get('langcode');
|
||||
$replace_pattern = $request->query->get('replace_pattern');
|
||||
$replace_token = $request->query->get('replace_token');
|
||||
$replace = $request->query->get('replace');
|
||||
$lowercase = $request->query->get('lowercase');
|
||||
|
||||
@@ -61,7 +75,15 @@ class MachineNameController implements ContainerInjectionInterface {
|
||||
if ($lowercase) {
|
||||
$transliterated = Unicode::strtolower($transliterated);
|
||||
}
|
||||
|
||||
if (isset($replace_pattern) && isset($replace)) {
|
||||
if (!isset($replace_token)) {
|
||||
throw new AccessDeniedHttpException("Missing 'replace_token' query parameter.");
|
||||
}
|
||||
elseif (!$this->tokenGenerator->validate($replace_token, $replace_pattern)) {
|
||||
throw new AccessDeniedHttpException("Invalid 'replace_token' query parameter.");
|
||||
}
|
||||
|
||||
// Quote the pattern delimiter and remove null characters to avoid the e
|
||||
// or other modifiers being injected.
|
||||
$transliterated = preg_replace('@' . strtr($replace_pattern, ['@' => '\@', chr(0) => '']) . '@', $replace, $transliterated);
|
||||
|
||||
@@ -52,7 +52,7 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
||||
protected $router;
|
||||
|
||||
/**
|
||||
* The dynamic router service.
|
||||
* The inbound path processor.
|
||||
*
|
||||
* @var \Drupal\Core\PathProcessor\InboundPathProcessorInterface
|
||||
*/
|
||||
@@ -122,14 +122,14 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
||||
*/
|
||||
public function build(RouteMatchInterface $route_match) {
|
||||
$breadcrumb = new Breadcrumb();
|
||||
$links = array();
|
||||
$links = [];
|
||||
|
||||
// General path-based breadcrumbs. Use the actual request path, prior to
|
||||
// resolving path aliases, so the breadcrumb can be defined by simply
|
||||
// creating a hierarchy of path aliases.
|
||||
$path = trim($this->context->getPathInfo(), '/');
|
||||
$path_elements = explode('/', $path);
|
||||
$exclude = array();
|
||||
$exclude = [];
|
||||
// Don't show a link to the front-page path.
|
||||
$front = $this->config->get('page.front');
|
||||
$exclude[$front] = TRUE;
|
||||
@@ -154,7 +154,7 @@ class PathBasedBreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
||||
if (!isset($title)) {
|
||||
// Fallback to using the raw path component as the title if the
|
||||
// route is missing a _title or _title_callback attribute.
|
||||
$title = str_replace(array('-', '_'), ' ', Unicode::ucfirst(end($path_elements)));
|
||||
$title = str_replace(['-', '_'], ' ', Unicode::ucfirst(end($path_elements)));
|
||||
}
|
||||
$url = Url::fromRouteMatch($route_match);
|
||||
$links[] = new Link($title, $url);
|
||||
|
||||
@@ -60,12 +60,12 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
return [
|
||||
'use_site_logo' => TRUE,
|
||||
'use_site_name' => TRUE,
|
||||
'use_site_slogan' => TRUE,
|
||||
'label_display' => FALSE,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,15 +77,15 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
|
||||
|
||||
// Get permissions.
|
||||
$url_system_theme_settings = new Url('system.theme_settings');
|
||||
$url_system_theme_settings_theme = new Url('system.theme_settings_theme', array('theme' => $theme));
|
||||
$url_system_theme_settings_theme = new Url('system.theme_settings_theme', ['theme' => $theme]);
|
||||
|
||||
if ($url_system_theme_settings->access() && $url_system_theme_settings_theme->access()) {
|
||||
// Provide links to the Appearance Settings and Theme Settings pages
|
||||
// if the user has access to administer themes.
|
||||
$site_logo_description = $this->t('Defined on the <a href=":appearance">Appearance Settings</a> or <a href=":theme">Theme Settings</a> page.', array(
|
||||
$site_logo_description = $this->t('Defined on the <a href=":appearance">Appearance Settings</a> or <a href=":theme">Theme Settings</a> page.', [
|
||||
':appearance' => $url_system_theme_settings->toString(),
|
||||
':theme' => $url_system_theme_settings_theme->toString(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
else {
|
||||
// Explain that the user does not have access to the Appearance and Theme
|
||||
@@ -99,8 +99,8 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
|
||||
|
||||
// Provide link to Site Information page if the user has access to
|
||||
// administer site configuration.
|
||||
$site_name_description = $this->t('Defined on the <a href=":information">Site Information</a> page.', array(':information' => $site_information_url));
|
||||
$site_slogan_description = $this->t('Defined on the <a href=":information">Site Information</a> page.', array(':information' => $site_information_url));
|
||||
$site_name_description = $this->t('Defined on the <a href=":information">Site Information</a> page.', [':information' => $site_information_url]);
|
||||
$site_slogan_description = $this->t('Defined on the <a href=":information">Site Information</a> page.', [':information' => $site_information_url]);
|
||||
}
|
||||
else {
|
||||
// Explain that the user does not have access to the Site Information
|
||||
@@ -109,30 +109,30 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
|
||||
$site_slogan_description = $this->t('Defined on the Site Information page. You do not have the appropriate permissions to change the site logo.');
|
||||
}
|
||||
|
||||
$form['block_branding'] = array(
|
||||
$form['block_branding'] = [
|
||||
'#type' => 'fieldset',
|
||||
'#title' => $this->t('Toggle branding elements'),
|
||||
'#description' => $this->t('Choose which branding elements you want to show in this block instance.'),
|
||||
);
|
||||
$form['block_branding']['use_site_logo'] = array(
|
||||
];
|
||||
$form['block_branding']['use_site_logo'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Site logo'),
|
||||
'#description' => $site_logo_description,
|
||||
'#default_value' => $this->configuration['use_site_logo'],
|
||||
);
|
||||
];
|
||||
|
||||
$form['block_branding']['use_site_name'] = array(
|
||||
$form['block_branding']['use_site_name'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Site name'),
|
||||
'#description' => $site_name_description,
|
||||
'#default_value' => $this->configuration['use_site_name'],
|
||||
);
|
||||
$form['block_branding']['use_site_slogan'] = array(
|
||||
];
|
||||
$form['block_branding']['use_site_slogan'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Site slogan'),
|
||||
'#description' => $site_slogan_description,
|
||||
'#default_value' => $this->configuration['use_site_slogan'],
|
||||
);
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -150,25 +150,25 @@ class SystemBrandingBlock extends BlockBase implements ContainerFactoryPluginInt
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build() {
|
||||
$build = array();
|
||||
$build = [];
|
||||
$site_config = $this->configFactory->get('system.site');
|
||||
|
||||
$build['site_logo'] = array(
|
||||
$build['site_logo'] = [
|
||||
'#theme' => 'image',
|
||||
'#uri' => theme_get_setting('logo.url'),
|
||||
'#alt' => $this->t('Home'),
|
||||
'#access' => $this->configuration['use_site_logo'],
|
||||
);
|
||||
];
|
||||
|
||||
$build['site_name'] = array(
|
||||
$build['site_name'] = [
|
||||
'#markup' => $site_config->get('name'),
|
||||
'#access' => $this->configuration['use_site_name'],
|
||||
);
|
||||
];
|
||||
|
||||
$build['site_slogan'] = array(
|
||||
$build['site_slogan'] = [
|
||||
'#markup' => $site_config->get('slogan'),
|
||||
'#access' => $this->configuration['use_site_slogan'],
|
||||
);
|
||||
];
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
||||
@@ -76,36 +76,36 @@ class SystemMenuBlock extends BlockBase implements ContainerFactoryPluginInterfa
|
||||
$config = $this->configuration;
|
||||
|
||||
$defaults = $this->defaultConfiguration();
|
||||
$form['menu_levels'] = array(
|
||||
$form['menu_levels'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Menu levels'),
|
||||
// Open if not set to defaults.
|
||||
'#open' => $defaults['level'] !== $config['level'] || $defaults['depth'] !== $config['depth'],
|
||||
'#process' => [[get_class(), 'processMenuLevelParents']],
|
||||
);
|
||||
];
|
||||
|
||||
$options = range(0, $this->menuTree->maxDepth());
|
||||
unset($options[0]);
|
||||
|
||||
$form['menu_levels']['level'] = array(
|
||||
$form['menu_levels']['level'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Initial menu level'),
|
||||
'#title' => $this->t('Initial visibility level'),
|
||||
'#default_value' => $config['level'],
|
||||
'#options' => $options,
|
||||
'#description' => $this->t('The menu will only be visible if the menu item for the current page is at or below the selected starting level. Select level 1 to always keep this menu visible.'),
|
||||
'#description' => $this->t('The menu is only visible if the menu item for the current page is at this level or below it. Use level 1 to always display this menu.'),
|
||||
'#required' => TRUE,
|
||||
);
|
||||
];
|
||||
|
||||
$options[0] = $this->t('Unlimited');
|
||||
|
||||
$form['menu_levels']['depth'] = array(
|
||||
$form['menu_levels']['depth'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Maximum number of menu levels to display'),
|
||||
'#title' => $this->t('Number of levels to display'),
|
||||
'#default_value' => $config['depth'],
|
||||
'#options' => $options,
|
||||
'#description' => $this->t('The maximum number of menu levels to show, starting from the initial menu level. For example: with an initial level 2 and a maximum number of 3, menu levels 2, 3 and 4 can be displayed.'),
|
||||
'#description' => $this->t('This maximum number includes the initial level.'),
|
||||
'#required' => TRUE,
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -148,10 +148,10 @@ class SystemMenuBlock extends BlockBase implements ContainerFactoryPluginInterfa
|
||||
}
|
||||
|
||||
$tree = $this->menuTree->load($menu_name, $parameters);
|
||||
$manipulators = array(
|
||||
array('callable' => 'menu.default_tree_manipulators:checkAccess'),
|
||||
array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
|
||||
);
|
||||
$manipulators = [
|
||||
['callable' => 'menu.default_tree_manipulators:checkAccess'],
|
||||
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
|
||||
];
|
||||
$tree = $this->menuTree->transform($tree, $manipulators);
|
||||
return $this->menuTree->build($tree);
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ class SystemMessagesBlock extends BlockBase implements MessagesBlockPluginInterf
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
return [
|
||||
'label_display' => FALSE,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,7 @@ class SystemPoweredByBlock extends BlockBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build() {
|
||||
return array('#markup' => '<span>' . $this->t('Powered by <a href=":poweredby">Drupal</a>', array(':poweredby' => 'https://www.drupal.org')) . '</span>');
|
||||
return ['#markup' => '<span>' . $this->t('Powered by <a href=":poweredby">Drupal</a>', [':poweredby' => 'https://www.drupal.org']) . '</span>'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -70,21 +70,21 @@ class CurrentThemeCondition extends ConditionPluginBase implements ContainerFact
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array('theme' => '') + parent::defaultConfiguration();
|
||||
return ['theme' => ''] + parent::defaultConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
|
||||
$form['theme'] = array(
|
||||
$form['theme'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Theme'),
|
||||
'#default_value' => $this->configuration['theme'],
|
||||
'#options' => array_map(function ($theme_info) {
|
||||
return $theme_info->info['name'];
|
||||
}, $this->themeHandler->listInfo()),
|
||||
);
|
||||
];
|
||||
return parent::buildConfigurationForm($form, $form_state);
|
||||
}
|
||||
|
||||
@@ -112,10 +112,10 @@ class CurrentThemeCondition extends ConditionPluginBase implements ContainerFact
|
||||
*/
|
||||
public function summary() {
|
||||
if ($this->isNegated()) {
|
||||
return $this->t('The current theme is not @theme', array('@theme' => $this->configuration['theme']));
|
||||
return $this->t('The current theme is not @theme', ['@theme' => $this->configuration['theme']]);
|
||||
}
|
||||
|
||||
return $this->t('The current theme is @theme', array('@theme' => $this->configuration['theme']));
|
||||
return $this->t('The current theme is @theme', ['@theme' => $this->configuration['theme']]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -94,23 +94,22 @@ class RequestPath extends ConditionPluginBase implements ContainerFactoryPluginI
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array('pages' => '') + parent::defaultConfiguration();
|
||||
return ['pages' => ''] + parent::defaultConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
|
||||
$form['pages'] = array(
|
||||
$form['pages'] = [
|
||||
'#type' => 'textarea',
|
||||
'#title' => $this->t('Pages'),
|
||||
'#default_value' => $this->configuration['pages'],
|
||||
'#description' => $this->t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %user for the current user's page and %user-wildcard for every user page. %front is the front page.", array(
|
||||
'%user' => '/user',
|
||||
'#description' => $this->t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. An example path is %user-wildcard for every user page. %front is the front page.", [
|
||||
'%user-wildcard' => '/user/*',
|
||||
'%front' => '<front>',
|
||||
)),
|
||||
);
|
||||
]),
|
||||
];
|
||||
return parent::buildConfigurationForm($form, $form_state);
|
||||
}
|
||||
|
||||
@@ -129,9 +128,9 @@ class RequestPath extends ConditionPluginBase implements ContainerFactoryPluginI
|
||||
$pages = array_map('trim', explode("\n", $this->configuration['pages']));
|
||||
$pages = implode(', ', $pages);
|
||||
if (!empty($this->configuration['negate'])) {
|
||||
return $this->t('Do not return true on the following pages: @pages', array('@pages' => $pages));
|
||||
return $this->t('Do not return true on the following pages: @pages', ['@pages' => $pages]);
|
||||
}
|
||||
return $this->t('Return true on the following pages: @pages', array('@pages' => $pages));
|
||||
return $this->t('Return true on the following pages: @pages', ['@pages' => $pages]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,7 +47,7 @@ class SystemMenuBlock extends DeriverBase implements ContainerDeriverInterface {
|
||||
foreach ($this->menuStorage->loadMultiple() as $menu => $entity) {
|
||||
$this->derivatives[$menu] = $base_plugin_definition;
|
||||
$this->derivatives[$menu]['admin_label'] = $entity->label();
|
||||
$this->derivatives[$menu]['config_dependencies']['config'] = array($entity->getConfigDependencyName());
|
||||
$this->derivatives[$menu]['config_dependencies']['config'] = [$entity->getConfigDependencyName()];
|
||||
}
|
||||
return $this->derivatives;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class ThemeLocalTask extends DeriverBase implements ContainerDeriverInterface {
|
||||
if ($this->themeHandler->hasUi($theme_name)) {
|
||||
$this->derivatives[$theme_name] = $base_plugin_definition;
|
||||
$this->derivatives[$theme_name]['title'] = $theme->info['name'];
|
||||
$this->derivatives[$theme_name]['route_parameters'] = array('theme' => $theme_name);
|
||||
$this->derivatives[$theme_name]['route_parameters'] = ['theme' => $theme_name];
|
||||
}
|
||||
}
|
||||
return $this->derivatives;
|
||||
|
||||
@@ -143,7 +143,7 @@ class GDToolkit extends ImageToolkitBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
|
||||
$form['image_jpeg_quality'] = array(
|
||||
$form['image_jpeg_quality'] = [
|
||||
'#type' => 'number',
|
||||
'#title' => t('JPEG quality'),
|
||||
'#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files.'),
|
||||
@@ -151,7 +151,7 @@ class GDToolkit extends ImageToolkitBase {
|
||||
'#max' => 100,
|
||||
'#default_value' => $this->configFactory->getEditable('system.image.gd')->get('jpeg_quality', FALSE),
|
||||
'#field_suffix' => t('%'),
|
||||
);
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ class GDToolkit extends ImageToolkitBase {
|
||||
*/
|
||||
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->configFactory->getEditable('system.image.gd')
|
||||
->set('jpeg_quality', $form_state->getValue(array('gd', 'image_jpeg_quality')))
|
||||
->set('jpeg_quality', $form_state->getValue(['gd', 'image_jpeg_quality']))
|
||||
->save();
|
||||
}
|
||||
|
||||
@@ -186,13 +186,13 @@ class GDToolkit extends ImageToolkitBase {
|
||||
// Convert indexed images to truecolor, copying the image to a new
|
||||
// truecolor resource, so that filters work correctly and don't result
|
||||
// in unnecessary dither.
|
||||
$data = array(
|
||||
$data = [
|
||||
'width' => imagesx($resource),
|
||||
'height' => imagesy($resource),
|
||||
'extension' => image_type_to_extension($this->getType(), FALSE),
|
||||
'transparent_color' => $this->getTransparentColor(),
|
||||
'is_temp' => TRUE,
|
||||
);
|
||||
];
|
||||
if ($this->apply('create_new', $data)) {
|
||||
imagecopy($this->getResource(), $resource, 0, 0, 0, 0, imagesx($resource), imagesy($resource));
|
||||
imagedestroy($resource);
|
||||
@@ -362,13 +362,13 @@ class GDToolkit extends ImageToolkitBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRequirements() {
|
||||
$requirements = array();
|
||||
$requirements = [];
|
||||
|
||||
$info = gd_info();
|
||||
$requirements['version'] = array(
|
||||
$requirements['version'] = [
|
||||
'title' => t('GD library'),
|
||||
'value' => $info['GD Version'],
|
||||
);
|
||||
];
|
||||
|
||||
// Check for filter and rotate support.
|
||||
if (!function_exists('imagefilter') || !function_exists('imagerotate')) {
|
||||
@@ -391,7 +391,7 @@ class GDToolkit extends ImageToolkitBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSupportedExtensions() {
|
||||
$extensions = array();
|
||||
$extensions = [];
|
||||
foreach (static::supportedTypes() as $image_type) {
|
||||
// @todo Automatically fetch possible extensions for each mime type.
|
||||
// @see https://www.drupal.org/node/2311679
|
||||
@@ -440,7 +440,7 @@ class GDToolkit extends ImageToolkitBase {
|
||||
* IMAGETYPE_* constant (e.g. IMAGETYPE_JPEG, IMAGETYPE_PNG, etc.).
|
||||
*/
|
||||
protected static function supportedTypes() {
|
||||
return array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF);
|
||||
return [IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@ class Convert extends GDImageToolkitOperationBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function arguments() {
|
||||
return array(
|
||||
'extension' => array(
|
||||
return [
|
||||
'extension' => [
|
||||
'description' => 'The new extension of the converted image',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -47,13 +47,13 @@ class Convert extends GDImageToolkitOperationBase {
|
||||
$height = $this->getToolkit()->getHeight();
|
||||
$original_resource = $this->getToolkit()->getResource();
|
||||
$original_type = $this->getToolkit()->getType();
|
||||
$data = array(
|
||||
$data = [
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'extension' => $arguments['extension'],
|
||||
'transparent_color' => $this->getToolkit()->getTransparentColor(),
|
||||
'is_temp' => TRUE,
|
||||
);
|
||||
];
|
||||
if ($this->getToolkit()->apply('create_new', $data)) {
|
||||
if (imagecopyresampled($this->getToolkit()->getResource(), $original_resource, 0, 0, 0, 0, $width, $height, $width, $height)) {
|
||||
imagedestroy($original_resource);
|
||||
|
||||
@@ -21,29 +21,29 @@ class CreateNew extends GDImageToolkitOperationBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function arguments() {
|
||||
return array(
|
||||
'width' => array(
|
||||
return [
|
||||
'width' => [
|
||||
'description' => 'The width of the image, in pixels',
|
||||
),
|
||||
'height' => array(
|
||||
],
|
||||
'height' => [
|
||||
'description' => 'The height of the image, in pixels',
|
||||
),
|
||||
'extension' => array(
|
||||
],
|
||||
'extension' => [
|
||||
'description' => 'The extension of the image file (e.g. png, gif, etc.)',
|
||||
'required' => FALSE,
|
||||
'default' => 'png',
|
||||
),
|
||||
'transparent_color' => array(
|
||||
],
|
||||
'transparent_color' => [
|
||||
'description' => 'The RGB hex color for GIF transparency',
|
||||
'required' => FALSE,
|
||||
'default' => '#ffffff',
|
||||
),
|
||||
'is_temp' => array(
|
||||
],
|
||||
'is_temp' => [
|
||||
'description' => 'If TRUE, this operation is being used to create a temporary image by another GD operation. After performing its function, the caller is responsible for destroying the original GD resource.',
|
||||
'required' => FALSE,
|
||||
'default' => FALSE,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,24 +19,24 @@ class Crop extends GDImageToolkitOperationBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function arguments() {
|
||||
return array(
|
||||
'x' => array(
|
||||
return [
|
||||
'x' => [
|
||||
'description' => 'The starting x offset at which to start the crop, in pixels',
|
||||
),
|
||||
'y' => array(
|
||||
],
|
||||
'y' => [
|
||||
'description' => 'The starting y offset at which to start the crop, in pixels',
|
||||
),
|
||||
'width' => array(
|
||||
],
|
||||
'width' => [
|
||||
'description' => 'The width of the cropped area, in pixels',
|
||||
'required' => FALSE,
|
||||
'default' => NULL,
|
||||
),
|
||||
'height' => array(
|
||||
],
|
||||
'height' => [
|
||||
'description' => 'The height of the cropped area, in pixels',
|
||||
'required' => FALSE,
|
||||
'default' => NULL,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ class Crop extends GDImageToolkitOperationBase {
|
||||
$arguments['width'] = empty($arguments['width']) ? $arguments['height'] / $aspect : $arguments['width'];
|
||||
|
||||
// Assure integers for all arguments.
|
||||
foreach (array('x', 'y', 'width', 'height') as $key) {
|
||||
foreach (['x', 'y', 'width', 'height'] as $key) {
|
||||
$arguments[$key] = (int) round($arguments[$key]);
|
||||
}
|
||||
|
||||
@@ -77,13 +77,13 @@ class Crop extends GDImageToolkitOperationBase {
|
||||
// the original resource on it with resampling. Destroy the original
|
||||
// resource upon success.
|
||||
$original_resource = $this->getToolkit()->getResource();
|
||||
$data = array(
|
||||
$data = [
|
||||
'width' => $arguments['width'],
|
||||
'height' => $arguments['height'],
|
||||
'extension' => image_type_to_extension($this->getToolkit()->getType(), FALSE),
|
||||
'transparent_color' => $this->getToolkit()->getTransparentColor(),
|
||||
'is_temp' => TRUE,
|
||||
);
|
||||
];
|
||||
if ($this->getToolkit()->apply('create_new', $data)) {
|
||||
if (imagecopyresampled($this->getToolkit()->getResource(), $original_resource, 0, 0, $arguments['x'], $arguments['y'], $arguments['width'], $arguments['height'], $arguments['width'], $arguments['height'])) {
|
||||
imagedestroy($original_resource);
|
||||
|
||||
@@ -20,7 +20,7 @@ class Desaturate extends GDImageToolkitOperationBase {
|
||||
*/
|
||||
protected function arguments() {
|
||||
// This operation does not use any parameters.
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ class Desaturate extends GDImageToolkitOperationBase {
|
||||
protected function execute(array $arguments) {
|
||||
// PHP installations using non-bundled GD do not have imagefilter.
|
||||
if (!function_exists('imagefilter')) {
|
||||
$this->logger->notice("The image '@file' could not be desaturated because the imagefilter() function is not available in this PHP installation.", array('@file' => $this->getToolkit()->getSource()));
|
||||
$this->logger->notice("The image '@file' could not be desaturated because the imagefilter() function is not available in this PHP installation.", ['@file' => $this->getToolkit()->getSource()]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,14 +19,14 @@ class Resize extends GDImageToolkitOperationBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function arguments() {
|
||||
return array(
|
||||
'width' => array(
|
||||
return [
|
||||
'width' => [
|
||||
'description' => 'The new width of the resized image, in pixels',
|
||||
),
|
||||
'height' => array(
|
||||
],
|
||||
'height' => [
|
||||
'description' => 'The new height of the resized image, in pixels',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,18 +51,18 @@ class Resize extends GDImageToolkitOperationBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(array $arguments = array()) {
|
||||
protected function execute(array $arguments = []) {
|
||||
// Create a new resource of the required dimensions, and copy and resize
|
||||
// the original resource on it with resampling. Destroy the original
|
||||
// resource upon success.
|
||||
$original_resource = $this->getToolkit()->getResource();
|
||||
$data = array(
|
||||
$data = [
|
||||
'width' => $arguments['width'],
|
||||
'height' => $arguments['height'],
|
||||
'extension' => image_type_to_extension($this->getToolkit()->getType(), FALSE),
|
||||
'transparent_color' => $this->getToolkit()->getTransparentColor(),
|
||||
'is_temp' => TRUE,
|
||||
);
|
||||
];
|
||||
if ($this->getToolkit()->apply('create_new', $data)) {
|
||||
if (imagecopyresampled($this->getToolkit()->getResource(), $original_resource, 0, 0, 0, 0, $arguments['width'], $arguments['height'], imagesx($original_resource), imagesy($original_resource))) {
|
||||
imagedestroy($original_resource);
|
||||
|
||||
@@ -21,16 +21,16 @@ class Rotate extends GDImageToolkitOperationBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function arguments() {
|
||||
return array(
|
||||
'degrees' => array(
|
||||
return [
|
||||
'degrees' => [
|
||||
'description' => 'The number of (clockwise) degrees to rotate the image',
|
||||
),
|
||||
'background' => array(
|
||||
],
|
||||
'background' => [
|
||||
'description' => "A string specifying the hexadecimal color code to use as background for the uncovered area of the image after the rotation. E.g. '#000000' for black, '#ff00ff' for magenta, and '#ffffff' for white. For images that support transparency, this will default to transparent white",
|
||||
'required' => FALSE,
|
||||
'default' => NULL,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,11 +45,11 @@ class Rotate extends GDImageToolkitOperationBase {
|
||||
// Validate or set background color argument.
|
||||
if (!empty($arguments['background'])) {
|
||||
// Validate the background color: Color::hexToRgb does so for us.
|
||||
$background = Color::hexToRgb($arguments['background']) + array( 'alpha' => 0 );
|
||||
$background = Color::hexToRgb($arguments['background']) + [ 'alpha' => 0 ];
|
||||
}
|
||||
else {
|
||||
// Background color is not specified: use transparent white as background.
|
||||
$background = array('red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127);
|
||||
$background = ['red' => 255, 'green' => 255, 'blue' => 255, 'alpha' => 127];
|
||||
}
|
||||
// Store the color index for the background as that is what GD uses.
|
||||
$arguments['background_idx'] = imagecolorallocatealpha($this->getToolkit()->getResource(), $background['red'], $background['green'], $background['blue'], $background['alpha']);
|
||||
@@ -89,7 +89,7 @@ class Rotate extends GDImageToolkitOperationBase {
|
||||
protected function execute(array $arguments) {
|
||||
// PHP installations using non-bundled GD do not have imagerotate.
|
||||
if (!function_exists('imagerotate')) {
|
||||
$this->logger->notice('The image %file could not be rotated because the imagerotate() function is not available in this PHP installation.', array('%file' => $this->getToolkit()->getSource()));
|
||||
$this->logger->notice('The image %file could not be rotated because the imagerotate() function is not available in this PHP installation.', ['%file' => $this->getToolkit()->getSource()]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,23 +19,23 @@ class Scale extends Resize {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function arguments() {
|
||||
return array(
|
||||
'width' => array(
|
||||
return [
|
||||
'width' => [
|
||||
'description' => 'The target width, in pixels. This value is omitted then the scaling will based only on the height value',
|
||||
'required' => FALSE,
|
||||
'default' => NULL,
|
||||
),
|
||||
'height' => array(
|
||||
],
|
||||
'height' => [
|
||||
'description' => 'The target height, in pixels. This value is omitted then the scaling will based only on the width value',
|
||||
'required' => FALSE,
|
||||
'default' => NULL,
|
||||
),
|
||||
'upscale' => array(
|
||||
],
|
||||
'upscale' => [
|
||||
'description' => 'Boolean indicating that files smaller than the dimensions will be scaled up. This generally results in a low quality image',
|
||||
'required' => FALSE,
|
||||
'default' => FALSE,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ class Scale extends Resize {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(array $arguments = array()) {
|
||||
protected function execute(array $arguments = []) {
|
||||
// Don't scale if we don't change the dimensions at all.
|
||||
if ($arguments['width'] !== $this->getToolkit()->getWidth() || $arguments['height'] !== $this->getToolkit()->getHeight()) {
|
||||
// Don't upscale if the option isn't enabled.
|
||||
|
||||
@@ -19,14 +19,14 @@ class ScaleAndCrop extends GDImageToolkitOperationBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function arguments() {
|
||||
return array(
|
||||
'width' => array(
|
||||
return [
|
||||
'width' => [
|
||||
'description' => 'The target width, in pixels',
|
||||
),
|
||||
'height' => array(
|
||||
],
|
||||
'height' => [
|
||||
'description' => 'The target height, in pixels',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,10 +40,10 @@ class ScaleAndCrop extends GDImageToolkitOperationBase {
|
||||
|
||||
$arguments['x'] = (int) round(($actualWidth * $scaleFactor - $arguments['width']) / 2);
|
||||
$arguments['y'] = (int) round(($actualHeight * $scaleFactor - $arguments['height']) / 2);
|
||||
$arguments['resize'] = array(
|
||||
$arguments['resize'] = [
|
||||
'width' => (int) round($actualWidth * $scaleFactor),
|
||||
'height' => (int) round($actualHeight * $scaleFactor),
|
||||
);
|
||||
];
|
||||
|
||||
// Fail when width or height are 0 or negative.
|
||||
if ($arguments['width'] <= 0) {
|
||||
@@ -59,7 +59,7 @@ class ScaleAndCrop extends GDImageToolkitOperationBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(array $arguments = array()) {
|
||||
protected function execute(array $arguments = []) {
|
||||
return $this->getToolkit()->apply('resize', $arguments['resize'])
|
||||
&& $this->getToolkit()->apply('crop', $arguments);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\system\Plugin\migrate\destination\d7;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate\Plugin\migrate\destination\DestinationBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Persist theme settings to the config system.
|
||||
*
|
||||
* @MigrateDestination(
|
||||
* id = "d7_theme_settings"
|
||||
* )
|
||||
*/
|
||||
class ThemeSettings extends DestinationBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The configuration factory.
|
||||
*
|
||||
* @var \Drupal\Core\Config\ConfigFactoryInterface
|
||||
*/
|
||||
protected $configFactory;
|
||||
|
||||
/**
|
||||
* Constructs a theme settings destination object.
|
||||
*
|
||||
* @param array $configuration
|
||||
* Plugin configuration.
|
||||
* @param string $plugin_id
|
||||
* The plugin ID.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin definition.
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The current migration.
|
||||
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
||||
* The configuration factory.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, ConfigFactoryInterface $config_factory) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
||||
$this->configFactory = $config_factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('config.factory')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function import(Row $row, array $old_destination_id_values = []) {
|
||||
$imported = FALSE;
|
||||
$config = $this->configFactory->getEditable($row->getDestinationProperty('configuration_name'));
|
||||
$theme_settings = $row->getDestination();
|
||||
// Remove keys not in theme settings.
|
||||
unset($theme_settings['configuration_name']);
|
||||
unset($theme_settings['theme_name']);
|
||||
if (isset($theme_settings)) {
|
||||
theme_settings_convert_to_config($theme_settings, $config);
|
||||
$config->save();
|
||||
$imported = TRUE;
|
||||
}
|
||||
return $imported;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['name']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields(MigrationInterface $migration = NULL) {
|
||||
// Theme settings vary by theme, so no specific fields are defined.
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,11 +25,11 @@ class Menu extends DrupalSqlBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
return [
|
||||
'menu_name' => $this->t('The menu name. Primary key.'),
|
||||
'title' => $this->t('The human-readable name of the menu.'),
|
||||
'description' => $this->t('A description of the menu'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\system\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\VariableMultiRow;
|
||||
|
||||
/**
|
||||
* Drupal 7 system source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_theme_settings",
|
||||
* source_provider = "system"
|
||||
* )
|
||||
*/
|
||||
class ThemeSettings extends VariableMultiRow {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('variable', 'v')
|
||||
->fields('v', ['name', 'value'])
|
||||
->condition('name', 'theme_%_settings', 'LIKE');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'name' => $this->t('Theme settings variable for a theme.'),
|
||||
'value' => $this->t('The theme settings variable value.'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['name']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,7 +49,7 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
||||
*
|
||||
* @var \Drupal\system\ActionConfigEntityInterface[]
|
||||
*/
|
||||
protected $actions = array();
|
||||
protected $actions = [];
|
||||
|
||||
/**
|
||||
* The language manager.
|
||||
@@ -162,13 +162,13 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
||||
*/
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['action_title'] = array('default' => $this->t('With selection'));
|
||||
$options['include_exclude'] = array(
|
||||
$options['action_title'] = ['default' => $this->t('Action')];
|
||||
$options['include_exclude'] = [
|
||||
'default' => 'exclude',
|
||||
);
|
||||
$options['selected_actions'] = array(
|
||||
'default' => array(),
|
||||
);
|
||||
];
|
||||
$options['selected_actions'] = [
|
||||
'default' => [],
|
||||
];
|
||||
return $options;
|
||||
}
|
||||
|
||||
@@ -176,28 +176,28 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
|
||||
$form['action_title'] = array(
|
||||
$form['action_title'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Action title'),
|
||||
'#default_value' => $this->options['action_title'],
|
||||
'#description' => $this->t('The title shown above the actions dropdown.'),
|
||||
);
|
||||
];
|
||||
|
||||
$form['include_exclude'] = array(
|
||||
$form['include_exclude'] = [
|
||||
'#type' => 'radios',
|
||||
'#title' => $this->t('Available actions'),
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
'exclude' => $this->t('All actions, except selected'),
|
||||
'include' => $this->t('Only selected actions'),
|
||||
),
|
||||
],
|
||||
'#default_value' => $this->options['include_exclude'],
|
||||
);
|
||||
$form['selected_actions'] = array(
|
||||
];
|
||||
$form['selected_actions'] = [
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => $this->t('Selected actions'),
|
||||
'#options' => $this->getBulkOptions(FALSE),
|
||||
'#default_value' => $this->options['selected_actions'],
|
||||
);
|
||||
];
|
||||
|
||||
parent::buildOptionsForm($form, $form_state);
|
||||
}
|
||||
@@ -208,8 +208,8 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
||||
public function validateOptionsForm(&$form, FormStateInterface $form_state) {
|
||||
parent::validateOptionsForm($form, $form_state);
|
||||
|
||||
$selected_actions = $form_state->getValue(array('options', 'selected_actions'));
|
||||
$form_state->setValue(array('options', 'selected_actions'), array_values(array_filter($selected_actions)));
|
||||
$selected_actions = $form_state->getValue(['options', 'selected_actions']);
|
||||
$form_state->setValue(['options', 'selected_actions'], array_values(array_filter($selected_actions)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,7 +259,7 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
||||
foreach ($this->view->result as $row_index => $row) {
|
||||
$entity = $this->getEntityTranslation($this->getEntity($row), $row);
|
||||
|
||||
$form[$this->options['id']][$row_index] = array(
|
||||
$form[$this->options['id']][$row_index] = [
|
||||
'#type' => 'checkbox',
|
||||
// We are not able to determine a main "title" for each row, so we can
|
||||
// only output a generic label.
|
||||
@@ -267,28 +267,28 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => !empty($form_state->getValue($this->options['id'])[$row_index]) ? 1 : NULL,
|
||||
'#return_value' => $this->calculateEntityBulkFormKey($entity, $use_revision),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
// Replace the form submit button label.
|
||||
$form['actions']['submit']['#value'] = $this->t('Apply');
|
||||
$form['actions']['submit']['#value'] = $this->t('Apply to selected items');
|
||||
|
||||
// Ensure a consistent container for filters/operations in the view header.
|
||||
$form['header'] = array(
|
||||
$form['header'] = [
|
||||
'#type' => 'container',
|
||||
'#weight' => -100,
|
||||
);
|
||||
];
|
||||
|
||||
// Build the bulk operations action widget for the header.
|
||||
// Allow themes to apply .container-inline on this separate container.
|
||||
$form['header'][$this->options['id']] = array(
|
||||
$form['header'][$this->options['id']] = [
|
||||
'#type' => 'container',
|
||||
);
|
||||
$form['header'][$this->options['id']]['action'] = array(
|
||||
];
|
||||
$form['header'][$this->options['id']]['action'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->options['action_title'],
|
||||
'#options' => $this->getBulkOptions(),
|
||||
);
|
||||
];
|
||||
|
||||
// Duplicate the form actions into the action container in the header.
|
||||
$form['header'][$this->options['id']]['actions'] = $form['actions'];
|
||||
@@ -308,7 +308,7 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
||||
* An associative array of operations, suitable for a select element.
|
||||
*/
|
||||
protected function getBulkOptions($filtered = TRUE) {
|
||||
$options = array();
|
||||
$options = [];
|
||||
// Filter the action list.
|
||||
foreach ($this->actions as $id => $action) {
|
||||
if ($filtered) {
|
||||
@@ -344,9 +344,12 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
||||
*/
|
||||
public function viewsFormSubmit(&$form, FormStateInterface $form_state) {
|
||||
if ($form_state->get('step') == 'views_form_views_form') {
|
||||
// Filter only selected checkboxes.
|
||||
$selected = array_filter($form_state->getValue($this->options['id']));
|
||||
$entities = array();
|
||||
// Filter only selected checkboxes. Use the actual user input rather than
|
||||
// the raw form values array, since the site data may change before the
|
||||
// bulk form is submitted, which can lead to data loss.
|
||||
$user_input = $form_state->getUserInput();
|
||||
$selected = array_filter($user_input[$this->options['id']]);
|
||||
$entities = [];
|
||||
$action = $this->actions[$form_state->getValue('action')];
|
||||
$count = 0;
|
||||
|
||||
@@ -372,19 +375,18 @@ class BulkForm extends FieldPluginBase implements CacheableDependencyInterface {
|
||||
|
||||
$operation_definition = $action->getPluginDefinition();
|
||||
if (!empty($operation_definition['confirm_form_route_name'])) {
|
||||
$options = array(
|
||||
$options = [
|
||||
'query' => $this->getDestinationArray(),
|
||||
);
|
||||
$form_state->setRedirect($operation_definition['confirm_form_route_name'], array(), $options);
|
||||
];
|
||||
$form_state->setRedirect($operation_definition['confirm_form_route_name'], [], $options);
|
||||
}
|
||||
else {
|
||||
// Don't display the message unless there are some elements affected and
|
||||
// there is no confirmation form.
|
||||
$count = count(array_filter($form_state->getValue($this->options['id'])));
|
||||
if ($count) {
|
||||
drupal_set_message($this->formatPlural($count, '%action was applied to @count item.', '%action was applied to @count items.', array(
|
||||
drupal_set_message($this->formatPlural($count, '%action was applied to @count item.', '%action was applied to @count items.', [
|
||||
'%action' => $action->label(),
|
||||
)));
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,11 +81,11 @@ class SystemConfigSubscriber implements EventSubscriberInterface {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents() {
|
||||
$events[ConfigEvents::SAVE][] = array('onConfigSave', 0);
|
||||
$events[ConfigEvents::SAVE][] = ['onConfigSave', 0];
|
||||
// The empty check has a high priority so that it can stop propagation if
|
||||
// there is no configuration to import.
|
||||
$events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidateNotEmpty', 512);
|
||||
$events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidateSiteUUID', 256);
|
||||
$events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidateNotEmpty', 512];
|
||||
$events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidateSiteUUID', 256];
|
||||
return $events;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,8 +109,8 @@ class SystemManager {
|
||||
drupal_load_updates();
|
||||
|
||||
// Check run-time requirements and status information.
|
||||
$requirements = $this->moduleHandler->invokeAll('requirements', array('runtime'));
|
||||
usort($requirements, function($a, $b) {
|
||||
$requirements = $this->moduleHandler->invokeAll('requirements', ['runtime']);
|
||||
uasort($requirements, function($a, $b) {
|
||||
if (!isset($a['weight'])) {
|
||||
if (!isset($b['weight'])) {
|
||||
return strcasecmp($a['title'], $b['title']);
|
||||
@@ -159,15 +159,15 @@ class SystemManager {
|
||||
// or elsewhere could give us a blank block.
|
||||
$link = $this->menuActiveTrail->getActiveLink('admin');
|
||||
if ($link && $content = $this->getAdminBlock($link)) {
|
||||
$output = array(
|
||||
$output = [
|
||||
'#theme' => 'admin_block_content',
|
||||
'#content' => $content,
|
||||
);
|
||||
];
|
||||
}
|
||||
else {
|
||||
$output = array(
|
||||
$output = [
|
||||
'#markup' => t('You do not have any administrative items.'),
|
||||
);
|
||||
];
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
@@ -182,16 +182,16 @@ class SystemManager {
|
||||
* An array of menu items, as expected by admin-block-content.html.twig.
|
||||
*/
|
||||
public function getAdminBlock(MenuLinkInterface $instance) {
|
||||
$content = array();
|
||||
$content = [];
|
||||
// Only find the children of this link.
|
||||
$link_id = $instance->getPluginId();
|
||||
$parameters = new MenuTreeParameters();
|
||||
$parameters->setRoot($link_id)->excludeRoot()->setTopLevelOnly()->onlyEnabledLinks();
|
||||
$tree = $this->menuTree->load(NULL, $parameters);
|
||||
$manipulators = array(
|
||||
array('callable' => 'menu.default_tree_manipulators:checkAccess'),
|
||||
array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'),
|
||||
);
|
||||
$manipulators = [
|
||||
['callable' => 'menu.default_tree_manipulators:checkAccess'],
|
||||
['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'],
|
||||
];
|
||||
$tree = $this->menuTree->transform($tree, $manipulators);
|
||||
foreach ($tree as $key => $element) {
|
||||
// Only render accessible links.
|
||||
|
||||
@@ -11,13 +11,13 @@ class AjaxInGroupTest extends AjaxTestBase {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalLogin($this->drupalCreateUser(array('access content')));
|
||||
$this->drupalLogin($this->drupalCreateUser(['access content']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits forms with select and checkbox elements via Ajax.
|
||||
*/
|
||||
function testSimpleAjaxFormValue() {
|
||||
public function testSimpleAjaxFormValue() {
|
||||
$this->drupalGet('/ajax_forms_test_get_form');
|
||||
$this->assertText('Test group');
|
||||
$this->assertText('AJAX checkbox in a group');
|
||||
|
||||
@@ -14,7 +14,7 @@ abstract class AjaxTestBase extends WebTestBase {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('node', 'ajax_test', 'ajax_forms_test');
|
||||
public static $modules = ['node', 'ajax_test', 'ajax_forms_test'];
|
||||
|
||||
/**
|
||||
* Asserts the array of Ajax commands contains the searched command.
|
||||
|
||||
@@ -32,91 +32,91 @@ class CommandsTest extends AjaxTestBase {
|
||||
/**
|
||||
* Tests the various Ajax Commands.
|
||||
*/
|
||||
function testAjaxCommands() {
|
||||
public function testAjaxCommands() {
|
||||
$form_path = 'ajax_forms_test_ajax_commands_form';
|
||||
$web_user = $this->drupalCreateUser(array('access content'));
|
||||
$web_user = $this->drupalCreateUser(['access content']);
|
||||
$this->drupalLogin($web_user);
|
||||
|
||||
$edit = array();
|
||||
$edit = [];
|
||||
|
||||
// Tests the 'add_css' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'add_css' command")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'add_css' command")]);
|
||||
$expected = new AddCssCommand('my/file.css');
|
||||
$this->assertCommand($commands, $expected->render(), "'add_css' AJAX command issued with correct data.");
|
||||
|
||||
// Tests the 'after' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'After': Click to put something after the div")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'After': Click to put something after the div")]);
|
||||
$expected = new AfterCommand('#after_div', 'This will be placed after');
|
||||
$this->assertCommand($commands, $expected->render(), "'after' AJAX command issued with correct data.");
|
||||
|
||||
// Tests the 'alert' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'Alert': Click to alert")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'Alert': Click to alert")]);
|
||||
$expected = new AlertCommand(t('Alert'));
|
||||
$this->assertCommand($commands, $expected->render(), "'alert' AJAX Command issued with correct text.");
|
||||
|
||||
// Tests the 'append' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'Append': Click to append something")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'Append': Click to append something")]);
|
||||
$expected = new AppendCommand('#append_div', 'Appended text');
|
||||
$this->assertCommand($commands, $expected->render(), "'append' AJAX command issued with correct data.");
|
||||
|
||||
// Tests the 'before' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'before': Click to put something before the div")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'before': Click to put something before the div")]);
|
||||
$expected = new BeforeCommand('#before_div', 'Before text');
|
||||
$this->assertCommand($commands, $expected->render(), "'before' AJAX command issued with correct data.");
|
||||
|
||||
// Tests the 'changed' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX changed: Click to mark div changed.")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX changed: Click to mark div changed.")]);
|
||||
$expected = new ChangedCommand('#changed_div');
|
||||
$this->assertCommand($commands, $expected->render(), "'changed' AJAX command issued with correct selector.");
|
||||
|
||||
// Tests the 'changed' command using the second argument.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX changed: Click to mark div changed with asterisk.")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX changed: Click to mark div changed with asterisk.")]);
|
||||
$expected = new ChangedCommand('#changed_div', '#changed_div_mark_this');
|
||||
$this->assertCommand($commands, $expected->render(), "'changed' AJAX command (with asterisk) issued with correct selector.");
|
||||
|
||||
// Tests the 'css' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("Set the '#box' div to be blue.")));
|
||||
$expected = new CssCommand('#css_div', array('background-color' => 'blue'));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("Set the '#box' div to be blue.")]);
|
||||
$expected = new CssCommand('#css_div', ['background-color' => 'blue']);
|
||||
$this->assertCommand($commands, $expected->render(), "'css' AJAX command issued with correct selector.");
|
||||
|
||||
// Tests the 'data' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX data command: Issue command.")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX data command: Issue command.")]);
|
||||
$expected = new DataCommand('#data_div', 'testkey', 'testvalue');
|
||||
$this->assertCommand($commands, $expected->render(), "'data' AJAX command issued with correct key and value.");
|
||||
|
||||
// Tests the 'html' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX html: Replace the HTML in a selector.")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX html: Replace the HTML in a selector.")]);
|
||||
$expected = new HtmlCommand('#html_div', 'replacement text');
|
||||
$this->assertCommand($commands, $expected->render(), "'html' AJAX command issued with correct data.");
|
||||
|
||||
// Tests the 'insert' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX insert: Let client insert based on #ajax['method'].")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX insert: Let client insert based on #ajax['method'].")]);
|
||||
$expected = new InsertCommand('#insert_div', 'insert replacement text');
|
||||
$this->assertCommand($commands, $expected->render(), "'insert' AJAX command issued with correct data.");
|
||||
|
||||
// Tests the 'invoke' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX invoke command: Invoke addClass() method.")));
|
||||
$expected = new InvokeCommand('#invoke_div', 'addClass', array('error'));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX invoke command: Invoke addClass() method.")]);
|
||||
$expected = new InvokeCommand('#invoke_div', 'addClass', ['error']);
|
||||
$this->assertCommand($commands, $expected->render(), "'invoke' AJAX command issued with correct method and argument.");
|
||||
|
||||
// Tests the 'prepend' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'prepend': Click to prepend something")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'prepend': Click to prepend something")]);
|
||||
$expected = new PrependCommand('#prepend_div', 'prepended text');
|
||||
$this->assertCommand($commands, $expected->render(), "'prepend' AJAX command issued with correct data.");
|
||||
|
||||
// Tests the 'remove' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'remove': Click to remove text")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'remove': Click to remove text")]);
|
||||
$expected = new RemoveCommand('#remove_text');
|
||||
$this->assertCommand($commands, $expected->render(), "'remove' AJAX command issued with correct command and selector.");
|
||||
|
||||
// Tests the 'restripe' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'restripe' command")));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'restripe' command")]);
|
||||
$expected = new RestripeCommand('#restripe_table');
|
||||
$this->assertCommand($commands, $expected->render(), "'restripe' AJAX command issued with correct selector.");
|
||||
|
||||
// Tests the 'settings' command.
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, array('op' => t("AJAX 'settings' command")));
|
||||
$expected = new SettingsCommand(array('ajax_forms_test' => array('foo' => 42)));
|
||||
$commands = $this->drupalPostAjaxForm($form_path, $edit, ['op' => t("AJAX 'settings' command")]);
|
||||
$expected = new SettingsCommand(['ajax_forms_test' => ['foo' => 42]]);
|
||||
$this->assertCommand($commands, $expected->render(), "'settings' AJAX command issued with correct data.");
|
||||
}
|
||||
|
||||
|
||||
@@ -19,72 +19,72 @@ class DialogTest extends AjaxTestBase {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('ajax_test', 'ajax_forms_test', 'contact');
|
||||
public static $modules = ['ajax_test', 'ajax_forms_test', 'contact'];
|
||||
|
||||
/**
|
||||
* Test sending non-JS and AJAX requests to open and manipulate modals.
|
||||
*/
|
||||
public function testDialog() {
|
||||
$this->drupalLogin($this->drupalCreateUser(array('administer contact forms')));
|
||||
$this->drupalLogin($this->drupalCreateUser(['administer contact forms']));
|
||||
// Ensure the elements render without notices or exceptions.
|
||||
$this->drupalGet('ajax-test/dialog');
|
||||
|
||||
// Set up variables for this test.
|
||||
$dialog_renderable = AjaxTestController::dialogContents();
|
||||
$dialog_contents = \Drupal::service('renderer')->renderRoot($dialog_renderable);
|
||||
$modal_expected_response = array(
|
||||
$modal_expected_response = [
|
||||
'command' => 'openDialog',
|
||||
'selector' => '#drupal-modal',
|
||||
'settings' => NULL,
|
||||
'data' => $dialog_contents,
|
||||
'dialogOptions' => array(
|
||||
'dialogOptions' => [
|
||||
'modal' => TRUE,
|
||||
'title' => 'AJAX Dialog contents',
|
||||
),
|
||||
);
|
||||
$form_expected_response = array(
|
||||
'title' => 'AJAX Dialog & contents',
|
||||
],
|
||||
];
|
||||
$form_expected_response = [
|
||||
'command' => 'openDialog',
|
||||
'selector' => '#drupal-modal',
|
||||
'settings' => NULL,
|
||||
'dialogOptions' => array(
|
||||
'dialogOptions' => [
|
||||
'modal' => TRUE,
|
||||
'title' => 'Ajax Form contents',
|
||||
),
|
||||
);
|
||||
$entity_form_expected_response = array(
|
||||
],
|
||||
];
|
||||
$entity_form_expected_response = [
|
||||
'command' => 'openDialog',
|
||||
'selector' => '#drupal-modal',
|
||||
'settings' => NULL,
|
||||
'dialogOptions' => array(
|
||||
'dialogOptions' => [
|
||||
'modal' => TRUE,
|
||||
'title' => 'Add contact form',
|
||||
),
|
||||
);
|
||||
$normal_expected_response = array(
|
||||
],
|
||||
];
|
||||
$normal_expected_response = [
|
||||
'command' => 'openDialog',
|
||||
'selector' => '#ajax-test-dialog-wrapper-1',
|
||||
'settings' => NULL,
|
||||
'data' => $dialog_contents,
|
||||
'dialogOptions' => array(
|
||||
'dialogOptions' => [
|
||||
'modal' => FALSE,
|
||||
'title' => 'AJAX Dialog contents',
|
||||
),
|
||||
);
|
||||
$no_target_expected_response = array(
|
||||
'title' => 'AJAX Dialog & contents',
|
||||
],
|
||||
];
|
||||
$no_target_expected_response = [
|
||||
'command' => 'openDialog',
|
||||
'selector' => '#drupal-dialog-ajax-testdialog-contents',
|
||||
'settings' => NULL,
|
||||
'data' => $dialog_contents,
|
||||
'dialogOptions' => array(
|
||||
'dialogOptions' => [
|
||||
'modal' => FALSE,
|
||||
'title' => 'AJAX Dialog contents',
|
||||
),
|
||||
);
|
||||
$close_expected_response = array(
|
||||
'title' => 'AJAX Dialog & contents',
|
||||
],
|
||||
];
|
||||
$close_expected_response = [
|
||||
'command' => 'closeDialog',
|
||||
'selector' => '#ajax-test-dialog-wrapper-1',
|
||||
'persist' => FALSE,
|
||||
);
|
||||
];
|
||||
|
||||
// Check that requesting a modal dialog without JS goes to a page.
|
||||
$this->drupalGet('ajax-test/dialog-contents');
|
||||
@@ -95,8 +95,11 @@ class DialogTest extends AjaxTestBase {
|
||||
$this->assertRaw($dialog_contents, 'Modal dialog page on XMLHttpRequest present.');
|
||||
|
||||
// Emulate going to the JS version of the page and check the JSON response.
|
||||
$ajax_result = $this->drupalGetAjax('ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal')));
|
||||
$ajax_result = $this->drupalGetAjax('ajax-test/dialog-contents', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal']]);
|
||||
$this->assertEqual($modal_expected_response, $ajax_result[3], 'Modal dialog JSON response matches.');
|
||||
// Test the HTML escaping of & character.
|
||||
$this->assertEqual($ajax_result[3]['dialogOptions']['title'], 'AJAX Dialog & contents');
|
||||
$this->assertNotEqual($ajax_result[3]['dialogOptions']['title'], 'AJAX Dialog & contents');
|
||||
|
||||
// Check that requesting a "normal" dialog without JS goes to a page.
|
||||
$this->drupalGet('ajax-test/dialog-contents');
|
||||
@@ -105,26 +108,26 @@ class DialogTest extends AjaxTestBase {
|
||||
// Emulate going to the JS version of the page and check the JSON response.
|
||||
// This needs to use WebTestBase::drupalPostAjaxForm() so that the correct
|
||||
// dialog options are sent.
|
||||
$ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', array(
|
||||
$ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', [
|
||||
// We have to mock a form element to make drupalPost submit from a link.
|
||||
'textfield' => 'test',
|
||||
), array(), 'ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog')), array(), NULL, array(
|
||||
'submit' => array(
|
||||
], [], 'ajax-test/dialog-contents', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog']], [], NULL, [
|
||||
'submit' => [
|
||||
'dialogOptions[target]' => 'ajax-test-dialog-wrapper-1',
|
||||
)
|
||||
));
|
||||
]
|
||||
]);
|
||||
$this->assertEqual($normal_expected_response, $ajax_result[3], 'Normal dialog JSON response matches.');
|
||||
|
||||
// Emulate going to the JS version of the page and check the JSON response.
|
||||
// This needs to use WebTestBase::drupalPostAjaxForm() so that the correct
|
||||
// dialog options are sent.
|
||||
$ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', array(
|
||||
$ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', [
|
||||
// We have to mock a form element to make drupalPost submit from a link.
|
||||
'textfield' => 'test',
|
||||
), array(), 'ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog')), array(), NULL, array(
|
||||
], [], 'ajax-test/dialog-contents', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog']], [], NULL, [
|
||||
// Don't send a target.
|
||||
'submit' => array()
|
||||
));
|
||||
'submit' => []
|
||||
]);
|
||||
// Make sure the selector ID starts with the right string.
|
||||
$this->assert(strpos($ajax_result[3]['selector'], $no_target_expected_response['selector']) === 0, 'Selector starts with right string.');
|
||||
unset($ajax_result[3]['selector']);
|
||||
@@ -139,7 +142,7 @@ class DialogTest extends AjaxTestBase {
|
||||
// Test submitting via a POST request through the button for modals. This
|
||||
// approach more accurately reflects the real responses by Drupal because
|
||||
// all of the necessary page variables are emulated.
|
||||
$ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', array(), 'button1');
|
||||
$ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', [], 'button1');
|
||||
|
||||
// Check that CSS and JavaScript are "added" to the page dynamically.
|
||||
$this->assertTrue(in_array('core/drupal.dialog.ajax', explode(',', $ajax_result[0]['settings']['ajaxPageState']['libraries'])), 'core/drupal.dialog.ajax library is added to the page.');
|
||||
@@ -152,9 +155,11 @@ class DialogTest extends AjaxTestBase {
|
||||
|
||||
// Check that the response matches the expected value.
|
||||
$this->assertEqual($modal_expected_response, $ajax_result[4], 'POST request modal dialog JSON response matches.');
|
||||
// Test the HTML escaping of & character.
|
||||
$this->assertNotEqual($ajax_result[4]['dialogOptions']['title'], 'AJAX Dialog & contents');
|
||||
|
||||
// Abbreviated test for "normal" dialogs, testing only the difference.
|
||||
$ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', array(), 'button2');
|
||||
$ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', [], 'button2');
|
||||
$this->assertEqual($normal_expected_response, $ajax_result[4], 'POST request normal dialog JSON response matches.');
|
||||
|
||||
// Check that requesting a form dialog without JS goes to a page.
|
||||
@@ -165,7 +170,7 @@ class DialogTest extends AjaxTestBase {
|
||||
$this->assertTrue(!empty($form), 'Non-JS form page present.');
|
||||
|
||||
// Emulate going to the JS version of the form and check the JSON response.
|
||||
$ajax_result = $this->drupalGetAjax('ajax-test/dialog-form', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal')));
|
||||
$ajax_result = $this->drupalGetAjax('ajax-test/dialog-form', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal']]);
|
||||
$expected_ajax_settings = [
|
||||
'edit-preview' => [
|
||||
'callback' => '::preview',
|
||||
@@ -197,7 +202,7 @@ class DialogTest extends AjaxTestBase {
|
||||
$this->assertTrue(!empty($form), 'Non-JS entity form page present.');
|
||||
|
||||
// Emulate going to the JS version of the form and check the JSON response.
|
||||
$ajax_result = $this->drupalGetAjax('admin/structure/contact/add', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal')));
|
||||
$ajax_result = $this->drupalGetAjax('admin/structure/contact/add', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal']]);
|
||||
$this->setRawContent($ajax_result[3]['data']);
|
||||
// Remove the data, the form build id and token will never match.
|
||||
unset($ajax_result[3]['data']);
|
||||
|
||||
@@ -16,8 +16,8 @@ class ElementValidationTest extends AjaxTestBase {
|
||||
* filled in, and we want to see if the activation of the "drivertext"
|
||||
* Ajax-enabled field fails due to the required field being empty.
|
||||
*/
|
||||
function testAjaxElementValidation() {
|
||||
$edit = array('drivertext' => t('some dumb text'));
|
||||
public function testAjaxElementValidation() {
|
||||
$edit = ['drivertext' => t('some dumb text')];
|
||||
|
||||
// Post with 'drivertext' as the triggering element.
|
||||
$this->drupalPostAjaxForm('ajax_validation_test', $edit, 'drivertext');
|
||||
@@ -26,7 +26,7 @@ class ElementValidationTest extends AjaxTestBase {
|
||||
$this->assertText('ajax_forms_test_validation_form_callback invoked', 'The correct callback was invoked');
|
||||
|
||||
$this->drupalGet('ajax_validation_test');
|
||||
$edit = array('drivernumber' => 12345);
|
||||
$edit = ['drivernumber' => 12345];
|
||||
|
||||
// Post with 'drivernumber' as the triggering element.
|
||||
$this->drupalPostAjaxForm('ajax_validation_test', $edit, 'drivernumber');
|
||||
|
||||
@@ -13,28 +13,28 @@ class FormValuesTest extends AjaxTestBase {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalLogin($this->drupalCreateUser(array('access content')));
|
||||
$this->drupalLogin($this->drupalCreateUser(['access content']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits forms with select and checkbox elements via Ajax.
|
||||
*/
|
||||
function testSimpleAjaxFormValue() {
|
||||
public function testSimpleAjaxFormValue() {
|
||||
// Verify form values of a select element.
|
||||
foreach (array('red', 'green', 'blue') as $item) {
|
||||
$edit = array(
|
||||
foreach (['red', 'green', 'blue'] as $item) {
|
||||
$edit = [
|
||||
'select' => $item,
|
||||
);
|
||||
];
|
||||
$commands = $this->drupalPostAjaxForm('ajax_forms_test_get_form', $edit, 'select');
|
||||
$expected = new DataCommand('#ajax_selected_color', 'form_state_value_select', $item);
|
||||
$this->assertCommand($commands, $expected->render(), 'Verification of AJAX form values from a selectbox issued with a correct value.');
|
||||
}
|
||||
|
||||
// Verify form values of a checkbox element.
|
||||
foreach (array(FALSE, TRUE) as $item) {
|
||||
$edit = array(
|
||||
foreach ([FALSE, TRUE] as $item) {
|
||||
$edit = [
|
||||
'checkbox' => $item,
|
||||
);
|
||||
];
|
||||
$commands = $this->drupalPostAjaxForm('ajax_forms_test_get_form', $edit, 'checkbox');
|
||||
$expected = new DataCommand('#ajax_checkbox_value', 'form_state_value_select', (int) $item);
|
||||
$this->assertCommand($commands, $expected->render(), 'Verification of AJAX form values from a checkbox issued with a correct value.');
|
||||
@@ -46,11 +46,11 @@ class FormValuesTest extends AjaxTestBase {
|
||||
// We don't need to check for the X-Drupal-Ajax-Token header with these
|
||||
// invalid requests.
|
||||
$this->assertAjaxHeader = FALSE;
|
||||
foreach (array('null', 'empty', 'nonexistent') as $key) {
|
||||
foreach (['null', 'empty', 'nonexistent'] as $key) {
|
||||
$element_name = 'select_' . $key . '_callback';
|
||||
$edit = array(
|
||||
$edit = [
|
||||
$element_name => 'red',
|
||||
);
|
||||
];
|
||||
$commands = $this->drupalPostAjaxForm('ajax_forms_test_get_form', $edit, $element_name);
|
||||
$this->assertResponse(500);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class FrameworkTest extends AjaxTestBase {
|
||||
public function testAJAXRender() {
|
||||
// Verify that settings command is generated if JavaScript settings exist.
|
||||
$commands = $this->drupalGetAjax('ajax-test/render');
|
||||
$expected = new SettingsCommand(array('ajax' => 'test'), TRUE);
|
||||
$expected = new SettingsCommand(['ajax' => 'test'], TRUE);
|
||||
$this->assertCommand($commands, $expected->render(), 'JavaScript settings command is present.');
|
||||
}
|
||||
|
||||
@@ -30,14 +30,14 @@ class FrameworkTest extends AjaxTestBase {
|
||||
* Tests AjaxResponse::prepare() AJAX commands ordering.
|
||||
*/
|
||||
public function testOrder() {
|
||||
$expected_commands = array();
|
||||
$expected_commands = [];
|
||||
|
||||
// Expected commands, in a very specific order.
|
||||
$asset_resolver = \Drupal::service('asset.resolver');
|
||||
$css_collection_renderer = \Drupal::service('asset.css.collection_renderer');
|
||||
$js_collection_renderer = \Drupal::service('asset.js.collection_renderer');
|
||||
$renderer = \Drupal::service('renderer');
|
||||
$expected_commands[0] = new SettingsCommand(array('ajax' => 'test'), TRUE);
|
||||
$expected_commands[0] = new SettingsCommand(['ajax' => 'test'], TRUE);
|
||||
$build['#attached']['library'][] = 'ajax_test/order-css-command';
|
||||
$assets = AttachedAssets::createFromRenderArray($build);
|
||||
$css_render_array = $css_collection_renderer->render($asset_resolver->getCssAssets($assets, FALSE));
|
||||
@@ -65,7 +65,7 @@ class FrameworkTest extends AjaxTestBase {
|
||||
// 3. JavaScript files in the header
|
||||
// 4. JavaScript files in the footer
|
||||
// 5. Any other AJAX commands, in whatever order they were added.
|
||||
$commands = $this->drupalPostAjaxForm(NULL, array(), NULL, 'ajax-test/order', array(), array(), NULL, array());
|
||||
$commands = $this->drupalPostAjaxForm(NULL, [], NULL, 'ajax-test/order', [], [], NULL, []);
|
||||
$this->assertCommand(array_slice($commands, 0, 1), $expected_commands[0]->render(), 'Settings command is first.');
|
||||
$this->assertCommand(array_slice($commands, 1, 1), $expected_commands[1]->render(), 'CSS command is second (and CSS files are ordered correctly).');
|
||||
$this->assertCommand(array_slice($commands, 2, 1), $expected_commands[2]->render(), 'Header JS command is third.');
|
||||
@@ -78,10 +78,10 @@ class FrameworkTest extends AjaxTestBase {
|
||||
*/
|
||||
public function testAJAXRenderError() {
|
||||
// Verify custom error message.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'message' => 'Custom error message.',
|
||||
);
|
||||
$commands = $this->drupalGetAjax('ajax-test/render-error', array('query' => $edit));
|
||||
];
|
||||
$commands = $this->drupalGetAjax('ajax-test/render-error', ['query' => $edit]);
|
||||
$expected = new AlertCommand($edit['message']);
|
||||
$this->assertCommand($commands, $expected->render(), 'Custom error message is output.');
|
||||
}
|
||||
@@ -95,12 +95,12 @@ class FrameworkTest extends AjaxTestBase {
|
||||
$js_collection_renderer = \Drupal::service('asset.js.collection_renderer');
|
||||
$renderer = \Drupal::service('renderer');
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'setting_name' => 'ajax_forms_test_lazy_load_form_submit',
|
||||
'setting_value' => 'executed',
|
||||
'library_1' => 'system/admin',
|
||||
'library_2' => 'system/drupal.system',
|
||||
);
|
||||
];
|
||||
|
||||
// Get the base page.
|
||||
$this->drupalGet('ajax_forms_test_lazy_load_form');
|
||||
@@ -109,9 +109,9 @@ class FrameworkTest extends AjaxTestBase {
|
||||
|
||||
// Verify that the base page doesn't have the settings and files that are to
|
||||
// be lazy loaded as part of the next requests.
|
||||
$this->assertTrue(!isset($original_settings[$expected['setting_name']]), format_string('Page originally lacks the %setting, as expected.', array('%setting' => $expected['setting_name'])));
|
||||
$this->assertTrue(!in_array($expected['library_1'], $original_libraries), format_string('Page originally lacks the %library library, as expected.', array('%library' => $expected['library_1'])));
|
||||
$this->assertTrue(!in_array($expected['library_2'], $original_libraries), format_string('Page originally lacks the %library library, as expected.', array('%library' => $expected['library_2'])));
|
||||
$this->assertTrue(!isset($original_settings[$expected['setting_name']]), format_string('Page originally lacks the %setting, as expected.', ['%setting' => $expected['setting_name']]));
|
||||
$this->assertTrue(!in_array($expected['library_1'], $original_libraries), format_string('Page originally lacks the %library library, as expected.', ['%library' => $expected['library_1']]));
|
||||
$this->assertTrue(!in_array($expected['library_2'], $original_libraries), format_string('Page originally lacks the %library library, as expected.', ['%library' => $expected['library_2']]));
|
||||
|
||||
// Calculate the expected CSS and JS.
|
||||
$assets = new AttachedAssets();
|
||||
@@ -128,14 +128,14 @@ class FrameworkTest extends AjaxTestBase {
|
||||
$expected_js_html = $renderer->renderRoot($js_render_array);
|
||||
|
||||
// Submit the AJAX request without triggering files getting added.
|
||||
$commands = $this->drupalPostAjaxForm(NULL, array('add_files' => FALSE), array('op' => t('Submit')));
|
||||
$commands = $this->drupalPostAjaxForm(NULL, ['add_files' => FALSE], ['op' => t('Submit')]);
|
||||
$new_settings = $this->getDrupalSettings();
|
||||
$new_libraries = explode(',', $new_settings['ajaxPageState']['libraries']);
|
||||
|
||||
// Verify the setting was not added when not expected.
|
||||
$this->assertTrue(!isset($new_settings[$expected['setting_name']]), format_string('Page still lacks the %setting, as expected.', array('%setting' => $expected['setting_name'])));
|
||||
$this->assertTrue(!in_array($expected['library_1'], $new_libraries), format_string('Page still lacks the %library library, as expected.', array('%library' => $expected['library_1'])));
|
||||
$this->assertTrue(!in_array($expected['library_2'], $new_libraries), format_string('Page still lacks the %library library, as expected.', array('%library' => $expected['library_2'])));
|
||||
$this->assertTrue(!isset($new_settings[$expected['setting_name']]), format_string('Page still lacks the %setting, as expected.', ['%setting' => $expected['setting_name']]));
|
||||
$this->assertTrue(!in_array($expected['library_1'], $new_libraries), format_string('Page still lacks the %library library, as expected.', ['%library' => $expected['library_1']]));
|
||||
$this->assertTrue(!in_array($expected['library_2'], $new_libraries), format_string('Page still lacks the %library library, as expected.', ['%library' => $expected['library_2']]));
|
||||
// Verify a settings command does not add CSS or scripts to drupalSettings
|
||||
// and no command inserts the corresponding tags on the page.
|
||||
$found_settings_command = FALSE;
|
||||
@@ -148,24 +148,24 @@ class FrameworkTest extends AjaxTestBase {
|
||||
$found_markup_command = TRUE;
|
||||
}
|
||||
}
|
||||
$this->assertFalse($found_settings_command, format_string('Page state still lacks the %library_1 and %library_2 libraries, as expected.', array('%library_1' => $expected['library_1'], '%library_2' => $expected['library_2'])));
|
||||
$this->assertFalse($found_markup_command, format_string('Page still lacks the %library_1 and %library_2 libraries, as expected.', array('%library_1' => $expected['library_1'], '%library_2' => $expected['library_2'])));
|
||||
$this->assertFalse($found_settings_command, format_string('Page state still lacks the %library_1 and %library_2 libraries, as expected.', ['%library_1' => $expected['library_1'], '%library_2' => $expected['library_2']]));
|
||||
$this->assertFalse($found_markup_command, format_string('Page still lacks the %library_1 and %library_2 libraries, as expected.', ['%library_1' => $expected['library_1'], '%library_2' => $expected['library_2']]));
|
||||
|
||||
// Submit the AJAX request and trigger adding files.
|
||||
$commands = $this->drupalPostAjaxForm(NULL, array('add_files' => TRUE), array('op' => t('Submit')));
|
||||
$commands = $this->drupalPostAjaxForm(NULL, ['add_files' => TRUE], ['op' => t('Submit')]);
|
||||
$new_settings = $this->getDrupalSettings();
|
||||
$new_libraries = explode(',', $new_settings['ajaxPageState']['libraries']);
|
||||
|
||||
// Verify the expected setting was added, both to drupalSettings, and as
|
||||
// the first AJAX command.
|
||||
$this->assertIdentical($new_settings[$expected['setting_name']], $expected['setting_value'], format_string('Page now has the %setting.', array('%setting' => $expected['setting_name'])));
|
||||
$expected_command = new SettingsCommand(array($expected['setting_name'] => $expected['setting_value']), TRUE);
|
||||
$this->assertIdentical($new_settings[$expected['setting_name']], $expected['setting_value'], format_string('Page now has the %setting.', ['%setting' => $expected['setting_name']]));
|
||||
$expected_command = new SettingsCommand([$expected['setting_name'] => $expected['setting_value']], TRUE);
|
||||
$this->assertCommand(array_slice($commands, 0, 1), $expected_command->render(), 'The settings command was first.');
|
||||
|
||||
// Verify the expected CSS file was added, both to drupalSettings, and as
|
||||
// the second AJAX command for inclusion into the HTML.
|
||||
$this->assertTrue(in_array($expected['library_1'], $new_libraries), format_string('Page state now has the %library library.', array('%library' => $expected['library_1'])));
|
||||
$this->assertCommand(array_slice($commands, 1, 1), array('data' => $expected_css_html), format_string('Page now has the %library library.', array('%library' => $expected['library_1'])));
|
||||
$this->assertTrue(in_array($expected['library_1'], $new_libraries), format_string('Page state now has the %library library.', ['%library' => $expected['library_1']]));
|
||||
$this->assertCommand(array_slice($commands, 1, 1), ['data' => $expected_css_html], format_string('Page now has the %library library.', ['%library' => $expected['library_1']]));
|
||||
|
||||
// Verify the expected JS file was added, both to drupalSettings, and as
|
||||
// the third AJAX command for inclusion into the HTML. By testing for an
|
||||
@@ -173,15 +173,15 @@ class FrameworkTest extends AjaxTestBase {
|
||||
// unexpected JavaScript code, such as a jQuery.extend() that would
|
||||
// potentially clobber rather than properly merge settings, didn't
|
||||
// accidentally get added.
|
||||
$this->assertTrue(in_array($expected['library_2'], $new_libraries), format_string('Page state now has the %library library.', array('%library' => $expected['library_2'])));
|
||||
$this->assertCommand(array_slice($commands, 2, 1), array('data' => $expected_js_html), format_string('Page now has the %library library.', array('%library' => $expected['library_2'])));
|
||||
$this->assertTrue(in_array($expected['library_2'], $new_libraries), format_string('Page state now has the %library library.', ['%library' => $expected['library_2']]));
|
||||
$this->assertCommand(array_slice($commands, 2, 1), ['data' => $expected_js_html], format_string('Page now has the %library library.', ['%library' => $expected['library_2']]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that drupalSettings.currentPath is not updated on AJAX requests.
|
||||
*/
|
||||
public function testCurrentPathChange() {
|
||||
$commands = $this->drupalPostAjaxForm('ajax_forms_test_lazy_load_form', array('add_files' => FALSE), array('op' => t('Submit')));
|
||||
$commands = $this->drupalPostAjaxForm('ajax_forms_test_lazy_load_form', ['add_files' => FALSE], ['op' => t('Submit')]);
|
||||
foreach ($commands as $command) {
|
||||
if ($command['command'] == 'settings') {
|
||||
$this->assertFalse(isset($command['settings']['currentPath']), 'Value of drupalSettings.currentPath is not updated after an AJAX request.');
|
||||
@@ -195,14 +195,14 @@ class FrameworkTest extends AjaxTestBase {
|
||||
public function testLazyLoadOverriddenCSS() {
|
||||
// The test theme overrides js.module.css without an implementation,
|
||||
// thereby removing it.
|
||||
\Drupal::service('theme_handler')->install(array('test_theme'));
|
||||
\Drupal::service('theme_handler')->install(['test_theme']);
|
||||
$this->config('system.theme')
|
||||
->set('default', 'test_theme')
|
||||
->save();
|
||||
|
||||
// This gets the form, and emulates an Ajax submission on it, including
|
||||
// adding markup to the HEAD and BODY for any lazy loaded JS/CSS files.
|
||||
$this->drupalPostAjaxForm('ajax_forms_test_lazy_load_form', array('add_files' => TRUE), array('op' => t('Submit')));
|
||||
$this->drupalPostAjaxForm('ajax_forms_test_lazy_load_form', ['add_files' => TRUE], ['op' => t('Submit')]);
|
||||
|
||||
// Verify that the resulting HTML does not load the overridden CSS file.
|
||||
// We add a "?" to the assertion, because drupalSettings may include
|
||||
|
||||
@@ -19,38 +19,38 @@ class MultiFormTest extends AjaxTestBase {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('form_test');
|
||||
public static $modules = ['form_test'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Page'));
|
||||
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Page']);
|
||||
|
||||
// Create a multi-valued field for 'page' nodes to use for Ajax testing.
|
||||
$field_name = 'field_ajax_test';
|
||||
FieldStorageConfig::create(array(
|
||||
FieldStorageConfig::create([
|
||||
'entity_type' => 'node',
|
||||
'field_name' => $field_name,
|
||||
'type' => 'text',
|
||||
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
|
||||
))->save();
|
||||
])->save();
|
||||
FieldConfig::create([
|
||||
'field_name' => $field_name,
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
])->save();
|
||||
entity_get_form_display('node', 'page', 'default')
|
||||
->setComponent($field_name, array('type' => 'text_textfield'))
|
||||
->setComponent($field_name, ['type' => 'text_textfield'])
|
||||
->save();
|
||||
|
||||
// Log in a user who can create 'page' nodes.
|
||||
$this->drupalLogin ($this->drupalCreateUser(array('create page content')));
|
||||
$this->drupalLogin ($this->drupalCreateUser(['create page content']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that pages with the 'node_page_form' included twice work correctly.
|
||||
*/
|
||||
function testMultiForm() {
|
||||
public function testMultiForm() {
|
||||
// HTML IDs for elements within the field are potentially modified with
|
||||
// each Ajax submission, but these variables are stable and help target the
|
||||
// desired elements.
|
||||
@@ -84,7 +84,7 @@ class MultiFormTest extends AjaxTestBase {
|
||||
$forms = $this->xpath($form_xpath);
|
||||
foreach ($forms as $offset => $form) {
|
||||
$form_html_id = (string) $form['id'];
|
||||
$this->drupalPostAjaxForm(NULL, array(), array($button_name => $button_value), NULL, array(), array(), $form_html_id);
|
||||
$this->drupalPostAjaxForm(NULL, [], [$button_name => $button_value], NULL, [], [], $form_html_id);
|
||||
$form = $this->xpath($form_xpath)[$offset];
|
||||
$field = $form->xpath('.' . $field_xpath);
|
||||
|
||||
|
||||
@@ -40,6 +40,28 @@ trait AssertPageCacheContextsAndTagsTrait {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts whether an expected cache context was present in the last response.
|
||||
*
|
||||
* @param string $expected_cache_context
|
||||
* The expected cache context.
|
||||
*/
|
||||
protected function assertCacheContext($expected_cache_context) {
|
||||
$cache_contexts = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Contexts'));
|
||||
$this->assertTrue(in_array($expected_cache_context, $cache_contexts), "'" . $expected_cache_context . "' is present in the X-Drupal-Cache-Contexts header.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a cache context was not present in the last response.
|
||||
*
|
||||
* @param string $not_expected_cache_context
|
||||
* The expected cache context.
|
||||
*/
|
||||
protected function assertNoCacheContext($not_expected_cache_context) {
|
||||
$cache_contexts = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Contexts'));
|
||||
$this->assertFalse(in_array($not_expected_cache_context, $cache_contexts), "'" . $not_expected_cache_context . "' is not present in the X-Drupal-Cache-Contexts header.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts page cache miss, then hit for the given URL; checks cache headers.
|
||||
*
|
||||
@@ -67,7 +89,7 @@ trait AssertPageCacheContextsAndTagsTrait {
|
||||
$this->assertCacheContexts($expected_contexts);
|
||||
|
||||
// Assert page cache item + expected cache tags.
|
||||
$cid_parts = array($url->setAbsolute()->toString(), 'html');
|
||||
$cid_parts = [$url->setAbsolute()->toString(), 'html'];
|
||||
$cid = implode(':', $cid_parts);
|
||||
$cache_entry = \Drupal::cache('render')->get($cid);
|
||||
sort($cache_entry->tags);
|
||||
@@ -100,10 +122,14 @@ trait AssertPageCacheContextsAndTagsTrait {
|
||||
*/
|
||||
protected function assertCacheTags(array $expected_tags, $include_default_tags = TRUE) {
|
||||
// The anonymous role cache tag is only added if the user is anonymous.
|
||||
if ($include_default_tags && \Drupal::currentUser()->isAnonymous()) {
|
||||
$expected_tags = Cache::mergeTags($expected_tags, ['config:user.role.anonymous']);
|
||||
if ($include_default_tags) {
|
||||
if (\Drupal::currentUser()->isAnonymous()) {
|
||||
$expected_tags = Cache::mergeTags($expected_tags, ['config:user.role.anonymous']);
|
||||
}
|
||||
$expected_tags[] = 'http_response';
|
||||
}
|
||||
$actual_tags = $this->getCacheHeaderValues('X-Drupal-Cache-Tags');
|
||||
$expected_tags = array_unique($expected_tags);
|
||||
sort($expected_tags);
|
||||
sort($actual_tags);
|
||||
$this->assertIdentical($actual_tags, $expected_tags);
|
||||
@@ -120,7 +146,7 @@ trait AssertPageCacheContextsAndTagsTrait {
|
||||
* @param bool $include_default_contexts
|
||||
* (optional) Whether the default contexts should automatically be included.
|
||||
*
|
||||
* @return
|
||||
* @return bool
|
||||
* TRUE if the assertion succeeded, FALSE otherwise.
|
||||
*/
|
||||
protected function assertCacheContexts(array $expected_contexts, $message = NULL, $include_default_contexts = TRUE) {
|
||||
@@ -137,12 +163,17 @@ trait AssertPageCacheContextsAndTagsTrait {
|
||||
$actual_contexts = $this->getCacheHeaderValues('X-Drupal-Cache-Contexts');
|
||||
sort($expected_contexts);
|
||||
sort($actual_contexts);
|
||||
$return = $this->assertIdentical($actual_contexts, $expected_contexts, $message);
|
||||
if (!$return) {
|
||||
$match = $actual_contexts === $expected_contexts;
|
||||
if (!$match) {
|
||||
debug('Unwanted cache contexts in response: ' . implode(',', array_diff($actual_contexts, $expected_contexts)));
|
||||
debug('Missing cache contexts in response: ' . implode(',', array_diff($expected_contexts, $actual_contexts)));
|
||||
}
|
||||
return $return;
|
||||
|
||||
$this->assertIdentical($actual_contexts, $expected_contexts, $message);
|
||||
|
||||
// For compatibility with both BrowserTestBase and WebTestBase always return
|
||||
// a boolean.
|
||||
return $match;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,9 @@ use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Provides helper methods for cache tests.
|
||||
*
|
||||
* @deprecated Scheduled for removal in Drupal 9.0.0.
|
||||
* Use \Drupal\Tests\system\Functional\Cache\CacheTestBase instead.
|
||||
*/
|
||||
abstract class CacheTestBase extends WebTestBase {
|
||||
|
||||
@@ -71,7 +74,7 @@ abstract class CacheTestBase extends WebTestBase {
|
||||
* @param $bin
|
||||
* The bin the cache item was stored in.
|
||||
*/
|
||||
function assertCacheRemoved($message, $cid = NULL, $bin = NULL) {
|
||||
public function assertCacheRemoved($message, $cid = NULL, $bin = NULL) {
|
||||
if ($bin == NULL) {
|
||||
$bin = $this->defaultBin;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@ use Drupal\simpletest\KernelTestBase;
|
||||
*
|
||||
* @see DatabaseBackendUnitTestCase
|
||||
* For a full working implementation.
|
||||
*
|
||||
* @deprecated as of Drupal 8.2.x, will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\KernelTests\Core\Cache\GenericCacheBackendUnitTestBase instead.
|
||||
*/
|
||||
abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
|
||||
@@ -102,7 +105,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
}
|
||||
|
||||
protected function setUp() {
|
||||
$this->cachebackends = array();
|
||||
$this->cachebackends = [];
|
||||
$this->defaultValue = $this->randomMachineName(10);
|
||||
|
||||
parent::setUp();
|
||||
@@ -131,7 +134,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
$backend = $this->getCacheBackend();
|
||||
|
||||
$this->assertIdentical(FALSE, $backend->get('test1'), "Backend does not contain data for cache id test1.");
|
||||
$with_backslash = array('foo' => '\Drupal\foo\Bar');
|
||||
$with_backslash = ['foo' => '\Drupal\foo\Bar'];
|
||||
$backend->set('test1', $with_backslash);
|
||||
$cached = $backend->get('test1');
|
||||
$this->assert(is_object($cached), "Backend returned an object for cache id test1.");
|
||||
@@ -142,10 +145,10 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
$this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.');
|
||||
|
||||
$this->assertIdentical(FALSE, $backend->get('test2'), "Backend does not contain data for cache id test2.");
|
||||
$backend->set('test2', array('value' => 3), REQUEST_TIME + 3);
|
||||
$backend->set('test2', ['value' => 3], REQUEST_TIME + 3);
|
||||
$cached = $backend->get('test2');
|
||||
$this->assert(is_object($cached), "Backend returned an object for cache id test2.");
|
||||
$this->assertIdentical(array('value' => 3), $cached->data);
|
||||
$this->assertIdentical(['value' => 3], $cached->data);
|
||||
$this->assertTrue($cached->valid, 'Item is marked as valid.');
|
||||
$this->assertTrue($cached->created >= REQUEST_TIME && $cached->created <= round(microtime(TRUE), 3), 'Created time is correct.');
|
||||
$this->assertEqual($cached->expire, REQUEST_TIME + 3, 'Expire time is correct.');
|
||||
@@ -159,7 +162,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
$this->assertEqual($cached->expire, REQUEST_TIME - 3, 'Expire time is correct.');
|
||||
|
||||
$this->assertIdentical(FALSE, $backend->get('test4'), "Backend does not contain data for cache id test4.");
|
||||
$with_eof = array('foo' => "\nEOF\ndata");
|
||||
$with_eof = ['foo' => "\nEOF\ndata"];
|
||||
$backend->set('test4', $with_eof);
|
||||
$cached = $backend->get('test4');
|
||||
$this->assert(is_object($cached), "Backend returned an object for cache id test4.");
|
||||
@@ -169,7 +172,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
$this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.');
|
||||
|
||||
$this->assertIdentical(FALSE, $backend->get('test5'), "Backend does not contain data for cache id test5.");
|
||||
$with_eof_and_semicolon = array('foo' => "\nEOF;\ndata");
|
||||
$with_eof_and_semicolon = ['foo' => "\nEOF;\ndata"];
|
||||
$backend->set('test5', $with_eof_and_semicolon);
|
||||
$cached = $backend->get('test5');
|
||||
$this->assert(is_object($cached), "Backend returned an object for cache id test5.");
|
||||
@@ -178,7 +181,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
$this->assertTrue($cached->created >= REQUEST_TIME && $cached->created <= round(microtime(TRUE), 3), 'Created time is correct.');
|
||||
$this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.');
|
||||
|
||||
$with_variable = array('foo' => '$bar');
|
||||
$with_variable = ['foo' => '$bar'];
|
||||
$backend->set('test6', $with_variable);
|
||||
$cached = $backend->get('test6');
|
||||
$this->assert(is_object($cached), "Backend returned an object for cache id test6.");
|
||||
@@ -257,14 +260,14 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
public function testValueTypeIsKept() {
|
||||
$backend = $this->getCacheBackend();
|
||||
|
||||
$variables = array(
|
||||
$variables = [
|
||||
'test1' => 1,
|
||||
'test2' => '0',
|
||||
'test3' => '',
|
||||
'test4' => 12.64,
|
||||
'test5' => FALSE,
|
||||
'test6' => array(1, 2, 3),
|
||||
);
|
||||
'test6' => [1, 2, 3],
|
||||
];
|
||||
|
||||
// Create cache entries.
|
||||
foreach ($variables as $cid => $data) {
|
||||
@@ -297,14 +300,14 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
$backend->set($long_cid, 300);
|
||||
|
||||
// Mismatch order for harder testing.
|
||||
$reference = array(
|
||||
$reference = [
|
||||
'test3',
|
||||
'test7',
|
||||
'test21', // Cid does not exist.
|
||||
'test6',
|
||||
'test19', // Cid does not exist until added before second getMultiple().
|
||||
'test2',
|
||||
);
|
||||
];
|
||||
|
||||
$cids = $reference;
|
||||
$ret = $backend->getMultiple($cids);
|
||||
@@ -364,7 +367,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
$this->assertFalse(in_array('test19', $cids), "Added cache id test19 is not in cids array.");
|
||||
|
||||
// Test with a long $cid and non-numeric array key.
|
||||
$cids = array('key:key' => $long_cid);
|
||||
$cids = ['key:key' => $long_cid];
|
||||
$return = $backend->getMultiple($cids);
|
||||
$this->assertEqual(300, $return[$long_cid]->data);
|
||||
$this->assertTrue(empty($cids));
|
||||
@@ -380,13 +383,13 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
|
||||
// Set multiple testing keys.
|
||||
$backend->set('cid_1', 'Some other value');
|
||||
$items = array(
|
||||
'cid_1' => array('data' => 1),
|
||||
'cid_2' => array('data' => 2),
|
||||
'cid_3' => array('data' => array(1, 2)),
|
||||
'cid_4' => array('data' => 1, 'expire' => $future_expiration),
|
||||
'cid_5' => array('data' => 1, 'tags' => array('test:a', 'test:b')),
|
||||
);
|
||||
$items = [
|
||||
'cid_1' => ['data' => 1],
|
||||
'cid_2' => ['data' => 2],
|
||||
'cid_3' => ['data' => [1, 2]],
|
||||
'cid_4' => ['data' => 1, 'expire' => $future_expiration],
|
||||
'cid_5' => ['data' => 1, 'tags' => ['test:a', 'test:b']],
|
||||
];
|
||||
$backend->setMultiple($items);
|
||||
$cids = array_keys($items);
|
||||
$cached = $backend->getMultiple($cids);
|
||||
@@ -411,9 +414,9 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
// assertion.
|
||||
try {
|
||||
$items = [
|
||||
'exception_test_1' => array('data' => 1, 'tags' => []),
|
||||
'exception_test_2' => array('data' => 2, 'tags' => ['valid']),
|
||||
'exception_test_3' => array('data' => 3, 'tags' => ['node' => [3, 5, 7]]),
|
||||
'exception_test_1' => ['data' => 1, 'tags' => []],
|
||||
'exception_test_2' => ['data' => 2, 'tags' => ['valid']],
|
||||
'exception_test_3' => ['data' => 3, 'tags' => ['node' => [3, 5, 7]]],
|
||||
];
|
||||
$backend->setMultiple($items);
|
||||
$this->fail('::setMultiple() was called with invalid cache tags, runtime assertion did not fail.');
|
||||
@@ -441,13 +444,13 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
|
||||
$backend->delete('test1');
|
||||
$backend->delete('test23'); // Nonexistent key should not cause an error.
|
||||
$backend->deleteMultiple(array(
|
||||
$backend->deleteMultiple([
|
||||
'test3',
|
||||
'test5',
|
||||
'test7',
|
||||
'test19', // Nonexistent key should not cause an error.
|
||||
'test21', // Nonexistent key should not cause an error.
|
||||
));
|
||||
]);
|
||||
|
||||
// Test if expected keys have been deleted.
|
||||
$this->assertIdentical(FALSE, $backend->get('test1'), "Cache id test1 deleted.");
|
||||
@@ -465,7 +468,7 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
$this->assertIdentical(FALSE, $backend->get('test21'), "Cache id test21 does not exist.");
|
||||
|
||||
// Calling deleteMultiple() with an empty array should not cause an error.
|
||||
$this->assertFalse($backend->deleteMultiple(array()));
|
||||
$this->assertFalse($backend->deleteMultiple([]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -491,21 +494,21 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
* Test Drupal\Core\Cache\CacheBackendInterface::invalidate() and
|
||||
* Drupal\Core\Cache\CacheBackendInterface::invalidateMultiple().
|
||||
*/
|
||||
function testInvalidate() {
|
||||
public function testInvalidate() {
|
||||
$backend = $this->getCacheBackend();
|
||||
$backend->set('test1', 1);
|
||||
$backend->set('test2', 2);
|
||||
$backend->set('test3', 2);
|
||||
$backend->set('test4', 2);
|
||||
|
||||
$reference = array('test1', 'test2', 'test3', 'test4');
|
||||
$reference = ['test1', 'test2', 'test3', 'test4'];
|
||||
|
||||
$cids = $reference;
|
||||
$ret = $backend->getMultiple($cids);
|
||||
$this->assertEqual(count($ret), 4, 'Four items returned.');
|
||||
|
||||
$backend->invalidate('test1');
|
||||
$backend->invalidateMultiple(array('test2', 'test3'));
|
||||
$backend->invalidateMultiple(['test2', 'test3']);
|
||||
|
||||
$cids = $reference;
|
||||
$ret = $backend->getMultiple($cids);
|
||||
@@ -517,55 +520,55 @@ abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
|
||||
|
||||
// Calling invalidateMultiple() with an empty array should not cause an
|
||||
// error.
|
||||
$this->assertFalse($backend->invalidateMultiple(array()));
|
||||
$this->assertFalse($backend->invalidateMultiple([]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Drupal\Core\Cache\CacheBackendInterface::invalidateTags().
|
||||
*/
|
||||
function testInvalidateTags() {
|
||||
public function testInvalidateTags() {
|
||||
$backend = $this->getCacheBackend();
|
||||
|
||||
// Create two cache entries with the same tag and tag value.
|
||||
$backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:2'));
|
||||
$backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:2'));
|
||||
$backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, ['test_tag:2']);
|
||||
$backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, ['test_tag:2']);
|
||||
$this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.');
|
||||
|
||||
// Invalidate test_tag of value 1. This should invalidate both entries.
|
||||
Cache::invalidateTags(array('test_tag:2'));
|
||||
Cache::invalidateTags(['test_tag:2']);
|
||||
$this->assertFalse($backend->get('test_cid_invalidate1') || $backend->get('test_cid_invalidate2'), 'Two cache items invalidated after invalidating a cache tag.');
|
||||
$this->assertTrue($backend->get('test_cid_invalidate1', TRUE) && $backend->get('test_cid_invalidate2', TRUE), 'Cache items not deleted after invalidating a cache tag.');
|
||||
|
||||
// Create two cache entries with the same tag and an array tag value.
|
||||
$backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:1'));
|
||||
$backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:1'));
|
||||
$backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, ['test_tag:1']);
|
||||
$backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, ['test_tag:1']);
|
||||
$this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.');
|
||||
|
||||
// Invalidate test_tag of value 1. This should invalidate both entries.
|
||||
Cache::invalidateTags(array('test_tag:1'));
|
||||
Cache::invalidateTags(['test_tag:1']);
|
||||
$this->assertFalse($backend->get('test_cid_invalidate1') || $backend->get('test_cid_invalidate2'), 'Two caches removed after invalidating a cache tag.');
|
||||
$this->assertTrue($backend->get('test_cid_invalidate1', TRUE) && $backend->get('test_cid_invalidate2', TRUE), 'Cache items not deleted after invalidating a cache tag.');
|
||||
|
||||
// Create three cache entries with a mix of tags and tag values.
|
||||
$backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:1'));
|
||||
$backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:2'));
|
||||
$backend->set('test_cid_invalidate3', $this->defaultValue, Cache::PERMANENT, array('test_tag_foo:3'));
|
||||
$backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, ['test_tag:1']);
|
||||
$backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, ['test_tag:2']);
|
||||
$backend->set('test_cid_invalidate3', $this->defaultValue, Cache::PERMANENT, ['test_tag_foo:3']);
|
||||
$this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2') && $backend->get('test_cid_invalidate3'), 'Three cached items were created.');
|
||||
Cache::invalidateTags(array('test_tag_foo:3'));
|
||||
Cache::invalidateTags(['test_tag_foo:3']);
|
||||
$this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Cache items not matching the tag were not invalidated.');
|
||||
$this->assertFalse($backend->get('test_cid_invalidated3'), 'Cached item matching the tag was removed.');
|
||||
|
||||
// Create cache entry in multiple bins. Two cache entries
|
||||
// (test_cid_invalidate1 and test_cid_invalidate2) still exist from previous
|
||||
// tests.
|
||||
$tags = array('test_tag:1', 'test_tag:2', 'test_tag:3');
|
||||
$bins = array('path', 'bootstrap', 'page');
|
||||
$tags = ['test_tag:1', 'test_tag:2', 'test_tag:3'];
|
||||
$bins = ['path', 'bootstrap', 'page'];
|
||||
foreach ($bins as $bin) {
|
||||
$this->getCacheBackend($bin)->set('test', $this->defaultValue, Cache::PERMANENT, $tags);
|
||||
$this->assertTrue($this->getCacheBackend($bin)->get('test'), 'Cache item was set in bin.');
|
||||
}
|
||||
|
||||
Cache::invalidateTags(array('test_tag:2'));
|
||||
Cache::invalidateTags(['test_tag:2']);
|
||||
|
||||
// Test that the cache entry has been invalidated in multiple bins.
|
||||
foreach ($bins as $bin) {
|
||||
|
||||
@@ -8,6 +8,9 @@ use Drupal\Component\Utility\SafeMarkup;
|
||||
|
||||
/**
|
||||
* Provides helper methods for page cache tags tests.
|
||||
*
|
||||
* @deprecated Scheduled for removal in Drupal 9.0.0.
|
||||
* Use \Drupal\Tests\system\Functional\Cache\PageCacheTagsTestBase instead.
|
||||
*/
|
||||
abstract class PageCacheTagsTestBase extends WebTestBase {
|
||||
|
||||
@@ -38,18 +41,18 @@ abstract class PageCacheTagsTestBase extends WebTestBase {
|
||||
* @param string $hit_or_miss
|
||||
* 'HIT' if a page cache hit is expected, 'MISS' otherwise.
|
||||
*
|
||||
* @param array|FALSE $tags
|
||||
* @param array|false $tags
|
||||
* When expecting a page cache hit, you may optionally specify an array of
|
||||
* expected cache tags. While FALSE, the cache tags will not be verified.
|
||||
*/
|
||||
protected function verifyPageCache(Url $url, $hit_or_miss, $tags = FALSE) {
|
||||
$this->drupalGet($url);
|
||||
$message = SafeMarkup::format('Page cache @hit_or_miss for %path.', array('@hit_or_miss' => $hit_or_miss, '%path' => $url->toString()));
|
||||
$message = SafeMarkup::format('Page cache @hit_or_miss for %path.', ['@hit_or_miss' => $hit_or_miss, '%path' => $url->toString()]);
|
||||
$this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), $hit_or_miss, $message);
|
||||
|
||||
if ($hit_or_miss === 'HIT' && is_array($tags)) {
|
||||
$absolute_url = $url->setAbsolute()->toString();
|
||||
$cid_parts = array($absolute_url, 'html');
|
||||
$cid_parts = [$absolute_url, 'html'];
|
||||
$cid = implode(':', $cid_parts);
|
||||
$cache_entry = \Drupal::cache('render')->get($cid);
|
||||
sort($cache_entry->tags);
|
||||
|
||||
@@ -58,7 +58,7 @@ class SessionExistsCacheContextTest extends WebTestBase {
|
||||
/**
|
||||
* Asserts whether a session cookie is present on the client or not.
|
||||
*/
|
||||
function assertSessionCookieOnClient($expected_present) {
|
||||
public function assertSessionCookieOnClient($expected_present) {
|
||||
$non_deleted_cookies = array_filter($this->cookies, function ($item) { return $item['value'] !== 'deleted'; });
|
||||
$this->assertEqual($expected_present, isset($non_deleted_cookies[$this->getSessionName()]), 'Session cookie exists.');
|
||||
}
|
||||
|
||||
@@ -15,41 +15,41 @@ class AddFeedTest extends WebTestBase {
|
||||
/**
|
||||
* Tests attaching feeds with paths, URLs, and titles.
|
||||
*/
|
||||
function testBasicFeedAddNoTitle() {
|
||||
public function testBasicFeedAddNoTitle() {
|
||||
$path = $this->randomMachineName(12);
|
||||
$external_url = 'http://' . $this->randomMachineName(12) . '/' . $this->randomMachineName(12);
|
||||
$fully_qualified_local_url = Url::fromUri('base:' . $this->randomMachineName(12), array('absolute' => TRUE))->toString();
|
||||
$fully_qualified_local_url = Url::fromUri('base:' . $this->randomMachineName(12), ['absolute' => TRUE])->toString();
|
||||
|
||||
$path_for_title = $this->randomMachineName(12);
|
||||
$external_for_title = 'http://' . $this->randomMachineName(12) . '/' . $this->randomMachineName(12);
|
||||
$fully_qualified_for_title = Url::fromUri('base:' . $this->randomMachineName(12), array('absolute' => TRUE))->toString();
|
||||
$fully_qualified_for_title = Url::fromUri('base:' . $this->randomMachineName(12), ['absolute' => TRUE])->toString();
|
||||
|
||||
$urls = array(
|
||||
'path without title' => array(
|
||||
'url' => Url::fromUri('base:' . $path, array('absolute' => TRUE))->toString(),
|
||||
$urls = [
|
||||
'path without title' => [
|
||||
'url' => Url::fromUri('base:' . $path, ['absolute' => TRUE])->toString(),
|
||||
'title' => '',
|
||||
),
|
||||
'external URL without title' => array(
|
||||
],
|
||||
'external URL without title' => [
|
||||
'url' => $external_url,
|
||||
'title' => '',
|
||||
),
|
||||
'local URL without title' => array(
|
||||
],
|
||||
'local URL without title' => [
|
||||
'url' => $fully_qualified_local_url,
|
||||
'title' => '',
|
||||
),
|
||||
'path with title' => array(
|
||||
'url' => Url::fromUri('base:' . $path_for_title, array('absolute' => TRUE))->toString(),
|
||||
],
|
||||
'path with title' => [
|
||||
'url' => Url::fromUri('base:' . $path_for_title, ['absolute' => TRUE])->toString(),
|
||||
'title' => $this->randomMachineName(12),
|
||||
),
|
||||
'external URL with title' => array(
|
||||
],
|
||||
'external URL with title' => [
|
||||
'url' => $external_for_title,
|
||||
'title' => $this->randomMachineName(12),
|
||||
),
|
||||
'local URL with title' => array(
|
||||
],
|
||||
'local URL with title' => [
|
||||
'url' => $fully_qualified_for_title,
|
||||
'title' => $this->randomMachineName(12),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$build = [];
|
||||
foreach ($urls as $feed_info) {
|
||||
@@ -63,14 +63,14 @@ class AddFeedTest extends WebTestBase {
|
||||
$this->setRawContent($response->getContent());
|
||||
// Assert that the content contains the RSS links we specified.
|
||||
foreach ($urls as $description => $feed_info) {
|
||||
$this->assertPattern($this->urlToRSSLinkPattern($feed_info['url'], $feed_info['title']), format_string('Found correct feed header for %description', array('%description' => $description)));
|
||||
$this->assertPattern($this->urlToRSSLinkPattern($feed_info['url'], $feed_info['title']), format_string('Found correct feed header for %description', ['%description' => $description]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a pattern representing the RSS feed in the page.
|
||||
*/
|
||||
function urlToRSSLinkPattern($url, $title = '') {
|
||||
public function urlToRSSLinkPattern($url, $title = '') {
|
||||
// Escape any regular expression characters in the URL ('?' is the worst).
|
||||
$url = preg_replace('/([+?.*])/', '[$0]', $url);
|
||||
$generated_pattern = '%<link +href="' . $url . '" +rel="alternate" +title="' . $title . '" +type="application/rss.xml" */>%';
|
||||
@@ -82,12 +82,12 @@ class AddFeedTest extends WebTestBase {
|
||||
*
|
||||
* @see https://www.drupal.org/node/1211668
|
||||
*/
|
||||
function testFeedIconEscaping() {
|
||||
$variables = array(
|
||||
public function testFeedIconEscaping() {
|
||||
$variables = [
|
||||
'#theme' => 'feed_icon',
|
||||
'#url' => 'node',
|
||||
'#title' => '<>&"\'',
|
||||
);
|
||||
];
|
||||
$text = \Drupal::service('renderer')->renderRoot($variables);
|
||||
$this->assertEqual(trim(strip_tags($text)), 'Subscribe to <>&"'', 'feed_icon template escapes reserved HTML characters.');
|
||||
}
|
||||
|
||||
@@ -16,24 +16,24 @@ class AlterTest extends WebTestBase {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('block', 'common_test');
|
||||
public static $modules = ['block', 'common_test'];
|
||||
|
||||
/**
|
||||
* Tests if the theme has been altered.
|
||||
*/
|
||||
function testDrupalAlter() {
|
||||
public function testDrupalAlter() {
|
||||
// This test depends on Bartik, so make sure that it is always the current
|
||||
// active theme.
|
||||
\Drupal::service('theme_handler')->install(array('bartik'));
|
||||
\Drupal::service('theme_handler')->install(['bartik']);
|
||||
\Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('bartik'));
|
||||
|
||||
$array = array('foo' => 'bar');
|
||||
$array = ['foo' => 'bar'];
|
||||
$entity = new \stdClass();
|
||||
$entity->foo = 'bar';
|
||||
|
||||
// Verify alteration of a single argument.
|
||||
$array_copy = $array;
|
||||
$array_expected = array('foo' => 'Drupal theme');
|
||||
$array_expected = ['foo' => 'Drupal theme'];
|
||||
\Drupal::moduleHandler()->alter('drupal_alter', $array_copy);
|
||||
\Drupal::theme()->alter('drupal_alter', $array_copy);
|
||||
$this->assertEqual($array_copy, $array_expected, 'Single array was altered.');
|
||||
@@ -47,12 +47,12 @@ class AlterTest extends WebTestBase {
|
||||
|
||||
// Verify alteration of multiple arguments.
|
||||
$array_copy = $array;
|
||||
$array_expected = array('foo' => 'Drupal theme');
|
||||
$array_expected = ['foo' => 'Drupal theme'];
|
||||
$entity_copy = clone $entity;
|
||||
$entity_expected = clone $entity;
|
||||
$entity_expected->foo = 'Drupal theme';
|
||||
$array2_copy = $array;
|
||||
$array2_expected = array('foo' => 'Drupal theme');
|
||||
$array2_expected = ['foo' => 'Drupal theme'];
|
||||
\Drupal::moduleHandler()->alter('drupal_alter', $array_copy, $entity_copy, $array2_copy);
|
||||
\Drupal::theme()->alter('drupal_alter', $array_copy, $entity_copy, $array2_copy);
|
||||
$this->assertEqual($array_copy, $array_expected, 'First argument to \Drupal::moduleHandler->alter() was altered.');
|
||||
@@ -63,9 +63,9 @@ class AlterTest extends WebTestBase {
|
||||
// common_test_module_implements_alter() places 'block' implementation after
|
||||
// other modules.
|
||||
$array_copy = $array;
|
||||
$array_expected = array('foo' => 'Drupal block theme');
|
||||
\Drupal::moduleHandler()->alter(array('drupal_alter', 'drupal_alter_foo'), $array_copy);
|
||||
\Drupal::theme()->alter(array('drupal_alter', 'drupal_alter_foo'), $array_copy);
|
||||
$array_expected = ['foo' => 'Drupal block theme'];
|
||||
\Drupal::moduleHandler()->alter(['drupal_alter', 'drupal_alter_foo'], $array_copy);
|
||||
\Drupal::theme()->alter(['drupal_alter', 'drupal_alter_foo'], $array_copy);
|
||||
$this->assertEqual($array_copy, $array_expected, 'hook_TYPE_alter() implementations ran in correct order.');
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class EarlyRenderingControllerTest extends WebTestBase {
|
||||
/**
|
||||
* Tests theme preprocess functions being able to attach assets.
|
||||
*/
|
||||
function testEarlyRendering() {
|
||||
public function testEarlyRendering() {
|
||||
// Render array: non-early & early.
|
||||
$this->drupalGet(Url::fromRoute('early_rendering_controller_test.render_array'));
|
||||
$this->assertResponse(200);
|
||||
|
||||
@@ -17,7 +17,7 @@ class FormatDateTest extends WebTestBase {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('language');
|
||||
public static $modules = ['language'];
|
||||
|
||||
/**
|
||||
* Arbitrary langcode for a custom language.
|
||||
@@ -32,16 +32,16 @@ class FormatDateTest extends WebTestBase {
|
||||
->save();
|
||||
$formats = $this->container->get('entity.manager')
|
||||
->getStorage('date_format')
|
||||
->loadMultiple(array('long', 'medium', 'short'));
|
||||
->loadMultiple(['long', 'medium', 'short']);
|
||||
$formats['long']->setPattern('l, j. F Y - G:i')->save();
|
||||
$formats['medium']->setPattern('j. F Y - G:i')->save();
|
||||
$formats['short']->setPattern('Y M j - g:ia')->save();
|
||||
$this->refreshVariables();
|
||||
|
||||
$this->settingsSet('locale_custom_strings_' . self::LANGCODE, array(
|
||||
'' => array('Sunday' => 'domingo'),
|
||||
'Long month name' => array('March' => 'marzo'),
|
||||
));
|
||||
$this->settingsSet('locale_custom_strings_' . self::LANGCODE, [
|
||||
'' => ['Sunday' => 'domingo'],
|
||||
'Long month name' => ['March' => 'marzo'],
|
||||
]);
|
||||
|
||||
ConfigurableLanguage::createFromLangcode(static::LANGCODE)->save();
|
||||
$this->resetAll();
|
||||
@@ -50,24 +50,24 @@ class FormatDateTest extends WebTestBase {
|
||||
/**
|
||||
* Tests admin-defined formats in format_date().
|
||||
*/
|
||||
function testAdminDefinedFormatDate() {
|
||||
public function testAdminDefinedFormatDate() {
|
||||
// Create and log in an admin user.
|
||||
$this->drupalLogin($this->drupalCreateUser(array('administer site configuration')));
|
||||
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
|
||||
|
||||
// Add new date format.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'id' => 'example_style',
|
||||
'label' => 'Example Style',
|
||||
'date_format_pattern' => 'j M y',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
|
||||
|
||||
// Add a second date format with a different case than the first.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'id' => 'example_style_uppercase',
|
||||
'label' => 'Example Style Uppercase',
|
||||
'date_format_pattern' => 'j M Y',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
|
||||
$this->assertText(t('Custom date format added.'));
|
||||
|
||||
@@ -77,46 +77,4 @@ class FormatDateTest extends WebTestBase {
|
||||
$this->assertIdentical(format_date($timestamp, 'undefined_style'), format_date($timestamp, 'fallback'), 'Test format_date() defaulting to `fallback` when $type not found.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the format_date() function.
|
||||
*/
|
||||
function testFormatDate() {
|
||||
$timestamp = strtotime('2007-03-26T00:00:00+00:00');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test all parameters.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'domingo, 25-Mar-07 17:00:00 PDT', 'Test translated format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', '\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), 'l, 25-Mar-07 17:00:00 PDT', 'Test an escaped format string.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', '\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), '\\domingo, 25-Mar-07 17:00:00 PDT', 'Test format containing backslash character.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', '\\\\\\l, d-M-y H:i:s T', 'America/Los_Angeles', self::LANGCODE), '\\l, 25-Mar-07 17:00:00 PDT', 'Test format containing backslash followed by escaped format string.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London', 'en'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.');
|
||||
|
||||
// Change the default language and timezone.
|
||||
$this->config('system.site')->set('default_langcode', static::LANGCODE)->save();
|
||||
date_default_timezone_set('America/Los_Angeles');
|
||||
|
||||
// Reset the language manager so new negotiations attempts will fall back on
|
||||
// on the new language.
|
||||
$this->container->get('language_manager')->reset();
|
||||
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'America/Los_Angeles', 'en'), 'Sunday, 25-Mar-07 17:00:00 PDT', 'Test a different language.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T', 'Europe/London'), 'Monday, 26-Mar-07 01:00:00 BST', 'Test a different time zone.');
|
||||
$this->assertIdentical(format_date($timestamp, 'custom', 'l, d-M-y H:i:s T'), 'domingo, 25-Mar-07 17:00:00 PDT', 'Test custom date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'long'), 'domingo, 25. marzo 2007 - 17:00', 'Test long date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'medium'), '25. marzo 2007 - 17:00', 'Test medium date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'short'), '2007 Mar 25 - 5:00pm', 'Test short date format.');
|
||||
$this->assertIdentical(format_date($timestamp), '25. marzo 2007 - 17:00', 'Test default date format.');
|
||||
// Test HTML time element formats.
|
||||
$this->assertIdentical(format_date($timestamp, 'html_datetime'), '2007-03-25T17:00:00-0700', 'Test html_datetime date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'html_date'), '2007-03-25', 'Test html_date date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'html_time'), '17:00:00', 'Test html_time date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'html_yearless_date'), '03-25', 'Test html_yearless_date date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'html_week'), '2007-W12', 'Test html_week date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'html_month'), '2007-03', 'Test html_month date format.');
|
||||
$this->assertIdentical(format_date($timestamp, 'html_year'), '2007', 'Test html_year date format.');
|
||||
|
||||
// HTML is not escaped by the date formatter, it must be escaped later.
|
||||
$formatter = \Drupal::service('date.formatter');
|
||||
$this->assertIdentical($formatter->format($timestamp, 'custom', '\<\s\c\r\i\p\t\>\a\l\e\r\t\(\'Y\'\)\;\<\/\s\c\r\i\p\t\>'), "<script>alert('2007');</script>", 'Script tags not removed from dates.');
|
||||
$this->assertIdentical($formatter->format($timestamp, 'custom', '\<\e\m\>Y\<\/\e\m\>'), '<em>2007</em>', 'Em tags are not removed from dates.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Drupal\system\Tests\Common;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\node\NodeInterface;
|
||||
|
||||
/**
|
||||
* Tests that anonymous users are not served any JavaScript in the Standard
|
||||
@@ -18,7 +19,7 @@ class NoJavaScriptAnonymousTest extends WebTestBase {
|
||||
parent::setUp();
|
||||
|
||||
// Grant the anonymous user the permission to look at user profiles.
|
||||
user_role_grant_permissions('anonymous', array('access user profiles'));
|
||||
user_role_grant_permissions('anonymous', ['access user profiles']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,9 +27,9 @@ class NoJavaScriptAnonymousTest extends WebTestBase {
|
||||
*/
|
||||
public function testNoJavaScript() {
|
||||
// Create a node that is listed on the frontpage.
|
||||
$this->drupalCreateNode(array(
|
||||
'promote' => NODE_PROMOTED,
|
||||
));
|
||||
$this->drupalCreateNode([
|
||||
'promote' => NodeInterface::PROMOTED,
|
||||
]);
|
||||
$user = $this->drupalCreateUser();
|
||||
|
||||
// Test frontpage.
|
||||
|
||||
@@ -19,12 +19,12 @@ class RenderWebTest extends WebTestBase {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('common_test');
|
||||
public static $modules = ['common_test'];
|
||||
|
||||
/**
|
||||
* Asserts the cache context for the wrapper format is always present.
|
||||
*/
|
||||
function testWrapperFormatCacheContext() {
|
||||
public function testWrapperFormatCacheContext() {
|
||||
$this->drupalGet('common-test/type-link-active-class');
|
||||
$this->assertIdentical(0, strpos($this->getRawContent(), "<!DOCTYPE html>\n<html"));
|
||||
$this->assertIdentical('text/html; charset=UTF-8', $this->drupalGetHeader('Content-Type'));
|
||||
@@ -43,135 +43,135 @@ class RenderWebTest extends WebTestBase {
|
||||
* Tests rendering form elements without passing through
|
||||
* \Drupal::formBuilder()->doBuildForm().
|
||||
*/
|
||||
function testDrupalRenderFormElements() {
|
||||
public function testDrupalRenderFormElements() {
|
||||
// Define a series of form elements.
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'button',
|
||||
'#value' => $this->randomMachineName(),
|
||||
);
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'submit'));
|
||||
];
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'submit']);
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->randomMachineName(),
|
||||
'#value' => $this->randomMachineName(),
|
||||
);
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'text'));
|
||||
];
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'text']);
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'password',
|
||||
'#title' => $this->randomMachineName(),
|
||||
);
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'password'));
|
||||
];
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'password']);
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'textarea',
|
||||
'#title' => $this->randomMachineName(),
|
||||
'#value' => $this->randomMachineName(),
|
||||
);
|
||||
];
|
||||
$this->assertRenderedElement($element, '//textarea');
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'radio',
|
||||
'#title' => $this->randomMachineName(),
|
||||
'#value' => FALSE,
|
||||
);
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'radio'));
|
||||
];
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'radio']);
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->randomMachineName(),
|
||||
);
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'checkbox'));
|
||||
];
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'checkbox']);
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->randomMachineName(),
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
0 => $this->randomMachineName(),
|
||||
1 => $this->randomMachineName(),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertRenderedElement($element, '//select');
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'file',
|
||||
'#title' => $this->randomMachineName(),
|
||||
);
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'file'));
|
||||
];
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'file']);
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'item',
|
||||
'#title' => $this->randomMachineName(),
|
||||
'#markup' => $this->randomMachineName(),
|
||||
);
|
||||
$this->assertRenderedElement($element, '//div[contains(@class, :class) and contains(., :markup)]/label[contains(., :label)]', array(
|
||||
];
|
||||
$this->assertRenderedElement($element, '//div[contains(@class, :class) and contains(., :markup)]/label[contains(., :label)]', [
|
||||
':class' => 'js-form-type-item',
|
||||
':markup' => $element['#markup'],
|
||||
':label' => $element['#title'],
|
||||
));
|
||||
]);
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'hidden',
|
||||
'#title' => $this->randomMachineName(),
|
||||
'#value' => $this->randomMachineName(),
|
||||
);
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'hidden'));
|
||||
];
|
||||
$this->assertRenderedElement($element, '//input[@type=:type]', [':type' => 'hidden']);
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'link',
|
||||
'#title' => $this->randomMachineName(),
|
||||
'#url' => Url::fromRoute('common_test.destination'),
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
'absolute' => TRUE,
|
||||
),
|
||||
);
|
||||
$this->assertRenderedElement($element, '//a[@href=:href and contains(., :title)]', array(
|
||||
],
|
||||
];
|
||||
$this->assertRenderedElement($element, '//a[@href=:href and contains(., :title)]', [
|
||||
':href' => URL::fromRoute('common_test.destination')->setAbsolute()->toString(),
|
||||
':title' => $element['#title'],
|
||||
));
|
||||
]);
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'details',
|
||||
'#open' => TRUE,
|
||||
'#title' => $this->randomMachineName(),
|
||||
);
|
||||
$this->assertRenderedElement($element, '//details/summary[contains(., :title)]', array(
|
||||
];
|
||||
$this->assertRenderedElement($element, '//details/summary[contains(., :title)]', [
|
||||
':title' => $element['#title'],
|
||||
));
|
||||
]);
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'details',
|
||||
'#open' => TRUE,
|
||||
'#title' => $this->randomMachineName(),
|
||||
);
|
||||
];
|
||||
$this->assertRenderedElement($element, '//details');
|
||||
|
||||
$element['item'] = array(
|
||||
$element['item'] = [
|
||||
'#type' => 'item',
|
||||
'#title' => $this->randomMachineName(),
|
||||
'#markup' => $this->randomMachineName(),
|
||||
);
|
||||
$this->assertRenderedElement($element, '//details/div/div[contains(@class, :class) and contains(., :markup)]', array(
|
||||
];
|
||||
$this->assertRenderedElement($element, '//details/div/div[contains(@class, :class) and contains(., :markup)]', [
|
||||
':class' => 'js-form-type-item',
|
||||
':markup' => $element['item']['#markup'],
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that elements are rendered properly.
|
||||
*/
|
||||
protected function assertRenderedElement(array $element, $xpath, array $xpath_args = array()) {
|
||||
protected function assertRenderedElement(array $element, $xpath, array $xpath_args = []) {
|
||||
$original_element = $element;
|
||||
$this->setRawContent(drupal_render_root($element));
|
||||
$this->verbose('<hr />' . $this->getRawContent());
|
||||
|
||||
// @see \Drupal\simpletest\WebTestBase::xpath()
|
||||
$xpath = $this->buildXPathQuery($xpath, $xpath_args);
|
||||
$element += array('#value' => NULL);
|
||||
$this->assertFieldByXPath($xpath, $element['#value'], format_string('#type @type was properly rendered.', array(
|
||||
$element += ['#value' => NULL];
|
||||
$this->assertFieldByXPath($xpath, $element['#value'], format_string('#type @type was properly rendered.', [
|
||||
'@type' => var_export($element['#type'], TRUE),
|
||||
)));
|
||||
]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user