Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| GraphqlRouteDefinitionProvider | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| getActionsForBoundedContext | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\Graphql\RouteDefinitions; |
| 3 | |
| 4 | use Apie\Common\Interfaces\RouteDefinitionProviderInterface; |
| 5 | use Apie\Common\RouteDefinitions\ActionHashmap; |
| 6 | use Apie\Core\BoundedContext\BoundedContext; |
| 7 | use Apie\Core\Context\ApieContext; |
| 8 | |
| 9 | final class GraphqlRouteDefinitionProvider implements RouteDefinitionProviderInterface |
| 10 | { |
| 11 | public function getActionsForBoundedContext(BoundedContext $boundedContext, ApieContext $apieContext): ActionHashmap |
| 12 | { |
| 13 | $routes = []; |
| 14 | $definition = new GraphqlPlaygroundRouteDefinition($boundedContext->getId()); |
| 15 | $routes[$definition->getOperationId()] = $definition; |
| 16 | $definition = new GraphqlRouteDefinition($boundedContext->getId()); |
| 17 | $routes[$definition->getOperationId()] = $definition; |
| 18 | foreach ($boundedContext->resources as $resource) { |
| 19 | $definition = new DownloadFileRouteDefinition($resource, $boundedContext->getId()); |
| 20 | $routes[$definition->getOperationId()] = $definition; |
| 21 | } |
| 22 | |
| 23 | return new ActionHashmap($routes); |
| 24 | } |
| 25 | } |