class Test in FillPDF 8.4
Backend used in tests.
Plugin annotation
@BackendService(
id = "test",
label = @Translation("FillPDF Test Backend Service"),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\fillpdf\Plugin\BackendServiceBase implements BackendServiceInterface
- class \Drupal\fillpdf_test\Plugin\BackendService\Test implements ContainerFactoryPluginInterface
- class \Drupal\fillpdf\Plugin\BackendServiceBase implements BackendServiceInterface
Expanded class hierarchy of Test
4 string references to 'Test'
- FillPdfFormDeleteFormTest::testDeleteFormCancel in tests/
src/ Functional/ FillPdfFormDeleteFormTest.php - Tests the cancel link works.
- FillPdfFormDuplicateFormTest::testDuplicateForm in tests/
src/ Functional/ FillPdfFormDuplicateFormTest.php - Tests the duplicate function.
- FillPdfFormImportFormTest::testExportDuplicateImport in tests/
src/ Functional/ FillPdfFormImportFormTest.php - Tests export and import functions.
- PdfPopulationTest::backendTest in tests/
src/ Functional/ PdfPopulationTest.php - Tests a backend.
File
- tests/
modules/ fillpdf_test/ src/ Plugin/ BackendService/ Test.php, line 18
Namespace
Drupal\fillpdf_test\Plugin\BackendServiceView source
class Test extends BackendServiceBase implements ContainerFactoryPluginInterface {
/**
* The state.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* Constructs a \Drupal\Component\Plugin\PluginBase 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 mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\State\StateInterface $state
* The state.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, StateInterface $state) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->configuration = $configuration;
$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 parse($pdf_content) {
return static::getParseResult();
}
/**
* {@inheritdoc}
*/
public function merge($pdf_content, array $field_mappings, array $options) {
$this->state
->set('fillpdf_test.last_populated_metadata', [
'field_mapping' => $field_mappings,
'options' => $options,
]);
return file_get_contents(drupal_get_path('module', 'fillpdf_test') . '/files/fillpdf_test_v3.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 |
---|---|---|---|---|
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. | |
Test:: |
protected | property | The state. | |
Test:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
Test:: |
public static | function | Returns a list of fields, as if a PDF file was parsed. | |
Test:: |
public | function |
Populate a PDF file with field data. Overrides BackendServiceInterface:: |
|
Test:: |
public | function |
Parse a PDF and return a list of its fields. Overrides BackendServiceInterface:: |
|
Test:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |