class LibraryDiscovery implements LibraryDiscoveryInterface (View source)

Discovers available asset libraries in Drupal.

Properties

protected CacheCollectorInterface $collector

The library discovery cache collector.

protected array $libraryDefinitions

The final library definitions, statically cached.

Methods

__construct(CacheCollectorInterface $library_discovery_collector)

Constructs a new LibraryDiscovery instance.

array
getLibrariesByExtension(string $extension)

Gets all libraries defined by an extension.

array|false
getLibraryByName(string $extension, string $name)

Gets a single library defined by an extension by name.

clearCachedDefinitions()

Clears static and persistent library definition caches.

Details

__construct(CacheCollectorInterface $library_discovery_collector)

Constructs a new LibraryDiscovery instance.

Parameters

CacheCollectorInterface $library_discovery_collector

The library discovery cache collector.

array getLibrariesByExtension(string $extension)

Gets all libraries defined by an extension.

Parameters

string $extension

The name of the extension that registered a library.

Return Value

array

An associative array of libraries registered by $extension is returned (which may be empty).

array|false getLibraryByName(string $extension, string $name)

Gets a single library defined by an extension by name.

Parameters

string $extension

The name of the extension that registered a library.

string $name

The name of a registered library to retrieve.

Return Value

array|false

The definition of the requested library, if $name was passed and it exists, otherwise FALSE.

clearCachedDefinitions()

Clears static and persistent library definition caches.