function angularjs_library in AngularJS 7
Implements hook_library().
File
- ./
angularjs.module, line 154
Code
function angularjs_library() {
$libraries = array();
$library_path = libraries_get_path('angular');
$version = variable_get('angularjs_version', ANGULARJS_DEFAULT_VERSION);
$files = variable_get('angularjs_files', array());
$compression = variable_get('angularjs_compression_type', 'min');
$cdn = TRUE == variable_get('angularjs_cdn', '0');
// Get correct extension
$extension = FALSE === empty($compression) ? $compression . '.js' : 'js';
$path = FALSE == $cdn ? $library_path : ANGULARJS_CDN_URL . '/' . $version;
$js = array(
$path . '/angular.' . $extension => array(
'external' => $cdn,
),
);
// Add selected files
foreach ($files as $file) {
$js[$path . '/' . $file . '.' . $extension] = array(
'external' => $cdn,
);
}
// Load module types exposed by modules
foreach (array(
'controllers',
'filters',
'directives',
'services',
) as $type) {
foreach (angularjs_get_modules($type, FALSE, $version) as $path => $options) {
$js[$path] = $options;
}
}
$libraries['angularjs'] = array(
'title' => 'AngularJS',
'website' => 'angularjs.org',
'version' => $version,
'js' => $js,
);
// Add CSRF token required by restWS.
$js_settings = array(
'angularjsApp' => array(
'restws_csrf_token' => drupal_get_token('restws'),
'basePath' => url('', array(
'absolute' => TRUE,
)),
),
);
drupal_add_js($js_settings, 'setting');
return $libraries;
}