class PhpFileLibraryType in Libraries API 8.3
Plugin annotation
@LibraryType("php_file");
Hierarchy
- class \Drupal\libraries\ExternalLibrary\Type\LibraryTypeBase implements ContainerFactoryPluginInterface, LibraryCreationListenerInterface, LibraryTypeInterface uses IdAccessorTrait
- class \Drupal\libraries\Plugin\libraries\Type\PhpFileLibraryType implements LibraryLoadingListenerInterface
Expanded class hierarchy of PhpFileLibraryType
File
- src/
Plugin/ libraries/ Type/ PhpFileLibraryType.php, line 16
Namespace
Drupal\libraries\Plugin\libraries\TypeView source
class PhpFileLibraryType extends LibraryTypeBase implements LibraryLoadingListenerInterface {
/**
* The PHP file loader.
*
* @var \Drupal\libraries\ExternalLibrary\PhpFile\PhpFileLoaderInterface
*/
protected $phpFileLoader;
/**
* Constructs the PHP file library type.
*
* @param string $plugin_id
* The plugin ID taken from the class annotation.
* @param \Drupal\Component\Plugin\Factory\FactoryInterface $locator_factory
* The locator factory.
* @param \Drupal\Component\Plugin\Factory\FactoryInterface $detector_factory
* The version detector factory.
* @param \Drupal\libraries\ExternalLibrary\PhpFile\PhpFileLoaderInterface $php_file_loader
* The PHP file loader.
*/
public function __construct($plugin_id, FactoryInterface $locator_factory, FactoryInterface $detector_factory, PhpFileLoaderInterface $php_file_loader) {
parent::__construct($plugin_id, $locator_factory, $detector_factory);
$this->phpFileLoader = $php_file_loader;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($plugin_id, $container
->get('plugin.manager.libraries.locator'), $container
->get('plugin.manager.libraries.version_detector'), $container
->get('libraries.php_file_loader'));
}
/**
* {@inheritdoc}
*/
public function getLibraryClass() {
return PhpFileLibrary::class;
}
/**
* {@inheritdoc}
*/
public function onLibraryLoad(LibraryInterface $library) {
/** @var \Drupal\libraries\ExternalLibrary\PhpFile\PhpFileLibraryInterface $library */
// @todo Prevent loading a library multiple times.
foreach ($library
->getPhpFiles() as $file) {
$this->phpFileLoader
->load($file);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
IdAccessorTrait:: |
protected | property | The ID. | |
IdAccessorTrait:: |
public | function | Returns the ID. | |
LibraryTypeBase:: |
protected | property | The version detector factory. | |
LibraryTypeBase:: |
protected | property | The locator factory. | |
LibraryTypeBase:: |
public | function |
Reacts to the instantiation of a library. Overrides LibraryCreationListenerInterface:: |
|
PhpFileLibraryType:: |
protected | property | The PHP file loader. | |
PhpFileLibraryType:: |
public static | function |
Creates an instance of the plugin. Overrides LibraryTypeBase:: |
|
PhpFileLibraryType:: |
public | function |
Returns the class used for libraries of this type. Overrides LibraryTypeInterface:: |
|
PhpFileLibraryType:: |
public | function |
Reacts to the instantiation of a library. Overrides LibraryLoadingListenerInterface:: |
|
PhpFileLibraryType:: |
public | function |
Constructs the PHP file library type. Overrides LibraryTypeBase:: |