routing.rst 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. Routing
  2. =======
  3. The default routes used in the CRUD controller are accessible through the
  4. ``Admin`` class.
  5. The ``Admin`` class contains two routing method:
  6. * ``getUrls()``: Returns the available routes;
  7. * ``generateUrl($name, $options)``: Generates the related routes.
  8. Routing Definition
  9. ------------------
  10. You can set a ``baseRouteName`` property inside your ``Admin`` class, which
  11. represents the route prefix.
  12. .. code-block:: php
  13. class PostAdmin extends Admin
  14. {
  15. protected $baseRouteName = 'news_post_admin';
  16. }
  17. If no ``baseRouteName`` is defined then the Admin will pick on for you, built on
  18. following format : 'admin_vendor_bundlename_entityname_action'. If the Admin
  19. fails to find the best baseRouteName then a ``RuntimeException`` will
  20. be throw.
  21. The same goes for the ``baseRoutePattern``.
  22. Routing usage
  23. -------------
  24. Inside a CRUD template, a route can be generated by using the ``Admin`` class.
  25. .. code-block:: html
  26. <a href="{{ admin.generateUrl('list') }}">List</a>
  27. <a href="{{ admin.generateUrl('list', params|merge('page': 1) }}">List</a>