Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| DashboardController | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __invoke | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Cms\Controllers; |
| 3 | |
| 4 | use Apie\Cms\Services\ResponseFactory; |
| 5 | use Apie\Core\BoundedContext\BoundedContextId; |
| 6 | use Apie\Core\ContextBuilders\ContextBuilderFactory; |
| 7 | use Apie\Core\ContextConstants; |
| 8 | use Apie\HtmlBuilders\Factories\ComponentFactory; |
| 9 | use Psr\Http\Message\ResponseInterface; |
| 10 | use Psr\Http\Message\ServerRequestInterface; |
| 11 | use Stringable; |
| 12 | |
| 13 | class DashboardController |
| 14 | { |
| 15 | public function __construct( |
| 16 | private readonly ComponentFactory $componentFactory, |
| 17 | private readonly ContextBuilderFactory $contextBuilder, |
| 18 | private readonly ResponseFactory $responseFactory, |
| 19 | private readonly string|Stringable $dashboardContents = '' |
| 20 | ) { |
| 21 | } |
| 22 | |
| 23 | public function __invoke(ServerRequestInterface $request): ResponseInterface |
| 24 | { |
| 25 | $context = $this->contextBuilder->createFromRequest($request, [ContextConstants::CMS => true]); |
| 26 | $boundedContextId = new BoundedContextId($request->getAttribute('boundedContextId')); |
| 27 | $component = $this->componentFactory->createWrapLayout( |
| 28 | 'Dashboard', |
| 29 | $boundedContextId, |
| 30 | $context, |
| 31 | $this->componentFactory->createRawContents($this->dashboardContents) |
| 32 | ); |
| 33 | return $this->responseFactory->createComponentPageRender($component, $context); |
| 34 | } |
| 35 | } |