class TestPdfEngine in Entity Print 8
Plugin annotation
@PdfEngine(
id = "testpdfengine",
label= @Translation("Test PDF Engine")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\entity_print\Plugin\PdfEngineBase implements PdfEngineInterface
- class \Drupal\entity_print_test\Plugin\EntityPrint\PdfEngine\TestPdfEngine
- class \Drupal\entity_print\Plugin\PdfEngineBase implements PdfEngineInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of TestPdfEngine
File
- tests/
modules/ entity_print_test/ src/ Plugin/ EntityPrint/ PdfEngine/ TestPdfEngine.php, line 15
Namespace
Drupal\entity_print_test\Plugin\EntityPrint\PdfEngineView source
class TestPdfEngine extends PdfEngineBase {
/**
* @var string
*/
protected $html;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public function send($filename = NULL) {
// Echo the response and then flush, just like a PDF implementation would.
echo 'Using testpdfengine - ' . $this->configuration['test_engine_suffix'];
echo $this->html;
flush();
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['test_engine_setting'] = [
'#title' => $this
->t('Test setting'),
'#type' => 'textfield',
'#default_value' => $this->configuration['test_engine_setting'],
'#description' => $this
->t('Test setting'),
];
$form['test_engine_suffix'] = [
'#title' => $this
->t('Suffix'),
'#type' => 'textfield',
'#default_value' => $this->configuration['test_engine_suffix'],
'#description' => $this
->t('Suffix'),
];
return $form;
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['test_engine_setting'] = $form_state
->getValue('test_engine_setting');
$this->configuration['test_engine_suffix'] = $form_state
->getValue('test_engine_suffix');
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
if ($form_state
->getValue('test_engine_setting') === 'rejected') {
$form_state
->setErrorByName('test_engine_setting', 'Setting has an invalid value');
}
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'test_engine_setting' => '',
'test_engine_suffix' => '',
];
}
/**
* {@inheritdoc}
*/
public function getError() {
}
/**
* {@inheritdoc}
*/
public function addPage($content) {
$this->html = $content;
}
/**
* {@inheritdoc}
*/
public static function dependenciesAvailable() {
return TRUE;
}
}
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 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PdfEngineBase:: |
protected | property | The PDF library object. | 2 |
PdfEngineBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
PdfEngineBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurablePluginInterface:: |
|
PdfEngineBase:: |
public static | function |
Gets the installation instructions for this PDF engine. Overrides PdfEngineInterface:: |
2 |
PdfEngineBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurablePluginInterface:: |
|
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. | |
TestPdfEngine:: |
protected | property | ||
TestPdfEngine:: |
public | function |
Add a string of HTML to a new page. Overrides PdfEngineInterface:: |
|
TestPdfEngine:: |
public | function |
Form constructor. Overrides PdfEngineBase:: |
|
TestPdfEngine:: |
public | function |
Gets default configuration for this plugin. Overrides PdfEngineBase:: |
|
TestPdfEngine:: |
public static | function |
Checks if the PDF engine dependencies are available. Overrides PdfEngineInterface:: |
|
TestPdfEngine:: |
public | function | ||
TestPdfEngine:: |
public | function |
Send the PDF contents to the browser. Overrides PdfEngineInterface:: |
|
TestPdfEngine:: |
public | function |
Form submission handler. Overrides PdfEngineBase:: |
|
TestPdfEngine:: |
public | function |
Form validation handler. Overrides PdfEngineBase:: |
|
TestPdfEngine:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PdfEngineBase:: |