You are here

content_entity_example.routing.yml in Examples for Developers 3.x

modules/content_entity_example/content_entity_example.routing.yml

File

modules/content_entity_example/content_entity_example.routing.yml
View source
  1. # This file brings everything together. Very nifty!
  2. # Route name can be used in several places; e.g. links, redirects, and local
  3. # actions.
  4. entity.content_entity_example_contact.canonical:
  5. path: '/content_entity_example_contact/{content_entity_example_contact}'
  6. defaults:
  7. # Calls the view controller, defined in the annotation of the contact
  8. # entity. This marks this route as belonging to this entity type.
  9. _entity_view: 'content_entity_example_contact'
  10. _title: 'Contact content'
  11. requirements:
  12. # Calls the access controller of the entity, passing in the suffix ('view')
  13. # as the $operation parameter to checkAccess().
  14. _entity_access: 'content_entity_example_contact.view'
  15. entity.content_entity_example_contact.collection:
  16. path: '/content_entity_example_contact/list'
  17. defaults:
  18. # Calls the list controller, defined in the annotation of the contact entity.
  19. _entity_list: 'content_entity_example_contact'
  20. _title: 'Contact list'
  21. requirements:
  22. # Checks for permission directly.
  23. _permission: 'view contact entity'
  24. content_entity_example.contact_add:
  25. path: '/content_entity_example_contact/add'
  26. defaults:
  27. # Calls the form.add controller, defined in the contact entity.
  28. _entity_form: content_entity_example_contact.default
  29. _title: 'Add contact'
  30. requirements:
  31. # Use the entity's access controller. _entity_create_access tells the router
  32. # to use the access controller's checkCreateAccess() method instead of
  33. # checkAccess().
  34. _entity_create_access: 'content_entity_example_contact'
  35. entity.content_entity_example_contact.edit_form:
  36. path: '/content_entity_example_contact/{content_entity_example_contact}/edit'
  37. defaults:
  38. # Calls the form.edit controller, defined in the contact entity.
  39. _entity_form: content_entity_example_contact.default
  40. _title: 'Edit contact'
  41. requirements:
  42. # Calls the access controller of the entity, passing in the suffix
  43. # ('update') as the $operation parameter to checkAccess().
  44. _entity_access: 'content_entity_example_contact.update'
  45. entity.content_entity_example_contact.delete_form:
  46. path: '/contact/{content_entity_example_contact}/delete'
  47. defaults:
  48. # Calls the form.delete controller, defined in the contact entity.
  49. _entity_form: content_entity_example_contact.delete
  50. _title: 'Delete contact'
  51. requirements:
  52. # Calls the access controller of the entity, passing in the suffix
  53. # ('delete') as the $operation parameter to checkAccess().
  54. _entity_access: 'content_entity_example_contact.delete'
  55. content_entity_example.contact_settings:
  56. path: '/admin/structure/content_entity_example_contact_settings'
  57. defaults:
  58. _form: '\Drupal\content_entity_example\Form\ContactSettingsForm'
  59. _title: 'Contact settings'
  60. requirements:
  61. _permission: 'administer contact entity'