You are here

public function LibraryManager::load in Libraries API 8.3

Loads library files for a library.

Note that not all library types support explicit loading. Asset libraries, in particular, are declared to Drupal core's library system and are then loaded using that.

Parameters

string $id: The ID of the library.

Throws

\Drupal\libraries\ExternalLibrary\Exception\LibraryDefinitionNotFoundException

\Drupal\libraries\ExternalLibrary\Exception\LibraryNotInstalledException

Overrides LibraryManagerInterface::load

File

src/ExternalLibrary/LibraryManager.php, line 78

Class

LibraryManager
Provides a manager for external libraries.

Namespace

Drupal\libraries\ExternalLibrary

Code

public function load($id) {
  $definition = $this->definitionDiscovery
    ->getDefinition($id);
  $library_type = $this
    ->getLibraryType($id, $definition);

  // @todo Throw an exception instead of silently failing.
  if ($library_type instanceof LibraryLoadingListenerInterface) {
    $library_type
      ->onLibraryLoad($this
      ->getLibraryFromDefinition($id, $definition));
  }
}