3 namespace Drupal\libraries\ExternalLibrary;
5 use Drupal\libraries\ExternalLibrary\Dependency\DependentLibraryInterface;
6 use Drupal\libraries\ExternalLibrary\Dependency\DependentLibraryTrait;
7 use Drupal\libraries\ExternalLibrary\Type\LibraryTypeInterface;
8 use Drupal\libraries\ExternalLibrary\Utility\IdAccessorTrait;
9 use Drupal\libraries\ExternalLibrary\Version\VersionedLibraryInterface;
10 use Drupal\libraries\ExternalLibrary\Version\VersionedLibraryTrait;
13 * Provides a base external library implementation.
15 abstract class LibraryBase implements
17 DependentLibraryInterface,
18 VersionedLibraryInterface
23 DependentLibraryTrait,
28 * The library type of this library.
30 * @var \Drupal\libraries\ExternalLibrary\Type\LibraryTypeInterface
35 * Constructs a library.
39 * @param array $definition
40 * The library definition array.
41 * @param \Drupal\libraries\ExternalLibrary\Type\LibraryTypeInterface $type
42 * The library type of this library.
44 public function __construct($id, array $definition, LibraryTypeInterface $type) {
45 $this->id = (string) $id;
47 $this->dependencies = $definition['dependencies'];
48 $this->versionDetector = $definition['version_detector'];
54 public static function create($id, array $definition, LibraryTypeInterface $type) {
55 static::processDefinition($definition);
56 return new static($id, $definition, $type);
60 * Gets library definition defaults.
62 * @param array $definition
63 * A library definition array.
65 protected static function processDefinition(array &$definition) {
68 // @todo This fallback is not very elegant.
69 'version_detector' => [
71 'configuration' => ['version' => ''],
79 public function getType() {