public function HandlePdfController::populatePdf in FillPDF 5.0.x
Same name and namespace in other branches
- 8.4 src/Controller/HandlePdfController.php \Drupal\fillpdf\Controller\HandlePdfController::populatePdf()
Populates PDF template from context.
Return value
\Symfony\Component\HttpFoundation\Response The action plugin's response object.
Throws
\InvalidArgumentException
\Drupal\Component\Plugin\Exception\PluginException
\Drupal\Core\Entity\EntityMalformedException If one of the passed arguments is missing or does not pass the validation.
1 string reference to 'HandlePdfController::populatePdf'
File
- src/
Controller/ HandlePdfController.php, line 138
Class
- HandlePdfController
- Class HandlePdfController.
Namespace
Drupal\fillpdf\ControllerCode
public function populatePdf() {
$context = $this->linkManipulator
->parseRequest($this->requestStack
->getCurrentRequest());
$fillpdf_form = FillPdfForm::load($context['fid']);
$entities = $this->contextManager
->loadEntities($context);
$populated_pdf = $this->backendProxy
->merge($fillpdf_form, $entities, $context);
if (empty($populated_pdf)) {
$this
->messenger()
->addError($this
->t('Merging the FillPDF Form failed.'));
return new RedirectResponse(Url::fromRoute('<front>')
->toString());
}
// Generate the filename of downloaded PDF from title of the PDF set in
// admin/structure/fillpdf/%fid.
$filename = $this
->buildFilename($fillpdf_form->title->value, $entities);
// @todo: When Rules integration ported, emit an event or whatever.
return $this
->handlePopulatedPdf($fillpdf_form, $populated_pdf, $context, $filename, $entities);
}