Estimados tengo este método:
/**
* @Security("has_role('ROLE_BONOS_FACTURADO_LISTAR') or has_role('ROLE_IDDQD')")
* @Route("/admin/bono/facturados/descargar/{uuid}", name="bonos_facturados_descargar_pdf")
* @return \Symfony\Component\HttpFoundation\Response
* @throws \Exception
*/
public function downloadPDF($uuid) {
$response = new Response();
$response->headers->set('Content-Type', 'application/pdf');
$fullpath = $this->get('kernel')->getProjectDir(). "/../web/bonos/" . $uuid . ".pdf";
$response->headers->set('Content-Disposition', 'attachment;filename="' . $uuid . '.pdf');
$content = @file_get_contents($fullpath);
if ($content == false) {
$this->addFlashError('No se encontro la factura');
return $this->redirectToRoute('bonos_facturados');
}
$response->setContent($content);
return $response;
}
Y me esta arrojando este error:
Service "kernel" not found: even though it exists in the app's container, the container inside "App\Controller\BonoController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session", "templating" and "twig" services. Try using dependency injection instead.