3 namespace Drupal\user\Entity;
5 use Drupal\Core\Entity\EntityTypeInterface;
6 use Drupal\Core\Entity\Routing\EntityRouteProviderInterface;
7 use Symfony\Component\Routing\Route;
8 use Symfony\Component\Routing\RouteCollection;
11 * Provides routes for the user entity.
13 class UserRouteProvider implements EntityRouteProviderInterface {
18 public function getRoutes(EntityTypeInterface $entity_type) {
19 $route_collection = new RouteCollection();
20 $route = (new Route('/user/{user}'))
22 '_entity_view' => 'user.full',
23 '_title_callback' => 'Drupal\user\Controller\UserController::userTitle',
25 ->setRequirement('user', '\d+')
26 ->setRequirement('_entity_access', 'user.view');
27 $route_collection->add('entity.user.canonical', $route);
29 $route = (new Route('/user/{user}/edit'))
31 '_entity_form' => 'user.default',
32 '_title_callback' => 'Drupal\user\Controller\UserController::userTitle',
34 ->setOption('_admin_route', TRUE)
35 ->setRequirement('user', '\d+')
36 ->setRequirement('_entity_access', 'user.update');
37 $route_collection->add('entity.user.edit_form', $route);
39 $route = (new Route('/user/{user}/cancel'))
41 '_title' => 'Cancel account',
42 '_entity_form' => 'user.cancel',
44 ->setOption('_admin_route', TRUE)
45 ->setRequirement('user', '\d+')
46 ->setRequirement('_entity_access', 'user.delete');
47 $route_collection->add('entity.user.cancel_form', $route);
49 return $route_collection;