1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace App\Controller;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Component\Routing\Annotation\Route;
- use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
- class BlogController extends Controller {
- /**
- * @param $page
- *
- * @return Response
- *
- * @Route(
- * name ="blog_list",
- * path ="/blog/{page}",
- * requirements={"page" = "\d+"}
- * )
- */
- public function list($page = 1) {
- return new Response("Page $page of the blog list.");
- }
- /**
- * @param $slug
- *
- * @return \Symfony\Component\HttpFoundation\Response
- *
- * @Route(
- * name = "blog_show",
- * path = "/blog/{slug}"
- * )
- */
- public function show($slug) {
- $path = $this->generateUrl('blog_list', [
- // Placeholder: fit in the path.
- 'page' => 2,
- // Non-placeholder: fit in the query
- 'foo' => 'bar',
- ], UrlGeneratorInterface::ABSOLUTE_PATH);
- return new Response("Show $slug. Back to page 2: $path");
- }
- }
|