@@ -9,6 +9,8 @@ use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Services\ApiClient;
|
||||
use App\Support\SchoolYear\SchoolYearContext;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Class BaseController
|
||||
@@ -88,6 +90,27 @@ abstract class BaseController extends Controller
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
protected function resolveSchoolYearContext(?int $routeSchoolYearId = null): SchoolYearContext
|
||||
{
|
||||
try {
|
||||
return service('schoolYearContext')->resolve($this->request, $routeSchoolYearId);
|
||||
} catch (Throwable $e) {
|
||||
log_message('warning', 'School-year resolution failed: {message}', [
|
||||
'message' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
protected function assertSchoolYearWritable(
|
||||
SchoolYearContext $context,
|
||||
bool $allowDraftForAdmin = false,
|
||||
bool $isAdmin = false
|
||||
): void {
|
||||
service('schoolYearWriteGuard')->assertWritable($context, $allowDraftForAdmin, $isAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user