You are here

public function LibraryDiscovery::getLibrariesByExtension in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Asset/LibraryDiscovery.php \Drupal\Core\Asset\LibraryDiscovery::getLibrariesByExtension()

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).

Overrides LibraryDiscoveryInterface::getLibrariesByExtension

See also

self::getLibraryByName()

1 call to LibraryDiscovery::getLibrariesByExtension()
LibraryDiscovery::getLibraryByName in core/lib/Drupal/Core/Asset/LibraryDiscovery.php
Gets a single library defined by an extension by name.

File

core/lib/Drupal/Core/Asset/LibraryDiscovery.php, line 42

Class

LibraryDiscovery
Discovers available asset libraries in Drupal.

Namespace

Drupal\Core\Asset

Code

public function getLibrariesByExtension($extension) {
  if (!isset($this->libraryDefinitions[$extension])) {
    $libraries = $this->collector
      ->get($extension);
    $this->libraryDefinitions[$extension] = [];
    foreach ($libraries as $name => $definition) {
      $this->libraryDefinitions[$extension][$name] = $definition;
    }
  }
  return $this->libraryDefinitions[$extension];
}