Skip to content
Snippets Groups Projects
Commit 4d0ded58 authored by greenskin's avatar greenskin
Browse files

Issue #2866242 by Munavijayalakshmi, amit.drupal, joelpittet, greenSkin:...

Issue #2866242 by Munavijayalakshmi, amit.drupal, joelpittet, greenSkin: Convert module to use short array syntax (new coding standard)
parent 7a3c1dfb
Branches
Tags
No related merge requests found
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
*/ */
function module_filter_install() { function module_filter_install() {
$state = \Drupal::state(); $state = \Drupal::state();
$state->set('module_filter.recent', array('module_filter' => REQUEST_TIME)); $state->set('module_filter.recent', ['module_filter' => REQUEST_TIME]);
} }
/** /**
......
...@@ -25,31 +25,31 @@ function module_filter_form_system_modules_alter(&$form, FormStateInterface $for ...@@ -25,31 +25,31 @@ function module_filter_form_system_modules_alter(&$form, FormStateInterface $for
$form['filters']['text']['#default_value'] = $_GET['filter']; $form['filters']['text']['#default_value'] = $_GET['filter'];
} }
$status_defaults = array( $status_defaults = [
((isset($_GET['enabled'])) ? $_GET['enabled'] : 1) ? 'enabled' : '', ((isset($_GET['enabled'])) ? $_GET['enabled'] : 1) ? 'enabled' : '',
((isset($_GET['disabled'])) ? $_GET['disabled'] : 1) ? 'disabled' : '', ((isset($_GET['disabled'])) ? $_GET['disabled'] : 1) ? 'disabled' : '',
((isset($_GET['unavailable'])) ? $_GET['unavailable'] : 1) ? 'unavailable' : '', ((isset($_GET['unavailable'])) ? $_GET['unavailable'] : 1) ? 'unavailable' : '',
); ];
$form['filters']['status'] = array( $form['filters']['status'] = [
'#type' => 'container', '#type' => 'container',
'#attributes' => array( '#attributes' => [
'class' => array( 'class' => [
'module-filter-status', 'module-filter-status',
), ],
), ],
'checkboxes' => array( 'checkboxes' => [
'#type' => 'checkboxes', '#type' => 'checkboxes',
'#default_value' => array_filter($status_defaults), '#default_value' => array_filter($status_defaults),
'#options' => array( '#options' => [
'enabled' => t('Enabled'), 'enabled' => t('Enabled'),
'disabled' => t('Disabled'), 'disabled' => t('Disabled'),
'unavailable' => t('Unavailable'), 'unavailable' => t('Unavailable'),
), ],
), ],
); ];
$state = \Drupal::state(); $state = \Drupal::state();
$recent = $state->get('module_filter.recent') ?: array(); $recent = $state->get('module_filter.recent') ?: [];
// Remove recent items older than a week. // Remove recent items older than a week.
$recent = array_filter($recent, function ($val) { $recent = array_filter($recent, function ($val) {
...@@ -92,10 +92,10 @@ function module_filter_form_system_modules_alter(&$form, FormStateInterface $for ...@@ -92,10 +92,10 @@ function module_filter_form_system_modules_alter(&$form, FormStateInterface $for
* Implements hook_form_FORM_ID_alter(). * Implements hook_form_FORM_ID_alter().
*/ */
function module_filter_form_system_modules_confirm_form_alter(&$form, FormStateInterface $form_state, $form_id) { function module_filter_form_system_modules_confirm_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['filters']['text'] = array( $form['filters']['text'] = [
'#type' => 'value', '#type' => 'value',
'#value' => isset($_GET['filter']) ? $_GET['filter'] : '', '#value' => isset($_GET['filter']) ? $_GET['filter'] : '',
); ];
$form['#submit'][] = 'module_filter_system_modules_redirect_submit'; $form['#submit'][] = 'module_filter_system_modules_redirect_submit';
} }
...@@ -164,7 +164,7 @@ function module_filter_preprocess_system_modules_details(&$variables) { ...@@ -164,7 +164,7 @@ function module_filter_preprocess_system_modules_details(&$variables) {
*/ */
function module_filter_system_modules_recent_enabled_submit($form, FormStateInterface $form_state) { function module_filter_system_modules_recent_enabled_submit($form, FormStateInterface $form_state) {
$state = \Drupal::state(); $state = \Drupal::state();
$recent = $state->get('module_filter.recent') ?: array(); $recent = $state->get('module_filter.recent') ?: [];
// Drupal 8.3.0 simplified the module form structure which requires checking // Drupal 8.3.0 simplified the module form structure which requires checking
// the version of Drupal and building the $modules array accordingly. // the version of Drupal and building the $modules array accordingly.
...@@ -197,6 +197,6 @@ function module_filter_system_modules_redirect_submit($form, FormStateInterface ...@@ -197,6 +197,6 @@ function module_filter_system_modules_redirect_submit($form, FormStateInterface
if ($text = $form_state->getValue('text')) { if ($text = $form_state->getValue('text')) {
/** @var \Drupal\Core\Url $redirect */ /** @var \Drupal\Core\Url $redirect */
$route_name = ($redirect = $form_state->getRedirect()) ? $redirect->getRouteName() : 'system.modules_list'; $route_name = ($redirect = $form_state->getRedirect()) ? $redirect->getRouteName() : 'system.modules_list';
$form_state->setRedirect($route_name, array('filter' => $text)); $form_state->setRedirect($route_name, ['filter' => $text]);
} }
} }
...@@ -24,18 +24,18 @@ class ModuleFilterSettingsForm extends ConfigFormBase { ...@@ -24,18 +24,18 @@ class ModuleFilterSettingsForm extends ConfigFormBase {
$config = $this->config('module_filter.settings'); $config = $this->config('module_filter.settings');
$form = parent::buildForm($form, $form_state); $form = parent::buildForm($form, $form_state);
$form['modules'] = array( $form['modules'] = [
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => $this->t('Extend'), '#title' => $this->t('Extend'),
'#description' => $this->t('These are settings pertaining to the Extend pages of the site.'), '#description' => $this->t('These are settings pertaining to the Extend pages of the site.'),
'#collapsible' => FALSE, '#collapsible' => FALSE,
); ];
$form['modules']['tabs'] = array( $form['modules']['tabs'] = [
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => $this->t('Enhance the Extend page with tabs'), '#title' => $this->t('Enhance the Extend page with tabs'),
'#description' => $this->t('Provides many enhancements to the Extend page including the use of tabs for packages.'), '#description' => $this->t('Provides many enhancements to the Extend page including the use of tabs for packages.'),
'#default_value' => $config->get('tabs'), '#default_value' => $config->get('tabs'),
); ];
return $form; return $form;
} }
......
...@@ -49,23 +49,23 @@ class ModuleFilterUpdateStatusForm extends FormBase { ...@@ -49,23 +49,23 @@ class ModuleFilterUpdateStatusForm extends FormBase {
$form['filters']['text']['#default_value'] = $_GET['filter']; $form['filters']['text']['#default_value'] = $_GET['filter'];
} }
$form['filters']['radios'] = array( $form['filters']['radios'] = [
'#type' => 'container', '#type' => 'container',
'#attributes' => array( '#attributes' => [
'class' => array( 'class' => [
'module-filter-status', 'module-filter-status',
), ],
), ],
'show' => array( 'show' => [
'#type' => 'radios', '#type' => 'radios',
'#default_value' => 'all', '#default_value' => 'all',
'#options' => array( '#options' => [
'all' => $this->t('All'), 'all' => $this->t('All'),
'updates' => $this->t('Update available'), 'updates' => $this->t('Update available'),
'security' => $this->t('Security update'), 'security' => $this->t('Security update'),
), ],
), ],
); ];
return $form; return $form;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment