class TestPdfBackend in FillPDF 5.0.x
Backend used in tests.
Plugin annotation
@PdfBackend(
id = "test",
label = @Translation("Pass-through plugin for testing")
)
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_test\Plugin\PdfBackend\TestPdfBackend implements ContainerFactoryPluginInterface
- class \Drupal\fillpdf\Plugin\PdfBackendBase implements PdfBackendInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of TestPdfBackend
1 file declares its use of TestPdfBackend
- PdfPopulationTest.php in tests/
src/ Functional/ PdfPopulationTest.php
File
- tests/
modules/ fillpdf_test/ src/ Plugin/ PdfBackend/ TestPdfBackend.php, line 19
Namespace
Drupal\fillpdf_test\Plugin\PdfBackendView source
class TestPdfBackend extends PdfBackendBase implements ContainerFactoryPluginInterface {
/**
* The plugin's configuration.
*
* @var array
*/
protected $configuration;
/**
* The state.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* Constructs a LocalFillPdfBackend 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\Core\State\StateInterface $state
* The state.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, StateInterface $state) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->state = $state;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('state'));
}
/**
* {@inheritdoc}
*/
public function parseFile(FileInterface $template_file) {
return $this
->parseStream('');
}
/**
* {@inheritdoc}
*/
public function parseStream($pdf_content) {
return static::getParseResult();
}
/**
* {@inheritdoc}
*/
public function mergeFile(FileInterface $template_file, array $field_mappings, array $context) {
return $this
->mergeStream('', $field_mappings, $context);
}
/**
* {@inheritdoc}
*/
public function mergeStream($pdf_content, array $field_mappings, array $context) {
// Not really populated, but that isn't our job.
$populated_pdf = file_get_contents(drupal_get_path('module', 'fillpdf_test') . '/files/fillpdf_test_v3.pdf');
$this->state
->set('fillpdf_test.last_populated_metadata', [
'field_mapping' => $field_mappings,
'context' => $context,
]);
return $populated_pdf;
}
/**
* Returns a list of fields, as if a PDF file was parsed.
*
* Note that there is a duplicate field that get consolidated in
* InputHelper::attachPdfToForm() at the latest.
* The expected number of fields is therefore three, not four.
*
* @return array
* List of associative arrays representing fields.
*
* @see \Drupal\fillpdf\InputHelper::attachPdfToForm()
*/
public static function getParseResult() {
return [
0 => [
'name' => 'ImageField',
'value' => '',
'type' => 'Pushbutton',
],
1 => [
'name' => 'TestButton',
'value' => '',
'type' => 'Pushbutton',
],
2 => [
'name' => 'TextField1',
'value' => '',
'type' => 'Text',
],
3 => [
'name' => 'TextField2',
'value' => '',
'type' => 'Text',
],
4 => [
'name' => 'ImageField',
'value' => '',
'type' => 'Pushbutton',
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
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:: |
2 |
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. | 4 |
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. | |
TestPdfBackend:: |
protected | property |
The plugin's configuration. Overrides PluginBase:: |
|
TestPdfBackend:: |
protected | property | The state. | |
TestPdfBackend:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
TestPdfBackend:: |
public static | function | Returns a list of fields, as if a PDF file was parsed. | |
TestPdfBackend:: |
public | function |
Populate a PDF file with field data. Overrides PdfBackendInterface:: |
|
TestPdfBackend:: |
public | function |
Populate a PDF file with field data. Overrides PdfBackendInterface:: |
|
TestPdfBackend:: |
public | function |
Parse a PDF and return a list of its fields. Overrides PdfBackendInterface:: |
|
TestPdfBackend:: |
public | function |
Parse a PDF and return a list of its fields. Overrides PdfBackendInterface:: |
|
TestPdfBackend:: |
public | function |
Constructs a LocalFillPdfBackend plugin object. Overrides PluginBase:: |