Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
AbstractCmsRouteDefinition
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getMainMenuUri
n/a
0 / 0
n/a
0 / 0
0
 getRouteAttributes
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 getUrlPrefixes
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\Common\Enums\UrlPrefix;
5use Apie\Common\Interfaces\HasActionDefinition;
6use Apie\Common\Interfaces\HasRouteDefinition;
7use Apie\Common\Lists\UrlPrefixList;
8use Apie\Core\BoundedContext\BoundedContextId;
9use Apie\Core\ContextConstants;
10use Apie\Core\ValueObjects\UrlRouteDefinition;
11use ReflectionClass;
12use ReflectionMethod;
13
14abstract class AbstractCmsRouteDefinition implements HasRouteDefinition, HasActionDefinition
15{
16    /**
17     * @param ReflectionClass<object> $class
18     */
19    public function __construct(
20        protected readonly ReflectionClass $class,
21        protected readonly ?BoundedContextId $boundedContextId = null,
22        protected readonly ?ReflectionMethod $method = null
23    ) {
24    }
25
26    abstract public function getMainMenuUri(): ?UrlRouteDefinition;
27
28    final public function getRouteAttributes(): array
29    {
30        $actionClass = $this->getAction();
31        $attributes = $actionClass::getRouteAttributes($this->class, $this->method);
32        $attributes[ContextConstants::APIE_ACTION] = $this->getAction();
33        $attributes[ContextConstants::CMS] = true;
34        $attributes[ContextConstants::OPERATION_ID] = $this->getOperationId();
35        $attributes[ContextConstants::BOUNDED_CONTEXT_ID] = $this->boundedContextId->toNative();
36        return $attributes;
37    }
38
39    final public function getUrlPrefixes(): UrlPrefixList
40    {
41        return new UrlPrefixList([UrlPrefix::CMS]);
42    }
43}