class FillPdfDownloadAction in FillPDF 5.0.x
Same name and namespace in other branches
- 8.4 src/Plugin/FillPdfActionPlugin/FillPdfDownloadAction.php \Drupal\fillpdf\Plugin\FillPdfActionPlugin\FillPdfDownloadAction
Action plugin sending a generated PDF file to the users browser.
@package Drupal\fillpdf\Plugin\FillPdfActionPlugin
Plugin annotation
@FillPdfActionPlugin(
id = "download",
label = @Translation("Download PDF")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\fillpdf\Plugin\FillPdfActionPluginBase implements FillPdfActionPluginInterface
- class \Drupal\fillpdf\Plugin\FillPdfActionPlugin\FillPdfDownloadAction
- class \Drupal\fillpdf\Plugin\FillPdfActionPluginBase implements FillPdfActionPluginInterface
Expanded class hierarchy of FillPdfDownloadAction
File
- src/
Plugin/ FillPdfActionPlugin/ FillPdfDownloadAction.php, line 19
Namespace
Drupal\fillpdf\Plugin\FillPdfActionPluginView source
class FillPdfDownloadAction extends FillPdfActionPluginBase {
/**
* Executes this plugin.
*
* Sends the PDF file to the user's browser.
*
* @return \Symfony\Component\HttpFoundation\Response
* Sends the PDF file to the browser.
*/
public function execute() {
$response = new Response($this->configuration['data']);
// This ensures that the browser serves the file as a download.
$disposition = $response->headers
->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $this->configuration['filename']);
$response->headers
->set('Content-Disposition', $disposition);
$response->headers
->set('Content-Type', 'application/pdf');
$response->headers
->set('Content-Length', strlen($this->configuration['data']));
return $response;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FillPdfActionPluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
FillPdfActionPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
1 |
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. | |
FillPdfDownloadAction:: |
public | function |
Executes this plugin. Overrides FillPdfActionPluginInterface:: |
|
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:: |
|
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 98 |