You are here

class LibrariesUiService in Libraries UI 8

Class LibrariesUiService.

@package Drupal\libraries_ui

Hierarchy

Expanded class hierarchy of LibrariesUiService

1 string reference to 'LibrariesUiService'
libraries_ui.services.yml in ./libraries_ui.services.yml
libraries_ui.services.yml
1 service uses LibrariesUiService
libraries_ui.default in ./libraries_ui.services.yml
Drupal\libraries_ui\LibrariesUiService

File

src/LibrariesUiService.php, line 11

Namespace

Drupal\libraries_ui
View source
class LibrariesUiService {
  public function getAllLibraries() {
    $modules = \Drupal::service('module_handler')
      ->getModuleList();
    $themes = \Drupal::service('theme_handler')
      ->rebuildThemeData();
    $libraryDiscovery = \Drupal::service('library.discovery');
    $extensions = array_merge($modules, $themes);
    $root = \Drupal::root();
    foreach ($extensions as $extension_name => $extension) {
      $library_file = $extension
        ->getPath() . '/' . $extension_name . '.libraries.yml';
      if (is_file($root . '/' . $library_file)) {
        $libraries[$extension_name] = $libraryDiscovery
          ->getLibrariesByExtension($extension_name);
      }
    }
    return $libraries;
  }

}

Members