PdfBackendManager.php in FillPDF 5.0.x
File
src/Plugin/PdfBackendManager.php
View source
<?php
namespace Drupal\fillpdf\Plugin;
use Drupal\Component\Plugin\FallbackPluginManagerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
class PdfBackendManager extends DefaultPluginManager implements FallbackPluginManagerInterface {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/PdfBackend', $namespaces, $module_handler, 'Drupal\\fillpdf\\Plugin\\PdfBackendInterface', 'Drupal\\fillpdf\\Annotation\\PdfBackend');
$this
->alterInfo('fillpdf_pdfbackend_info');
$this
->setCacheBackend($cache_backend, 'fillpdf_pdfbackend_plugins');
}
public function getDefinitions() {
$definitions = parent::getDefinitions();
unset($definitions['legacy_provider']);
uasort($definitions, function ($a, $b) {
return $a['weight'] - $b['weight'];
});
return $definitions;
}
public function getFallbackPluginId($plugin_id, array $configuration = []) {
return 'legacy_provider';
}
protected function handlePluginNotFound($plugin_id, array $configuration) {
$fallback_id = $this
->getFallbackPluginId($plugin_id, $configuration);
$configuration['backend'] = $plugin_id;
return $this
->getFactory()
->createInstance($fallback_id, $configuration);
}
}