You are here

config_entity_example.routing.yml in Examples for Developers 8

config_entity_example/config_entity_example.routing.yml

File

config_entity_example/config_entity_example.routing.yml
View source
  1. # The routing.yml file defines the paths for our module.
  2. # Here we define the paths for our entity type's admin UI.
  3. # This is the router item for listing all entities.
  4. entity.robot.list:
  5. path: '/examples/config-entity-example'
  6. defaults:
  7. # '_entity_list' tells Drupal to use an entity list controller.
  8. # We give the entity ID here. Drupal then looks in the entity's annotation
  9. # and looks for the "list" entry under "controllers" for the class to load.
  10. # @see \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer
  11. _entity_list: robot
  12. _title: 'Config Entity Example'
  13. requirements:
  14. _permission: 'administer robots'
  15. # This is the router item for adding our entity.
  16. entity.robot.add_form:
  17. path: '/examples/config-entity-example/add'
  18. defaults:
  19. _title: 'Add robot'
  20. # Like _entity_list above, _entity_form gives the entity type ID, only this
  21. # time also lists the form separated by a period. Drupal looks in the
  22. # annotation for the entity and locates the "add" entry under "form" for
  23. # the form class to load.
  24. # @see \Drupal\Core\Entity\Enhancer\EntityRouteEnhancer
  25. _entity_form: robot.add
  26. requirements:
  27. _entity_create_access: robot
  28. # This is the router item for editing our entity.
  29. entity.robot.edit_form:
  30. # Parameters may be passed to the form via the URL path. We name the
  31. # parameter in the path by enclosing it in curly braces. For entity forms,
  32. # we include the entity ID in the path by including a parameter with the
  33. # same name as the entity type ID.
  34. path: '/examples/config-entity-example/manage/{robot}'
  35. defaults:
  36. _title: 'Edit robot'
  37. # List our add entry above, this _entity_form entry instructs Drupal to
  38. # read our entity type's annonation, and look for the "edit" entry under
  39. # "form".
  40. _entity_form: robot.edit
  41. requirements:
  42. # This uses our entity access controller.
  43. # @see \Drupal\Core\Entity\EntityAccessCheck
  44. _entity_access: robot.update
  45. # This is the router item for deleting an instance of our entity.
  46. entity.robot.delete_form:
  47. path: '/examples/config-entity-example/manage/{robot}/delete'
  48. defaults:
  49. _title: 'Delete robot'
  50. _entity_form: robot.delete
  51. requirements:
  52. _entity_access: robot.delete