Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| DashboardController | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| index | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Modules\User\Presentation\Web; |
| 6 | |
| 7 | use Psr\Http\Message\ResponseFactoryInterface; |
| 8 | use Psr\Http\Message\ResponseInterface; |
| 9 | use Twig\Environment as TwigEnvironment; |
| 10 | use Yiisoft\User\CurrentUser; |
| 11 | |
| 12 | /** |
| 13 | * Dashboard Controller for Authenticated Zone. |
| 14 | * |
| 15 | * Renders protected dashboard welcome area. |
| 16 | * |
| 17 | * @package App\Modules\User\Presentation\Web |
| 18 | */ |
| 19 | final readonly class DashboardController |
| 20 | { |
| 21 | /** |
| 22 | * DashboardController constructor. |
| 23 | * |
| 24 | * @param ResponseFactoryInterface $responseFactory PSR-7 Response factory. |
| 25 | * @param TwigEnvironment $twig Twig template environment. |
| 26 | * @param CurrentUser $currentUser Yii3 CurrentUser service instance. |
| 27 | */ |
| 28 | public function __construct( |
| 29 | private ResponseFactoryInterface $responseFactory, |
| 30 | private TwigEnvironment $twig, |
| 31 | private CurrentUser $currentUser |
| 32 | ) { |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Renders dashboard home view for authenticated users. |
| 37 | * |
| 38 | * @return ResponseInterface PSR-7 HTML response containing dashboard view. |
| 39 | */ |
| 40 | public function index(): ResponseInterface |
| 41 | { |
| 42 | $userId = $this->currentUser->getId(); |
| 43 | |
| 44 | $html = $this->twig->render('dashboard/index.twig', [ |
| 45 | 'userId' => $userId, |
| 46 | ]); |
| 47 | |
| 48 | $response = $this->responseFactory->createResponse(200); |
| 49 | $response->getBody()->write($html); |
| 50 | return $response->withHeader('Content-Type', 'text/html; charset=utf-8'); |
| 51 | } |
| 52 | } |