5 * Advanced aggregation bundler module.
8 use Drupal\Core\Form\FormStateInterface;
11 * Implements hook_advagg_current_hooks_hash_array_alter().
13 function advagg_bundler_advagg_current_hooks_hash_array_alter(&$aggregate_settings) {
14 $aggregate_settings['variables']['advagg_bundler'] = \Drupal::config('advagg_bundler.settings')->get();
18 * Implements hook_form_FORM_ID_alter().
20 function advagg_bundler_form_advagg_settings_alter(&$form, $form_state) {
21 if (advagg_bundler_enabled()) {
22 $form['global']['core_groups']['#disabled'] = TRUE;
23 $form['global']['core_groups']['#description'] = t('The bundler submodule disables core grouping logic.');
24 $form['global']['core_groups']['#states'] = [];
25 $form['global']['core_groups']['#default_value'] = FALSE;
26 array_unshift($form['#submit'], 'advagg_bundler_advagg_setting_form_submit');
31 * Prevent the bundler config overrides from being saved into stored config.
33 function advagg_bundler_advagg_setting_form_submit(array &$form, FormStateInterface &$form_state) {
34 $form_state->setValue('core_groups', \Drupal::config('advagg.settings')->getOriginal('core_groups', FALSE));
38 * Returns TRUE if the bundler will run.
41 * (optional) The type to check for - either 'css' or 'js'.
43 function advagg_bundler_enabled($type = NULL) {
44 $config = \Drupal::config('advagg_bundler.settings');
45 if (!$config->get('active')) {
49 return $config->get('max_' . $type);
51 if ($config->get('max_css') || $config->get('max_js')) {