. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Http\ViewResponseTrait; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Module\ModuleReportInterface; use Fisharebest\Webtrees\Services\ModuleService; use Fisharebest\Webtrees\Validator; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; /** * Show all available reports. */ class ReportListPage implements RequestHandlerInterface { use ViewResponseTrait; private ModuleService $module_service; /** * @param ModuleService $module_service */ public function __construct(ModuleService $module_service) { $this->module_service = $module_service; } /** * A list of available reports. * * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $tree = Validator::attributes($request)->tree(); $user = Validator::attributes($request)->user(); $reports = $this->module_service ->findByComponent(ModuleReportInterface::class, $tree, $user); $title = I18N::translate('Choose a report to run'); return $this->viewResponse('report-select-page', [ 'reports' => $reports, 'title' => $title, 'tree' => $tree, ]); } }