Exceptions
Exception
ErrorException
*/
public function download( Request $request,$id){
$productPdf = $this->em->getRepository(ProductPdf::class)->find($id);
$response = new Response();
if($productPdf){
$response->setContent(file_get_contents($this->params->get('productPdf_directory').'/'.$productPdf->getFile()));
$response->headers->set('Content-Type', 'application/force-download');
$response->headers->set('Content-disposition', 'filename= '.$productPdf->getFile());
$response->setStatusCode(200);
return $response;
}
$this->dispatcher->dispatch($event, KernelEvents::CONTROLLER_ARGUMENTS);
$controller = $event->getController();
$arguments = $event->getArguments();
// call controller
$response = $controller(...$arguments);
// view
if (!$response instanceof Response) {
$event = new ViewEvent($this, $request, $type, $response);
$this->dispatcher->dispatch($event, KernelEvents::VIEW);
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
try {
return $this->handleRaw($request, $type);
} catch (\Exception $e) {
if ($e instanceof RequestExceptionInterface) {
$e = new BadRequestHttpException($e->getMessage(), $e);
}
if (false === $catch) {
Stack Trace
ErrorException |
---|
ErrorException: Warning: file_get_contents(/home/preprodcopees/www/copees-sf/public/productPdf/89b88613e6bb4745354637c0cb2d3c88.pdf): failed to open stream: No such file or directory at src/Controller/Front/TopPdfProductController.php:171 at App\Controller\Front\TopPdfProductController->download(object(Request), '11') (vendor/symfony/http-kernel/HttpKernel.php:151) at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1) (vendor/symfony/http-kernel/HttpKernel.php:68) at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true) (vendor/symfony/http-kernel/Kernel.php:198) at Symfony\Component\HttpKernel\Kernel->handle(object(Request)) (public/index.php:25) |