This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
|
||||
final class SchoolYearViewDataService
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SchoolYearContextService $contextService,
|
||||
private readonly SchoolYearAccessPolicy $accessPolicy,
|
||||
) {
|
||||
}
|
||||
|
||||
public function forCurrentRequest(IncomingRequest $request): array
|
||||
{
|
||||
$context = $this->contextService->resolve($request);
|
||||
$userId = (int) (session()->get('user_id') ?? 0);
|
||||
|
||||
return [
|
||||
'schoolYearContext' => $context,
|
||||
'schoolYearOptions' => $this->contextService->selectableYears(
|
||||
$this->accessPolicy->canViewDraft($userId)
|
||||
),
|
||||
'schoolYearReadonly' => $context->isReadonly(),
|
||||
'schoolYearSelectorEnabled' => config('Feature')->globalSchoolYearSelector,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user