Forward / redirect with PersistenceResource as argument

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

Hi Tobias,

How does it look if you use \Neos\Flow\var_dump($invoice->getDocument()); - do you get a persisted resource in return?

Dear Soren,

thank you very much for your prompt reply.

A var_dump on $invoice->getDocument() gives me:

Flow Variable Dump

[Neos\Flow\Persistence\Doctrine\Proxies_CG_\Neos\Flow\ResourceManagement\PersistentResource persistable proxy]

Best regards,

Tobias