final class LegacyProviderPdfBackend in FillPDF 8.4
Legacy provider PdfBackend plugin.
Provides backwards compatibility with legacy FillPdfBackend plugins.
Plugin annotation
@PdfBackend(
id = "legacy_provider",
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\fillpdf\Plugin\PdfBackendBase implements PdfBackendInterface
- class \Drupal\fillpdf_legacy\Plugin\PdfBackend\LegacyProviderPdfBackend implements ContainerFactoryPluginInterface, FillPdfBackendPluginInterface
- class \Drupal\fillpdf\Plugin\PdfBackendBase implements PdfBackendInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of LegacyProviderPdfBackend
Deprecated
in fillpdf:8.x-4.9 and is removed from fillpdf:8.x-5.0. This is only a BC wrapper. Once you turned your legacy FillPdfBackend plugins into new PdfBackend plugins, this wrapper will not be needed anymore.
See also
https://www.drupal.org/node/3059476
1 file declares its use of LegacyProviderPdfBackend
- LegacyBackendTest.php in modules/
fillpdf_legacy/ tests/ Kernel/ LegacyBackendTest.php
File
- modules/
fillpdf_legacy/ src/ Plugin/ PdfBackend/ LegacyProviderPdfBackend.php, line 30
Namespace
Drupal\fillpdf_legacy\Plugin\PdfBackendView source
final class LegacyProviderPdfBackend extends PdfBackendBase implements ContainerFactoryPluginInterface, FillPdfBackendPluginInterface {
/**
* The FillPDF legacy backend.
*
* @var \Drupal\fillpdf\FillPdfBackendPluginInterface
*/
private $legacyBackend;
/**
* Constructs a LegacyProviderPdfBackend plugin object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param array $plugin_definition
* The plugin implementation definition.
* @param \Drupal\fillpdf_legacy\Plugin\FillPdfBackendManager $legacy_backend_manager
* The FillPDF legacy backend manager.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, FillPdfBackendManager $legacy_backend_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->legacyBackend = $legacy_backend_manager
->createInstance($configuration['backend'], $configuration);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('plugin.manager.fillpdf_backend'));
}
/**
* {@inheritdoc}
*/
public function parse(FillPdfFormInterface $fillpdf_form) {
return $this->legacyBackend
->parse($fillpdf_form);
}
/**
* {@inheritdoc}
*/
public function parseFile(FileInterface $template_file) {
$fillpdf_form = FillPdfForm::create([
'file' => $template_file,
]);
return $this
->parse($fillpdf_form);
}
/**
* {@inheritdoc}
*/
public function parseStream($pdf_content) {
$template_file = file_save_data($pdf_content);
return $this
->parseFile($template_file);
}
/**
* {@inheritdoc}
*/
public function populateWithFieldData(FillPdfFormInterface $fillpdf_form, array $field_mapping, array $context) {
return $this->legacyBackend
->populateWithFieldData($fillpdf_form, $field_mapping, $context);
}
/**
* {@inheritdoc}
*/
public function mergeFile(FileInterface $template_file, array $field_mappings, array $context) {
$legacy_mapping = [];
foreach ($field_mappings as $pdf_key => $mapping) {
if ($mapping instanceof TextFieldMapping) {
$legacy_mapping['fields'][$pdf_key] = (string) $mapping
->getData();
}
elseif ($mapping instanceof ImageFieldMapping) {
$uri = (string) $mapping
->getUri();
if ($uri) {
$legacy_mapping['fields'][$pdf_key] = "{image}{$uri}";
$image_path_info = pathinfo($uri);
$legacy_mapping['images'][$pdf_key] = [
'data' => base64_encode($mapping
->getData()),
'filenamehash' => md5($image_path_info['filename']) . '.' . $image_path_info['extension'],
];
}
}
}
$fillpdf_form = FillPdfForm::create([
'file' => $template_file,
]);
return $this->legacyBackend
->populateWithFieldData($fillpdf_form, $legacy_mapping, $context);
}
/**
* {@inheritdoc}
*/
public function mergeStream($pdf_content, array $field_mappings, array $context) {
$template_file = file_save_data($pdf_content);
return $this
->mergeFile($template_file);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
LegacyProviderPdfBackend:: |
private | property | The FillPDF legacy backend. | |
LegacyProviderPdfBackend:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
LegacyProviderPdfBackend:: |
public | function |
Populate a PDF file with field data. Overrides PdfBackendInterface:: |
|
LegacyProviderPdfBackend:: |
public | function |
Populate a PDF file with field data. Overrides PdfBackendInterface:: |
|
LegacyProviderPdfBackend:: |
public | function |
Parse a PDF and return a list of its fields. Overrides FillPdfBackendPluginInterface:: |
|
LegacyProviderPdfBackend:: |
public | function |
Parse a PDF and return a list of its fields. Overrides PdfBackendInterface:: |
|
LegacyProviderPdfBackend:: |
public | function |
Parse a PDF and return a list of its fields. Overrides PdfBackendInterface:: |
|
LegacyProviderPdfBackend:: |
public | function |
Populate a FillPDF form with field data. Overrides FillPdfBackendPluginInterface:: |
|
LegacyProviderPdfBackend:: |
public | function |
Constructs a LegacyProviderPdfBackend plugin object. Overrides PluginBase:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |