You are here

function angularjs_version_files in AngularJS 7

Provides a list of files that are part of the selected version of AngularJS

Parameters

string $version :

Return value

array

3 calls to angularjs_version_files()
angularjs_install in ./angularjs.install
Implements hook_install
angularjs_settings_form in ./angularjs.admin.inc
AngularJS configuration form
angularjs_update_7000 in ./angularjs.install
Set initial AngularJS variables

File

./angularjs.module, line 107

Code

function angularjs_version_files($version = NULL, $reset = FALSE) {
  $data = array();
  if ($version) {
    $cid = 'angularjs:versions:' . $version;
    if (!$reset && ($cache = cache_get($cid)) && !empty($cache->data)) {
      $data = $cache->data;
    }
    else {
      $result = drupal_http_request('https://code.angularjs.org/' . $version);
      if (FALSE === isset($result->error)) {
        $re = "/href=\"([a-z][a-z\\-\\.0-9]+)(?<!min).js\"/";
        preg_match_all($re, $result->data, $matches);
        if ($matches && 2 == sizeof($matches)) {
          $data = $matches[1];

          // Make sure we don't list the basic library
          $angular_position = array_search('angular', $data);
          if (FALSE !== $angular_position) {
            unset($data[$angular_position]);
          }
          cache_set($cid, $data);
        }
      }
    }
  }
  return $data;
}