You are here

class FillPdfRedirectAction in FillPDF 5.0.x

Same name and namespace in other branches
  1. 8.4 src/Plugin/FillPdfActionPlugin/FillPdfRedirectAction.php \Drupal\fillpdf\Plugin\FillPdfActionPlugin\FillPdfRedirectAction

Action plugin redirecting to a generated PDF file saved to the filesystem.

@package Drupal\fillpdf\Plugin\FillPdfActionPlugin

Plugin annotation


@FillPdfActionPlugin(
  id = "redirect",
  label = @Translation("Redirect PDF to file")
)

Hierarchy

Expanded class hierarchy of FillPdfRedirectAction

File

src/Plugin/FillPdfActionPlugin/FillPdfRedirectAction.php, line 18

Namespace

Drupal\fillpdf\Plugin\FillPdfActionPlugin
View source
class FillPdfRedirectAction extends FillPdfSaveAction {

  /**
   * Executes this plugin.
   *
   * Saves the PDF file to the filesystem and redirects to it.
   *
   * @return \Symfony\Component\HttpFoundation\RedirectResponse
   *   Redirects user to the generated PDF file, or if saving the file fails,
   *   to the front page.
   *
   * @todo Replace file_create_url() by File::createFileUrl() once we're not
   *   supporting Drupal 8.6 anymore.
   */
  public function execute() {
    $saved_file = $this
      ->savePdf();
    $url = $saved_file !== FALSE ? file_create_url($saved_file
      ->getFileUri()) : Url::fromRoute('<front>')
      ->toString();
    return new RedirectResponse($url);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FillPdfActionPluginBase::calculateDependencies public function Calculates dependencies for the configured plugin. Overrides DependentPluginInterface::calculateDependencies
FillPdfActionPluginBase::defaultConfiguration Deprecated public function Gets default configuration for this plugin.
FillPdfActionPluginBase::getConfiguration Deprecated public function Gets this plugin's configuration.
FillPdfActionPluginBase::isConfigurable public function @todo Remove once drupal:8.6.x is no longer supported. Overrides PluginBase::isConfigurable
FillPdfActionPluginBase::setConfiguration Deprecated public function Sets the configuration for this plugin instance.
FillPdfRedirectAction::execute public function Executes this plugin. Overrides FillPdfSaveAction::execute
FillPdfSaveAction::$outputHandler protected property The FillPdf output handler.
FillPdfSaveAction::create public static function Creates an instance of the plugin. Overrides FillPdfActionPluginBase::create
FillPdfSaveAction::savePdf protected function Saves merged PDF data to the filesystem.
FillPdfSaveAction::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 2
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId