Hello together!
I want to pass a PersistenceResource object to another action (Neos flow 6.3.0). Unfortunately I get an error that the object is null, although this is not the case at the beginning. The “die” is never thrown. “redirect” and “forward” generate the same error.
/**
* @param DocumentInvoice $invoice
* @throws \Neos\Flow\Mvc\Exception\ForwardException
*/
public function showAction(DocumentInvoice $invoice)
{
$document = $invoice->getDocument();
$fileName = "Invoice_".$invoice->getParentOrder()->getNumberInvoice()->getNumber().".pdf";
if ($document === null)
die();
$this->forward("show", "document", "Bla.Framework", ["document" => $document, "fileName" => $fileName]);
}
Following the receiving action:
class DocumentController extends ActionController
{
/**
* @param PersistentResource $document
* @param string $fileName
* @return bool|resource
*/
public function showAction(PersistentResource $document, string $fileName = "")
{
$fileName = ($fileName === "") ? $document->getFilename() : $fileName;
$this->response->setContentType($document->getMediaType());
$this->response->setComponentParameter(\Neos\Flow\Http\Component\SetHeaderComponent::class, "Content-Disposition","inline; filename=".$fileName);
return $document->getStream();
}
}
Replacing [“document” => $document by [“document” => “bla” an error will thrown, that the validation is failed - so, im princible, the redirect / forward is working.
Any ideas about this issues?
Thank you very much for your help!
Best regards,
Tobias