-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEntityRouteProvider.php
More file actions
56 lines (45 loc) · 1.9 KB
/
EntityRouteProvider.php
File metadata and controls
56 lines (45 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
declare(strict_types=1);
namespace Drupal\paatokset_allu\Entity\Routing;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
use Drupal\paatokset_allu\Controller\Controller;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
/**
* Provides routes for content entities.
*/
class EntityRouteProvider extends AdminHtmlRouteProvider {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type): RouteCollection|array {
$collection = parent::getRoutes($entity_type);
if ($entity_type->id() === 'paatokset_allu_document') {
$route = (new Route('/allu/document/{paatokset_allu_document}/download'))
->addDefaults([
'_controller' => Controller::class . '::decision',
])
->setRequirement('paatokset_allu_document', '\d+')
->setRequirement('_entity_access', 'paatokset_allu_document.view');
$collection->add('entity.paatokset_allu_document.canonical', $route);
$route = (new Route('/allu/document/{paatokset_allu_document}/approval/{type}/download'))
->addDefaults([
'_controller' => Controller::class . '::approvalFromDecision',
])
->setRequirement('paatokset_allu_document', '\d+')
->setRequirement('_entity_access', 'paatokset_allu_document.view');
$collection->add('entity.paatokset_allu_document.approval', $route);
}
if ($entity_type->id() === 'paatokset_allu_approval') {
$route = (new Route('/allu/approval/{paatokset_allu_approval}/download'))
->addDefaults([
'_controller' => Controller::class . '::approval',
])
->setRequirement('paatokset_allu_approval', '\d+')
->setRequirement('_entity_access', 'paatokset_allu_approval.view');
$collection->add('entity.paatokset_allu_approval.canonical', $route);
}
return $collection;
}
}