TestPrintEngine.php in Entity Print 8.2
File
tests/modules/entity_print_test/src/Plugin/EntityPrint/PrintEngine/TestPrintEngine.php
View source
<?php
namespace Drupal\entity_print_test\Plugin\EntityPrint\PrintEngine;
use Drupal\Core\Form\FormStateInterface;
use Drupal\entity_print\Plugin\PrintEngineBase;
class TestPrintEngine extends PrintEngineBase {
protected $html;
public function send($filename, $force_download = TRUE) {
echo $filename;
echo 'Using testprintengine - ' . $this->configuration['test_engine_suffix'];
echo $this->html;
}
public function getBlob() {
return 'Using testprintengine';
}
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;
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['test_engine_setting'] = $form_state
->getValue([
'testprintengine',
'test_engine_setting',
]);
$this->configuration['test_engine_suffix'] = $form_state
->getValue([
'testprintengine',
'test_engine_suffix',
]);
}
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
if ($form_state
->getValue([
'testprintengine',
'test_engine_setting',
]) === 'rejected') {
$form_state
->setErrorByName('test_engine_setting', 'Setting has an invalid value');
}
}
public function defaultConfiguration() {
return [
'test_engine_setting' => '',
'test_engine_suffix' => '',
];
}
public function getError() {
}
public function addPage($content) {
$this->html = $content;
}
public static function dependenciesAvailable() {
return TRUE;
}
public function getPrintObject() {
}
}