documentRepository = $this->em->getRepository($this->em->getClassMetadata(DocumentInterface::class)->getName()) ; } public function downloadInvoiceAction() { $idDocument = $this->request->get('id') ; $document = $this->documentRepository->find($idDocument) ; $orderShop = null ; if($document) { $orderShops = $document->getOrderShops() ; $orderShop = (isset($orderShops[0])) ? $orderShops[0] : null ; } if($document && $orderShop) { return new StreamedResponse(function () use ($orderShop) { $this->orderUtils->generateDocumentInvoiceOrderShop($orderShop, 'download') ; }); } else { throw new NotFoundHttpException('Document introuvable') ; } } }