function minifyjs_form_system_performance_settings_alter in Minify JS 8
Same name and namespace in other branches
- 8.2 minifyjs.module \minifyjs_form_system_performance_settings_alter()
- 7 minifyjs.module \minifyjs_form_system_performance_settings_alter()
Implements hook_FORM_ID_alter().
Parameters
array $form:
FormStateInterface $form_state:
int $form_id:
File
- ./
minifyjs.module, line 19
Code
function minifyjs_form_system_performance_settings_alter(&$form, $form_state, $form_id) {
if (\Drupal::currentUser()
->hasPermission('administer minifyjs')) {
// Determine the number of files minified.
$files = minifyjs_load_all_files();
$files_minified = 0;
foreach ($files as $file) {
if (!empty($file->minified_uri)) {
$files_minified++;
}
}
$form['bandwidth_optimization']['use_minified_javascript'] = [
'#type' => 'checkbox',
'#title' => t('Use Minified JavaScript files.'),
'#disabled' => $files_minified ? FALSE : TRUE,
'#description' => t('Toggle minified javascript files on or off. There are @minified minified files out of @total total files available. <a href=":href">Click here to manage your javascript files</a>.', [
'@minified' => $files_minified,
'@total' => count($files),
':href' => Url::fromUri('base:/admin/config/development/performance/js')
->toString(),
]),
'#default_value' => \Drupal::config('minifyjs.config')
->get('use_minified'),
];
$form['#submit'][] = 'minifyjs_system_performance_settings_submit';
}
}