You are here

function advagg_modify_css_pre_render in Advanced CSS/JS Aggregation 7.2

Callback for pre_render so elements can be modified before they are rendered.

Parameters

array $elements: A render array containing:

  • #items: The CSS items as returned by drupal_add_css() and altered by drupal_get_css().
  • #group_callback: A function to call to group #items. Following this function, #aggregate_callback is called to aggregate items within the same group into a single file.
  • #aggregate_callback: A function to call to aggregate the items within the groups arranged by the #group_callback function.

Return value

array A render array that will render to a string of JavaScript tags.

2 string references to 'advagg_modify_css_pre_render'
advagg_element_info_alter in ./advagg.module
Implements hook_element_info_alter().
advagg_install_fast_checks in ./advagg.install
Run various checks that are fast.

File

./advagg.module, line 1554
Advanced CSS/JS aggregation module.

Code

function advagg_modify_css_pre_render(array $elements) {
  if (!advagg_enabled()) {
    return $elements;
  }

  // Put children elements into a reference array.
  $children = array();
  foreach ($elements as $key => &$value) {
    if ($key !== '' && is_string($key) && 0 === strpos($key, '#')) {
      continue;
    }
    $children[$key] =& $value;
  }
  unset($value);

  // Allow other modules to modify $children and $elements before they are
  // rendered.
  // Call hook_advagg_modify_css_pre_render_alter()
  drupal_alter('advagg_modify_css_pre_render', $children, $elements);
  return $elements;
}