Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
1 / 1
DisplayResourceOverviewRouteDefinition
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
7 / 7
8
100.00% covered (success)
100.00%
1 / 1
 createFrom
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getMethod
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUrl
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getController
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAction
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getOperationId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Cms\RouteDefinitions;
3
4use Apie\Cms\Controllers\GetResourceListController;
5use Apie\Common\ActionDefinitions\ActionDefinitionInterface;
6use Apie\Common\ActionDefinitions\GetResourceListActionDefinition;
7use Apie\Common\Actions\GetListAction;
8use Apie\Core\BoundedContext\BoundedContextId;
9use Apie\Core\Enums\RequestMethod;
10use Apie\Core\ValueObjects\UrlRouteDefinition;
11use ReflectionClass;
12
13class DisplayResourceOverviewRouteDefinition extends AbstractCmsRouteDefinition
14{
15    public static function createFrom(ActionDefinitionInterface $actionDefinition): ?AbstractCmsRouteDefinition
16    {
17        if ($actionDefinition instanceof GetResourceListActionDefinition) {
18            return new self($actionDefinition->getResourceName(), $actionDefinition->getBoundedContextId());
19        }
20        return null;
21    }
22
23    public function __construct(ReflectionClass $class, BoundedContextId $id)
24    {
25        parent::__construct($class, $id);
26    }
27
28    public function getMethod(): RequestMethod
29    {
30        return RequestMethod::GET;
31    }
32
33    public function getUrl(): UrlRouteDefinition
34    {
35        return new UrlRouteDefinition('/resource/' . $this->class->getShortName());
36    }
37    /**
38     * @return class-string<object>
39     */
40    public function getController(): string
41    {
42        return GetResourceListController::class;
43    }
44
45    public function getAction(): string
46    {
47        return GetListAction::class;
48    }
49
50    public function getOperationId(): string
51    {
52        return 'cms.resource.' . $this->class->getShortName();
53    }
54}