爱自由 2019-06-26
$this->get($serviceId);
$this->redirectToRoute($routeName, $parameters, $status = 302);
$this->generateUrl($routeName, $parameters, $referenceType);
$this->json($data, $status = 200, $headers = array(), $context = array());
$this->addFlash($type, $message);
$this->isGranted('ROLE_ADMIN');$this->denyAccessUnlessGranted('ROLE_EDIT', $item, 'You cannot edit this item.');$this->isCsrfTokenValid('token_id', $token);$this->forward('GregwarCaptchaBundle:Captcha:generateCaptcha', ['key' => $key]);
//forward($controller, array $path = array(), array $query = array())
PS: 第二个参数为route上占位符参数,第三个为其他额外的参数$this->file();
//简单用法示例
return $this->file($docPath, $saveName);
// 如果是pdf之类,直接显示而不是下载,需要设置第三个参数ResponseHeaderBag::DISPOSITION_INLINE
// 还可以直接接受一个File或者UploadedFile实例
//$samplePdf = new File('/sample.pdf');
//return $this->file($samplePdf);$this->getParameter('kernel.root_dir');