. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Http\ViewResponseTrait; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Services\HomePageService; use Fisharebest\Webtrees\Validator; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function route; /** * Show a form to edit block config options. */ class TreePageBlockEdit implements RequestHandlerInterface { use ViewResponseTrait; private HomePageService $home_page_service; /** * @param HomePageService $home_page_service */ public function __construct(HomePageService $home_page_service) { $this->home_page_service = $home_page_service; } /** * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $tree = Validator::attributes($request)->tree(); $block_id = Validator::attributes($request)->integer('block_id'); $block = $this->home_page_service->treeBlock($request); $title = $block->title() . ' — ' . I18N::translate('Preferences'); return $this->viewResponse('modules/edit-block-config', [ 'block' => $block, 'block_id' => $block_id, 'cancel_url' => route(TreePage::class, ['tree' => $tree->name()]), 'save_url' => route(TreePageBlockUpdate::class, ['tree' => $tree->name(), 'block_id' => $block_id]), 'title' => $title, 'tree' => $tree, ]); } }