function _webprofiler_verify_library in Devel 4.x
Same name and namespace in other branches
- 8.3 webprofiler/webprofiler.install \_webprofiler_verify_library()
- 8 webprofiler/webprofiler.install \_webprofiler_verify_library()
- 8.2 webprofiler/webprofiler.install \_webprofiler_verify_library()
Verify that the library files exist.
Parameters
string $extension: The name of the extension that registered a library.
string $name: The name of a registered library to retrieve.
Return value
bool TRUE if all files of this library exists, FALSE otherwise
See also
https://drupal.org/node/2231385
1 call to _webprofiler_verify_library()
- webprofiler_requirements in webprofiler/
webprofiler.install - Implements hook_requirements().
File
- webprofiler/
webprofiler.install, line 135 - Install, update and uninstall functions for the webprofiler module.
Code
function _webprofiler_verify_library($extension, $name) {
/** @var Drupal\Core\Asset\LibraryDiscovery $library_discovery */
$library_discovery = \Drupal::service('library.discovery');
$library = $library_discovery
->getLibraryByName($extension, $name);
$exist = TRUE;
if ($library['js']) {
foreach ($library['js'] as $js) {
if ($js['type'] == 'file') {
if (!file_exists(DRUPAL_ROOT . '/' . $js['data'])) {
$exist = FALSE;
}
}
}
}
if ($library['css']) {
foreach ($library['css'] as $css) {
if ($css['type'] == 'file') {
if (!file_exists(DRUPAL_ROOT . '/' . $css['data'])) {
$exist = FALSE;
}
}
}
}
if ($library['dependencies']) {
foreach ($library['dependencies'] as $dependency) {
$parts = explode('/', $dependency);
$exist = _webprofiler_verify_library($parts[0], $parts[1]);
}
}
return $exist;
}