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
ModifyResourceCommitRouteDefinition
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\FormCommitController;
5use Apie\Common\ActionDefinitions\ActionDefinitionInterface;
6use Apie\Common\ActionDefinitions\ModifyResourceActionDefinition;
7use Apie\Common\Actions\ModifyObjectAction;
8use Apie\Core\BoundedContext\BoundedContextId;
9use Apie\Core\Enums\RequestMethod;
10use Apie\Core\ValueObjects\UrlRouteDefinition;
11use ReflectionClass;
12
13class ModifyResourceCommitRouteDefinition extends AbstractCmsRouteDefinition
14{
15    public static function createFrom(ActionDefinitionInterface $actionDefinition): ?AbstractCmsRouteDefinition
16    {
17        if ($actionDefinition instanceof ModifyResourceActionDefinition) {
18            return new self($actionDefinition->getResourceName(), $actionDefinition->getBoundedContextId());
19        }
20        return null;
21    }
22
23    public function __construct(ReflectionClass $class, BoundedContextId $boundedContextId)
24    {
25        parent::__construct($class, $boundedContextId);
26    }
27
28    public function getMethod(): RequestMethod
29    {
30        return RequestMethod::POST;
31    }
32
33    public function getUrl(): UrlRouteDefinition
34    {
35        return new UrlRouteDefinition('/resource/edit/' . $this->class->getShortName() . '/{id}');
36    }
37
38    public function getController(): string
39    {
40        return FormCommitController::class;
41    }
42
43    public function getAction(): string
44    {
45        return ModifyObjectAction::class;
46    }
47
48    public function getOperationId(): string
49    {
50        return 'modify-resource-commit-' . $this->class->getShortName();
51    }
52}