PhpFileLibraryType.php in Libraries API 8.3
File
src/Plugin/libraries/Type/PhpFileLibraryType.php
View source
<?php
namespace Drupal\libraries\Plugin\libraries\Type;
use Drupal\Component\Plugin\Factory\FactoryInterface;
use Drupal\libraries\ExternalLibrary\LibraryInterface;
use Drupal\libraries\ExternalLibrary\Type\LibraryLoadingListenerInterface;
use Drupal\libraries\ExternalLibrary\PhpFile\PhpFileLibrary;
use Drupal\libraries\ExternalLibrary\PhpFile\PhpFileLoaderInterface;
use Drupal\libraries\ExternalLibrary\Type\LibraryTypeBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class PhpFileLibraryType extends LibraryTypeBase implements LibraryLoadingListenerInterface {
protected $phpFileLoader;
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;
}
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'));
}
public function getLibraryClass() {
return PhpFileLibrary::class;
}
public function onLibraryLoad(LibraryInterface $library) {
foreach ($library
->getPhpFiles() as $file) {
$this->phpFileLoader
->load($file);
}
}
}