You are here

function hook_advagg_build_aggregate_plans_alter in Advanced CSS/JS Aggregation 7.2

Allow modules to modify the aggregate plan.

Parameters

array $files: An associative array. filename - data.

bool $modified: Set this to TRUE if the $files structure has been changed.

string $type: Lowercase css or js.

See also

advagg_build_aggregate_plans()

advagg_advagg_build_aggregate_plans_alter()

Related topics

3 functions implement hook_advagg_build_aggregate_plans_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

advagg_advagg_build_aggregate_plans_alter in ./advagg.advagg.inc
Implements hook_advagg_build_aggregate_plans_alter().
advagg_bundler_advagg_build_aggregate_plans_alter in advagg_bundler/advagg_bundler.advagg.inc
Implements hook_advagg_build_aggregate_plans_alter().
advagg_sri_advagg_build_aggregate_plans_alter in advagg_sri/advagg_sri.advagg.inc
Implements hook_advagg_build_aggregate_plans_alter().
1 invocation of hook_advagg_build_aggregate_plans_alter()
advagg_build_aggregate_plans in ./advagg.inc
Replacement for drupal_build_css_cache() and drupal_build_js_cache().

File

./advagg.api.php, line 33
Hooks provided by the AdvAgg module.

Code

function hook_advagg_build_aggregate_plans_alter(array &$files, &$modified, $type) {

  // Do nothing if core grouping is disabled.
  if (!variable_get('advagg_core_groups', ADVAGG_CORE_GROUPS)) {
    return;
  }
  $temp_new_files = array();
  $counter = 0;
  foreach ($files as $filename => $data) {
    if ($filename) {

      // This is the filename.
    }
    $group = NULL;
    $every_page = NULL;
    foreach ($data['files'] as $fileinfo) {

      // Grouped by group and every_page variables.
      if (is_null($group)) {
        $group = $fileinfo['group'];
      }
      if (is_null($every_page)) {
        $every_page = $fileinfo['every_page'];
      }

      // Bump Counter if group/every_page has changed from the last one.
      if ($group != $fileinfo['group'] || $every_page != $fileinfo['every_page']) {
        ++$counter;
        $group = $fileinfo['group'];
        $every_page = $fileinfo['every_page'];
        $modified = TRUE;
      }
      $temp_new_files[$counter][] = $fileinfo;
    }
    ++$counter;
  }

  // Replace $files array with new aggregate filenames.
  $files = advagg_generate_filenames(array(
    $temp_new_files,
  ), $type);
}