Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
| RemoveResourceFormCommitRouteDefinition | |
100.00% |
9 / 9 |
|
100.00% |
7 / 7 |
8 | |
100.00% |
1 / 1 |
| createFrom | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| __construct | |
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 | |||
| getController | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAction | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getOperationId | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Cms\RouteDefinitions; |
| 3 | |
| 4 | use Apie\Cms\Controllers\FormCommitController; |
| 5 | use Apie\Common\ActionDefinitions\ActionDefinitionInterface; |
| 6 | use Apie\Common\ActionDefinitions\RemoveResourceActionDefinition; |
| 7 | use Apie\Common\Actions\RemoveObjectAction; |
| 8 | use Apie\Core\BoundedContext\BoundedContextId; |
| 9 | use Apie\Core\Enums\RequestMethod; |
| 10 | use Apie\Core\ValueObjects\UrlRouteDefinition; |
| 11 | use ReflectionClass; |
| 12 | |
| 13 | class RemoveResourceFormCommitRouteDefinition extends AbstractCmsRouteDefinition |
| 14 | { |
| 15 | public static function createFrom(ActionDefinitionInterface $actionDefinition): ?AbstractCmsRouteDefinition |
| 16 | { |
| 17 | if ($actionDefinition instanceof RemoveResourceActionDefinition) { |
| 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/delete/' . $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 RemoveObjectAction::class; |
| 46 | } |
| 47 | |
| 48 | public function getOperationId(): string |
| 49 | { |
| 50 | return 'delete-resource-form-commit-' . $this->class->getShortName(); |
| 51 | } |
| 52 | } |