You are here

function advagg_get_js_scopes in Advanced CSS/JS Aggregation 7

Same name and namespace in other branches
  1. 7.2 advagg.module \advagg_get_js_scopes()

Get all javascript scopes set in the $javascript array.

Parameters

$javascript: An array with all JavaScript code.

Return value

Array of scopes that are currently being used.

File

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

Code

function advagg_get_js_scopes($javascript) {

  // Return if nothing given to us.
  if (empty($javascript) || !is_array($javascript)) {
    return FALSE;
  }

  // Filter out elements of the given scope.
  $scopes = array();
  foreach ($javascript as $key => $item) {

    // skip if the scope is not set.
    if (!is_array($item) || empty($item['scope'])) {
      continue;
    }
    if (!isset($scopes[$item['scope']])) {
      $scopes[$item['scope']] = TRUE;
    }
  }
  return $scopes;
}