You are here

function _fotorama_gallery_verify_library in Fotorama Gallery 8.2

Same name and namespace in other branches
  1. 8 fotorama_gallery.install \_fotorama_gallery_verify_library()

Verify that the library files exist.

Return value

bool TRUE if all files of this library exists, FALSE otherwise

See also

https://drupal.org/node/2231385

2 calls to _fotorama_gallery_verify_library()
fotorama_gallery_install in ./fotorama_gallery.install
Implements hook_install().
fotorama_gallery_requirements in ./fotorama_gallery.install
Implements hook_requirements().

File

./fotorama_gallery.install, line 44
Installation actions for Fotorama Gallery.

Code

function _fotorama_gallery_verify_library() {

  /** @var Drupal\Core\Asset\LibraryDiscovery $library_discovery */
  $library_discovery = \Drupal::service('library.discovery');
  $library = $library_discovery
    ->getLibraryByName('fotorama_gallery', 'fotorama');
  $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;
        }
      }
    }
  }
  return $exist;
}