Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
70.00% |
7 / 10 |
|
87.50% |
7 / 8 |
CRAP | |
0.00% |
0 / 1 |
| DownloadFileRouteDefinition | |
70.00% |
7 / 10 |
|
87.50% |
7 / 8 |
11.19 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getController | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUrlPrefixes | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getOperationId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getMethod | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getUrl | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAction | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| createFrom | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | namespace Apie\Graphql\RouteDefinitions; |
| 3 | |
| 4 | use Apie\Common\ActionDefinitions\ActionDefinitionInterface; |
| 5 | use Apie\Common\ActionDefinitions\DownloadFilesActionDefinition; |
| 6 | use Apie\Common\Actions\StreamItemMethodAction; |
| 7 | use Apie\Common\Enums\UrlPrefix; |
| 8 | use Apie\Common\Lists\UrlPrefixList; |
| 9 | use Apie\Common\RouteDefinitions\AbstractRestApiRouteDefinition; |
| 10 | use Apie\Core\BoundedContext\BoundedContextId; |
| 11 | use Apie\Core\Enums\RequestMethod; |
| 12 | use Apie\Core\ValueObjects\UrlRouteDefinition; |
| 13 | use Apie\Graphql\Controllers\DownloadFileController; |
| 14 | use ReflectionClass; |
| 15 | |
| 16 | class DownloadFileRouteDefinition extends AbstractRestApiRouteDefinition |
| 17 | { |
| 18 | /** |
| 19 | * @param ReflectionClass<EntityInterface> $className |
| 20 | */ |
| 21 | public function __construct(ReflectionClass $className, BoundedContextId $boundedContextId) |
| 22 | { |
| 23 | parent::__construct($className, $boundedContextId); |
| 24 | } |
| 25 | |
| 26 | public function getController(): string |
| 27 | { |
| 28 | return DownloadFileController::class; |
| 29 | } |
| 30 | |
| 31 | public function getUrlPrefixes(): UrlPrefixList |
| 32 | { |
| 33 | return new UrlPrefixList([UrlPrefix::GRAPHQL]); |
| 34 | } |
| 35 | |
| 36 | public function getOperationId(): string |
| 37 | { |
| 38 | return 'stream-graphql-' . $this->class->getShortName() . '-run-download'; |
| 39 | } |
| 40 | |
| 41 | public function getMethod(): RequestMethod |
| 42 | { |
| 43 | return RequestMethod::GET; |
| 44 | } |
| 45 | |
| 46 | public function getUrl(): UrlRouteDefinition |
| 47 | { |
| 48 | return new UrlRouteDefinition('/' . $this->class->getShortName() . '/{id}/download/{properties}'); |
| 49 | } |
| 50 | |
| 51 | public function getAction(): string |
| 52 | { |
| 53 | return StreamItemMethodAction::class; |
| 54 | } |
| 55 | |
| 56 | public static function createFrom(ActionDefinitionInterface $actionDefinition): ?AbstractRestApiRouteDefinition |
| 57 | { |
| 58 | if ($actionDefinition instanceof DownloadFilesActionDefinition) { |
| 59 | return new self($actionDefinition->getResourceName(), $actionDefinition->getBoundedContextId()); |
| 60 | } |
| 61 | return null; |
| 62 | } |
| 63 | } |