Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
DashboardController
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
2 / 2
2
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
 __invoke
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Cms\Controllers;
3
4use Apie\Cms\Services\ResponseFactory;
5use Apie\Core\BoundedContext\BoundedContextId;
6use Apie\Core\ContextBuilders\ContextBuilderFactory;
7use Apie\Core\ContextConstants;
8use Apie\HtmlBuilders\Factories\ComponentFactory;
9use Psr\Http\Message\ResponseInterface;
10use Psr\Http\Message\ServerRequestInterface;
11use Stringable;
12
13class 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}