You are here

public function FillPdfRedirectAction::execute 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::execute()

Executes this plugin.

Saves the PDF file to the filesystem and redirects to it.

@todo Replace file_create_url() by File::createFileUrl() once we're not supporting Drupal 8.6 anymore.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse Redirects user to the generated PDF file, or if saving the file fails, to the front page.

Overrides FillPdfSaveAction::execute

File

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

Class

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

Namespace

Drupal\fillpdf\Plugin\FillPdfActionPlugin

Code

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);
}