blob: 347fa942eab523dde04ccc782fa8addd9a13b17d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<?php
namespace Drupal\Core\Asset;
use Drupal\Core\Cache\CacheCollectorInterface;
/**
* Discovers available asset libraries in Drupal.
*
* @deprecated in drupal:11.1.0 and is removed from drupal:12.0.0. Use
* \Drupal\Core\Asset\LibraryDiscoveryCollector instead.
* @see https://www.drupal.org/node/3462970
*/
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();
}
}
|