render('hello.html.twig', ["message" => "Hello!"]); } /** * @return \Symfony\Component\HttpFoundation\RedirectResponse * * @\Symfony\Component\Routing\Annotation\Route( * name = "front_too", * path = "/front" * ) */ public function frontToo() { // As per RFC 7231 ยง 7.1.2, relative URLs are allowed. Try /front#foo ! // Never use a user-supplied URL without integrity checks: // https://www.owasp.org/index.php/Open_redirect // That's why Drupal has TrustedRedirectResponse and checks. return $this->redirect('/'); } /** * @return \Symfony\Component\HttpFoundation\RedirectResponse * * @\Symfony\Component\Routing\Annotation\Route( * name = "blog_42", * path = "/question" * ) */ public function blog42() { // Notice how the matching route will actually be blog_list, because once // the redirect is sent, the browser has no notion of the initially // requested route name and parameters, and routing just receives an URL, // matching it without knowledge of the initial URL generation choices. return $this->redirectToRoute('blog_show', ['slug' => 42]); } /** * @param $name * @param \App\GreetingGenerator $generator * * @return \Symfony\Component\HttpFoundation\Response * * @Route( * name="hello_html", * path="/hello/{name}" * ) */ public function hello($name, GreetingGenerator $generator) { $greeting = $generator->getRandomGreeting(); return new Response("$greeting $name"); } /** * @param $name * * @return \Symfony\Component\HttpFoundation\JsonResponse * * @Route("/json/{name}", * name="hello_json", * ) */ public function helloJson($name) { return $this->json([ 'name' => $name, ]); } }