You are here

protected function LibraryManager::getLibraryFromDefinition in Libraries API 8.3

Parameters

$id:

$definition:

Return value

mixed

2 calls to LibraryManager::getLibraryFromDefinition()
LibraryManager::getLibrary in src/ExternalLibrary/LibraryManager.php
Gets a library by its ID.
LibraryManager::load in src/ExternalLibrary/LibraryManager.php
Loads library files for a library.

File

src/ExternalLibrary/LibraryManager.php, line 92

Class

LibraryManager
Provides a manager for external libraries.

Namespace

Drupal\libraries\ExternalLibrary

Code

protected function getLibraryFromDefinition($id, $definition) {
  $library_type = $this
    ->getLibraryType($id, $definition);

  // @todo Make this alter-able.
  $class = $library_type
    ->getLibraryClass();

  // @todo Make sure that the library class implements the correct interface.
  $library = $class::create($id, $definition, $library_type);
  if ($library_type instanceof LibraryCreationListenerInterface) {
    $library_type
      ->onLibraryCreate($library);
    return $library;
  }
  return $library;
}