class LibraryDiscovery
Same name in other branches
- 9 core/lib/Drupal/Core/Asset/LibraryDiscovery.php \Drupal\Core\Asset\LibraryDiscovery
- 8.9.x core/lib/Drupal/Core/Asset/LibraryDiscovery.php \Drupal\Core\Asset\LibraryDiscovery
- 10 core/lib/Drupal/Core/Asset/LibraryDiscovery.php \Drupal\Core\Asset\LibraryDiscovery
Discovers available asset libraries in Drupal.
Hierarchy
- class \Drupal\Core\Asset\LibraryDiscovery implements \Drupal\Core\Asset\LibraryDiscoveryInterface
Expanded class hierarchy of LibraryDiscovery
Deprecated
in drupal:11.1.0 and is removed from drupal:12.0.0. Use \Drupal\Core\Asset\LibraryDiscoveryCollector instead.
See also
https://www.drupal.org/node/3462970
File
-
core/
lib/ Drupal/ Core/ Asset/ LibraryDiscovery.php, line 14
Namespace
Drupal\Core\AssetView source
class LibraryDiscovery implements LibraryDiscoveryInterface {
/**
* The library discovery cache collector.
*
* @var \Drupal\Core\Cache\CacheCollectorInterface
*/
protected $collector;
/**
* Constructs a new LibraryDiscovery instance.
*
* @param \Drupal\Core\Cache\CacheCollectorInterface $library_discovery_collector
* The library discovery cache collector.
*/
public function __construct(CacheCollectorInterface $library_discovery_collector) {
trigger_error(__CLASS__ . 'is deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Use LibraryDiscoveryCollector instead. See https://www.drupal.org/node/3462970', E_USER_DEPRECATED);
$this->collector = $library_discovery_collector;
}
/**
* {@inheritdoc}
*/
public function getLibrariesByExtension($extension) {
return $this->collector
->get($extension);
}
/**
* {@inheritdoc}
*/
public function getLibraryByName($extension, $name) {
$libraries = $this->collector
->get($extension);
if (!isset($libraries[$name])) {
return FALSE;
}
if (isset($libraries[$name]['deprecated'])) {
// phpcs:ignore Drupal.Semantics.FunctionTriggerError
@trigger_error(str_replace('%library_id%', "{$extension}/{$name}", $libraries[$name]['deprecated']), E_USER_DEPRECATED);
}
return $libraries[$name];
}
/**
* {@inheritdoc}
*/
public function clearCachedDefinitions() {
$this->collector
->clear();
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
LibraryDiscovery::$collector | protected | property | The library discovery cache collector. | |
LibraryDiscovery::clearCachedDefinitions | public | function | Clears static and persistent library definition caches. | Overrides LibraryDiscoveryInterface::clearCachedDefinitions |
LibraryDiscovery::getLibrariesByExtension | public | function | Gets all libraries defined by an extension. | Overrides LibraryDiscoveryInterface::getLibrariesByExtension |
LibraryDiscovery::getLibraryByName | public | function | Gets a single library defined by an extension by name. | Overrides LibraryDiscoveryInterface::getLibraryByName |
LibraryDiscovery::__construct | public | function | Constructs a new LibraryDiscovery instance. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.