Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. LibraryDiscoveryInterface.php

interface LibraryDiscoveryInterface

Discovers information for asset (CSS/JavaScript) libraries.

Library information is statically cached. Libraries are keyed by extension for several reasons:

  • Libraries are not unique. Multiple extensions might ship with the same library in a different version or variant. This registry cannot (and does not attempt to) prevent library conflicts.
  • Extensions implementing and thereby depending on a library that is registered by another extension can only rely on that extension's library.
  • Two (or more) extensions can still register the same library and use it without conflicts in case the libraries are loaded on certain pages only.

Hierarchy

  • interface \Drupal\Core\Asset\LibraryDiscoveryInterface

Expanded class hierarchy of LibraryDiscoveryInterface

All classes that implement LibraryDiscoveryInterface

File

core/lib/Drupal/Core/Asset/LibraryDiscoveryInterface.php, line 18

Namespace

Drupal\Core\Asset
View source
interface LibraryDiscoveryInterface {
    
    /**
     * Gets all libraries defined by an extension.
     *
     * @param string $extension
     *   The name of the extension that registered a library.
     *
     * @return array
     *   An associative array of libraries registered by $extension is returned
     *   (which may be empty).
     *
     * @see self::getLibraryByName()
     */
    public function getLibrariesByExtension($extension);
    
    /**
     * Gets a single library defined by an extension by name.
     *
     * @param string $extension
     *   The name of the extension that registered a library.
     * @param string $name
     *   The name of a registered library to retrieve.
     *
     * @return array|false
     *   The definition of the requested library, if $name was passed and it
     *   exists, otherwise FALSE.
     */
    public function getLibraryByName($extension, $name);
    
    /**
     * Clears static and persistent library definition caches.
     *
     * @deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Use
     * LibraryDiscoveryCollector::clear() instead.
     * @see https://www.drupal.org/node/3462970
     */
    public function clearCachedDefinitions();

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overrides
LibraryDiscoveryInterface::clearCachedDefinitions Deprecated public function Clears static and persistent library definition caches. 2
LibraryDiscoveryInterface::getLibrariesByExtension public function Gets all libraries defined by an extension. 2
LibraryDiscoveryInterface::getLibraryByName public function Gets a single library defined by an extension by name. 2

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal