Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| HostContextViewInjection | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLayoutParameters | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Shared\View; |
| 6 | |
| 7 | use App\Domain\Host\Repository\HostRecordRepository; |
| 8 | use App\Domain\Menu\Service\MenuService; |
| 9 | use App\Shared\Host\ActiveHostProvider; |
| 10 | use App\Shared\Host\TablePrefixResolver; |
| 11 | use Yiisoft\Yii\View\Renderer\LayoutParametersInjectionInterface; |
| 12 | |
| 13 | class HostContextViewInjection implements LayoutParametersInjectionInterface |
| 14 | { |
| 15 | public function __construct( |
| 16 | private HostRecordRepository $hostRecordRepository, |
| 17 | private ActiveHostProvider $activeHostProvider, |
| 18 | private MenuService $menuService, |
| 19 | private TablePrefixResolver $prefixResolver |
| 20 | ) {} |
| 21 | |
| 22 | public function getLayoutParameters(): array |
| 23 | { |
| 24 | $recordsTable = $this->prefixResolver->resolve('menu_records'); |
| 25 | $sortTable = $this->prefixResolver->resolve('menu_sort'); |
| 26 | |
| 27 | return [ |
| 28 | 'allHosts' => $this->hostRecordRepository->findAll(), |
| 29 | 'activeHost' => $this->activeHostProvider->getActiveHost(), |
| 30 | 'menuTree' => $this->menuService->getMenuTree($recordsTable, $sortTable), |
| 31 | ]; |
| 32 | } |
| 33 | } |