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