| Total Complexity | 5 |
| Total Lines | 50 |
| 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 | \Zend\Expressive\Helper\BodyParams\BodyParamsMiddleware::class, |
||
| 31 | 2 | $this->dataProvider->provide()['input_filter_middleware_name'], |
|
| 32 | ]; |
||
| 33 | 2 | if ($this->dataProvider->provide()['has_owner']) { |
|
| 34 | $middleware[] = '\SlayerBirden\DataFlowServer\Domain\Middleware\SetOwnerMiddleware::class'; |
||
| 35 | } |
||
| 36 | 2 | $middleware[] = $this->getControllerFullName(); |
|
| 37 | return [ |
||
| 38 | [ |
||
| 39 | 2 | 'path' => '/' . $entity, |
|
| 40 | 2 | 'middleware' => $middleware, |
|
| 41 | 2 | 'name' => 'add_' . $entity, |
|
| 42 | 'allowed_methods' => ['POST'], |
||
| 43 | ], |
||
| 44 | ]; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @inheritdoc |
||
| 49 | */ |
||
| 50 | 2 | public function getCode(): string |
|
| 51 | { |
||
| 52 | 2 | return self::PART_KEY; |
|
| 53 | } |
||
| 54 | |||
| 55 | 2 | private function getControllerFullName(): string |
|
| 59 | } |
||
| 60 | } |
||
| 61 |