abstract class LibraryBase in Libraries API 8.3
Provides a base external library implementation.
Hierarchy
- class \Drupal\libraries\ExternalLibrary\LibraryBase implements DependentLibraryInterface, LibraryInterface, VersionedLibraryInterface uses IdAccessorTrait
Expanded class hierarchy of LibraryBase
3 files declare their use of LibraryBase
- AssetLibrary.php in src/
ExternalLibrary/ Asset/ AssetLibrary.php - MultipleAssetLibrary.php in src/
ExternalLibrary/ Asset/ MultipleAssetLibrary.php - PhpFileLibrary.php in src/
ExternalLibrary/ PhpFile/ PhpFileLibrary.php
File
- src/
ExternalLibrary/ LibraryBase.php, line 15
Namespace
Drupal\libraries\ExternalLibraryView source
abstract class LibraryBase implements LibraryInterface, DependentLibraryInterface, VersionedLibraryInterface {
use IdAccessorTrait, DependentLibraryTrait, VersionedLibraryTrait;
/**
* The library type of this library.
*
* @var \Drupal\libraries\ExternalLibrary\Type\LibraryTypeInterface
*/
protected $type;
/**
* Constructs a library.
*
* @param string $id
* The library ID.
* @param array $definition
* The library definition array.
* @param \Drupal\libraries\ExternalLibrary\Type\LibraryTypeInterface $type
* The library type of this library.
*/
public function __construct($id, array $definition, LibraryTypeInterface $type) {
$this->id = (string) $id;
$this->type = $type;
$this->dependencies = $definition['dependencies'];
$this->versionDetector = $definition['version_detector'];
}
/**
* {@inheritdoc}
*/
public static function create($id, array $definition, LibraryTypeInterface $type) {
static::processDefinition($definition);
return new static($id, $definition, $type);
}
/**
* Gets library definition defaults.
*
* @param array $definition
* A library definition array.
*/
protected static function processDefinition(array &$definition) {
$definition += [
'dependencies' => [],
// @todo This fallback is not very elegant.
'version_detector' => [
'id' => 'static',
'configuration' => [
'version' => '',
],
],
];
}
/**
* {@inheritdoc}
*/
public function getType() {
return $this->type;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependentLibraryInterface:: |
public | function | Returns the libraries dependencies, if any. | |
IdAccessorTrait:: |
protected | property | The ID. | |
IdAccessorTrait:: |
public | function | Returns the ID. | |
LibraryBase:: |
protected | property | The library type of this library. | |
LibraryBase:: |
public static | function |
Creates an instance of the library from its definition. Overrides LibraryInterface:: |
|
LibraryBase:: |
public | function |
Returns the library type of the library. Overrides LibraryInterface:: |
|
LibraryBase:: |
protected static | function | Gets library definition defaults. | 3 |
LibraryBase:: |
public | function | Constructs a library. | 3 |
VersionedLibraryInterface:: |
public | function | Gets the version of the library. | |
VersionedLibraryInterface:: |
public | function | Gets the version detector of this library using the detector factory. | |
VersionedLibraryInterface:: |
public | function | Sets the version of the library. |