123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- Routing
- =======
- The default routes used in the CRUD controller are accessible through the
- ``Admin`` class.
- The ``Admin`` class contains two routing method:
- * ``getUrls()``: Returns the available routes;
- * ``generateUrl($name, $options)``: Generates the related routes.
- Routing Definition
- ------------------
- You must set a ``base_route`` property inside your ``Admin`` class, which
- represents the each route prefix.
- .. code-block:: php
- class PostAdmin extends Admin
- {
- protected $class = 'Application\NewsBundle\Entity\Post';
- protected $base_route = 'news_post_admin';
- }
- This definition is mandatory.
- .. code-block:: xml
- <?xml version="1.0" encoding="UTF-8" ?>
- <routes xmlns="http://www.symfony-project.org/schema/routing"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.symfony-project.org/schema/routing http://www.symfony-project.org/schema/routing/routing-1.0.xsd">
- <!-- NEWS CONTROLLER -->
- <route id="news_post_admin_list" pattern="/post">
- <default key="_controller">NewsBundle:PostAdmin:list</default>
- </route>
- <route id="news_post_admin_create" pattern="/post/create">
- <default key="_controller">NewsBundle:PostAdmin:create</default>
- </route>
- <route id="news_post_admin_batch" pattern="/post/batch">
- <default key="_controller">NewsBundle:PostAdmin:batch</default>
- </route>
- <route id="news_post_admin_update" pattern="/post/update">
- <default key="_controller">NewsBundle:PostAdmin:update</default>
- </route>
- <route id="news_post_admin_edit" pattern="/post/:id/edit">
- <default key="_controller">NewsBundle:PostAdmin:edit</default>
- </route>
- <route id="news_post_admin_delete" pattern="/post/:id/delete">
- <default key="_controller">NewsBundle:PostAdmin:delete</default>
- </route>
- </routes>
- Routing usage
- -------------
- Inside a CRUD template, a route can be generated by using the ``Admin`` class.
- .. code-block:: html
- <a href="{{ configuration.generateUrl('list') }}">List</a>
- <a href="{{ configuration.generateUrl('list', params|merge('page': 1) }}">List</a>
|