Total Complexity | 5 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Coverage | 94.44% |
Changes | 0 |
1 | <?php |
||
9 | final class Routes implements ConfigPartInterface |
||
10 | { |
||
11 | const PART_KEY = 'routes'; |
||
12 | /** |
||
13 | * @var DataProviderInterface |
||
14 | */ |
||
15 | private $dataProvider; |
||
16 | |||
17 | 2 | public function __construct(DataProviderInterface $dataProvider) |
|
20 | 2 | } |
|
21 | |||
22 | /** |
||
23 | * @inheritdoc |
||
24 | */ |
||
25 | 2 | public function getConfig(): array |
|
26 | { |
||
27 | 2 | $entity = $this->dataProvider->provide()['refName']; |
|
28 | $middleware = [ |
||
29 | 2 | '\SlayerBirden\DataFlowServer\Authentication\Middleware\TokenMiddleware::class', |
|
30 | 2 | $this->dataProvider->provide()['entityClassName'] . 'ResourceMiddleware', |
|
31 | ]; |
||
32 | 2 | if ($this->dataProvider->provide()['has_owner']) { |
|
33 | $middleware[] = '\SlayerBirden\DataFlowServer\Domain\Middleware\ValidateOwnerMiddleware::class'; |
||
34 | } |
||
35 | 2 | $middleware[] = $this->getControllerFullName(); |
|
36 | return [ |
||
37 | [ |
||
38 | 2 | 'path' => '/' . $entity . '/{id:\d+}', |
|
39 | 2 | 'middleware' => $middleware, |
|
40 | 2 | 'name' => 'get_' . $entity, |
|
41 | 'allowed_methods' => ['GET'], |
||
42 | ], |
||
43 | ]; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @inheritdoc |
||
48 | */ |
||
49 | 2 | public function getCode(): string |
|
52 | } |
||
53 | |||
54 | 2 | private function getControllerFullName(): string |
|
60 |