class PhpFileLibrary in Libraries API 8.3
Provides a base PHP file library implementation.
Hierarchy
- class \Drupal\libraries\ExternalLibrary\LibraryBase implements DependentLibraryInterface, LibraryInterface, VersionedLibraryInterface uses IdAccessorTrait
- class \Drupal\libraries\ExternalLibrary\PhpFile\PhpFileLibrary implements PhpFileLibraryInterface uses LocalLibraryTrait
Expanded class hierarchy of PhpFileLibrary
1 file declares its use of PhpFileLibrary
- PhpFileLibraryType.php in src/
Plugin/ libraries/ Type/ PhpFileLibraryType.php
File
- src/
ExternalLibrary/ PhpFile/ PhpFileLibrary.php, line 14
Namespace
Drupal\libraries\ExternalLibrary\PhpFileView source
class PhpFileLibrary extends LibraryBase implements PhpFileLibraryInterface {
use LocalLibraryTrait;
/**
* An array of PHP files for this library.
*
* @var array
*/
protected $files = [];
/**
* Constructs a PHP file 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) {
parent::__construct($id, $definition, $type);
$this->files = $definition['files'];
}
/**
* {@inheritdoc}
*/
protected static function processDefinition(array &$definition) {
parent::processDefinition($definition);
$definition += [
'files' => [],
];
}
/**
* {@inheritdoc}
*/
public function getPhpFiles() {
if (!$this
->isInstalled()) {
throw new LibraryNotInstalledException($this);
}
$processed_files = [];
foreach ($this->files as $file) {
$processed_files[] = $this
->getLocalPath() . '/' . $file;
}
return $processed_files;
}
/**
* {@inheritdoc}
*/
public function getLocator(FactoryInterface $locator_factory) {
// @todo Consider refining the stream wrapper used here.
return $locator_factory
->createInstance('uri', [
'uri' => 'php-file://',
]);
}
}
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:: |
|
LocalLibraryTrait:: |
protected | property | Whether or not the library is installed. | |
LocalLibraryTrait:: |
protected | property | The local path to the library relative to the app root. | |
LocalLibraryTrait:: |
public | function | Gets the path to the library. | |
LocalLibraryTrait:: |
public | function | Checks whether the library is installed. | |
LocalLibraryTrait:: |
public | function | Sets the library path of the library. | |
LocalLibraryTrait:: |
public | function | Marks the library as uninstalled. | |
PhpFileLibrary:: |
protected | property | An array of PHP files for this library. | |
PhpFileLibrary:: |
public | function |
Gets the locator of this library using the locator factory. Overrides LocalLibraryInterface:: |
|
PhpFileLibrary:: |
public | function |
Returns the PHP files of this library. Overrides PhpFileLibraryInterface:: |
|
PhpFileLibrary:: |
protected static | function |
Gets library definition defaults. Overrides LibraryBase:: |
|
PhpFileLibrary:: |
public | function |
Constructs a PHP file library. Overrides LibraryBase:: |
|
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. |