createFromDB($id_order); if ($order->order_no === null) { return new Response('Neexistujici objednavka'); } try { increaseMaxExecutionTime(60); $attachment = $attachmentLocator->getServiceByType($type, $order); $response = new Response(); $response->headers->set('Content-Type', $attachment->getMimeType()); $response->headers->set('Content-Disposition', 'inline; filename="'.$attachment->getFilename().'"'); $content = $attachment->getContent(); if (!$content) { throw new \UnexpectedValueException('PDF error: server returned false'); } if ($attachment->getAttachmentType() == BaseAttachment::TYPE_PATH) { $content = file_get_contents($content); } $response->setContent($content); return $response; } catch (UnknownAttachmentTypeException $e) { return new Response('Neexistujici typ prilohy'); } catch (\UnexpectedValueException $e) { getRaven()->captureException($e); return new Response('Přílohu se nepodařilo vygenerovat, zkuste to znovu.'); } catch (InvoiceException $e) { return new Response($e->getMessage()); } } }