LibraryBase.php in Libraries API 8.3
File
src/ExternalLibrary/LibraryBase.php
View source
<?php
namespace Drupal\libraries\ExternalLibrary;
use Drupal\libraries\ExternalLibrary\Dependency\DependentLibraryInterface;
use Drupal\libraries\ExternalLibrary\Dependency\DependentLibraryTrait;
use Drupal\libraries\ExternalLibrary\Type\LibraryTypeInterface;
use Drupal\libraries\ExternalLibrary\Utility\IdAccessorTrait;
use Drupal\libraries\ExternalLibrary\Version\VersionedLibraryInterface;
use Drupal\libraries\ExternalLibrary\Version\VersionedLibraryTrait;
abstract class LibraryBase implements LibraryInterface, DependentLibraryInterface, VersionedLibraryInterface {
use IdAccessorTrait, DependentLibraryTrait, VersionedLibraryTrait;
protected $type;
public function __construct($id, array $definition, LibraryTypeInterface $type) {
$this->id = (string) $id;
$this->type = $type;
$this->dependencies = $definition['dependencies'];
$this->versionDetector = $definition['version_detector'];
}
public static function create($id, array $definition, LibraryTypeInterface $type) {
static::processDefinition($definition);
return new static($id, $definition, $type);
}
protected static function processDefinition(array &$definition) {
$definition += [
'dependencies' => [],
'version_detector' => [
'id' => 'static',
'configuration' => [
'version' => '',
],
],
];
}
public function getType() {
return $this->type;
}
}
Classes
Name |
Description |
LibraryBase |
Provides a base external library implementation. |