Mercurial > hg > isophonics-drupal-site
comparison core/modules/user/src/Entity/UserRouteProvider.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\user\Entity; | |
4 | |
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; | |
9 | |
10 /** | |
11 * Provides routes for the user entity. | |
12 */ | |
13 class UserRouteProvider implements EntityRouteProviderInterface { | |
14 | |
15 /** | |
16 * {@inheritdoc} | |
17 */ | |
18 public function getRoutes(EntityTypeInterface $entity_type) { | |
19 $route_collection = new RouteCollection(); | |
20 $route = (new Route('/user/{user}')) | |
21 ->setDefaults([ | |
22 '_entity_view' => 'user.full', | |
23 '_title_callback' => 'Drupal\user\Controller\UserController::userTitle', | |
24 ]) | |
25 ->setRequirement('user', '\d+') | |
26 ->setRequirement('_entity_access', 'user.view'); | |
27 $route_collection->add('entity.user.canonical', $route); | |
28 | |
29 $route = (new Route('/user/{user}/edit')) | |
30 ->setDefaults([ | |
31 '_entity_form' => 'user.default', | |
32 '_title_callback' => 'Drupal\user\Controller\UserController::userTitle', | |
33 ]) | |
34 ->setOption('_admin_route', TRUE) | |
35 ->setRequirement('user', '\d+') | |
36 ->setRequirement('_entity_access', 'user.update'); | |
37 $route_collection->add('entity.user.edit_form', $route); | |
38 | |
39 $route = (new Route('/user/{user}/cancel')) | |
40 ->setDefaults([ | |
41 '_title' => 'Cancel account', | |
42 '_entity_form' => 'user.cancel', | |
43 ]) | |
44 ->setOption('_admin_route', TRUE) | |
45 ->setRequirement('user', '\d+') | |
46 ->setRequirement('_entity_access', 'user.delete'); | |
47 $route_collection->add('entity.user.cancel_form', $route); | |
48 | |
49 return $route_collection; | |
50 } | |
51 | |
52 } |