class FillPdfSaveAction in FillPDF 5.0.x
Same name and namespace in other branches
- 8.4 src/Plugin/FillPdfActionPlugin/FillPdfSaveAction.php \Drupal\fillpdf\Plugin\FillPdfActionPlugin\FillPdfSaveAction
Action plugin saving a generated PDF file to the filesystem.
@package Drupal\fillpdf\Plugin\FillPdfActionPlugin
Plugin annotation
@FillPdfActionPlugin(
id = "save",
label = @Translation("Save PDF to file")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\fillpdf\Plugin\FillPdfActionPluginBase implements FillPdfActionPluginInterface
- class \Drupal\fillpdf\Plugin\FillPdfActionPlugin\FillPdfSaveAction
- class \Drupal\fillpdf\Plugin\FillPdfActionPluginBase implements FillPdfActionPluginInterface
Expanded class hierarchy of FillPdfSaveAction
File
- src/
Plugin/ FillPdfActionPlugin/ FillPdfSaveAction.php, line 21
Namespace
Drupal\fillpdf\Plugin\FillPdfActionPluginView source
class FillPdfSaveAction extends FillPdfActionPluginBase {
/**
* The FillPdf output handler.
*
* @var \Drupal\fillpdf\OutputHandler
*/
protected $outputHandler;
/**
* Constructs a \Drupal\Component\Plugin\PluginBase object.
*
* @param \Drupal\fillpdf\OutputHandler $output_handler
* The FillPdf output handler.
* @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.
*/
public function __construct(OutputHandler $output_handler, array $configuration, $plugin_id, $plugin_definition) {
$this->outputHandler = $output_handler;
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($container
->get('fillpdf.output_handler'), $configuration, $plugin_id, $plugin_definition);
}
/**
* Executes this plugin.
*
* Saves the PDF file to the filesystem and redirects to the front page.
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* Redirects user to the front page.
*/
public function execute() {
$this
->savePdf();
// @todo: Fix based on value of post_save_redirect, once I add that
$response = new RedirectResponse(Url::fromRoute('<front>')
->toString());
return $response;
}
/**
* Saves merged PDF data to the filesystem.
*
* @return \Drupal\file\FileInterface|false
* The saved file entity, or FALSE on error.
*
* @see \Drupal\fillpdf\OutputHandlerInterface::savePdfToFile()
*/
protected function savePdf() {
// @todo: Error handling?
return $this->outputHandler
->savePdfToFile($this->configuration);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FillPdfActionPluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
FillPdfActionPluginBase:: |
public | function | Gets default configuration for this plugin. | |
FillPdfActionPluginBase:: |
public | function | Gets this plugin's configuration. | |
FillPdfActionPluginBase:: |
public | function |
@todo Remove once drupal:8.6.x is no longer supported. Overrides PluginBase:: |
|
FillPdfActionPluginBase:: |
public | function | Sets the configuration for this plugin instance. | |
FillPdfSaveAction:: |
protected | property | The FillPdf output handler. | |
FillPdfSaveAction:: |
public static | function |
Creates an instance of the plugin. Overrides FillPdfActionPluginBase:: |
|
FillPdfSaveAction:: |
public | function |
Executes this plugin. Overrides FillPdfActionPluginInterface:: |
1 |
FillPdfSaveAction:: |
protected | function | Saves merged PDF data to the filesystem. | |
FillPdfSaveAction:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
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:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |