LibraryDependencyResolver::doGetDependencies

protected LibraryDependencyResolver::doGetDependencies(array $libraries_with_unresolved_dependencies, array $final_libraries = [])

Gets the given libraries with its dependencies.

Helper method for ::getLibrariesWithDependencies().

Parameters

string[] $libraries_with_unresolved_dependencies: A list of libraries, with unresolved dependencies, in the order they should be loaded.

string[] $final_libraries: The final list of libraries (the return value) that is being built recursively.

Return value

string[] A list of libraries, in the order they should be loaded, including their dependencies.

File

core/lib/Drupal/Core/Asset/LibraryDependencyResolver.php, line 50

Class

LibraryDependencyResolver
Resolves the dependencies of asset (CSS/JavaScript) libraries.

Namespace

Drupal\Core\Asset

Code

protected function doGetDependencies(array $libraries_with_unresolved_dependencies, array $final_libraries = []) {
  foreach ($libraries_with_unresolved_dependencies as $library) {
    if (!in_array($library, $final_libraries)) {
      list($extension, $name) = explode('/', $library, 2);
      $definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
      if (!empty($definition['dependencies'])) {
        $final_libraries = $this->doGetDependencies($definition['dependencies'], $final_libraries);
      }
      $final_libraries[] = $library;
    }
  }
  return $final_libraries;
}
doc_Drupal
2016-10-29 09:23:04
Comments
Leave a Comment

Please login to continue.