. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; 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 redirect; use function route; /** * Update block config options. */ class TreePageBlockUpdate implements RequestHandlerInterface { 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); $block->saveBlockConfiguration($request, $block_id); return redirect(route(TreePage::class, ['tree' => $tree->name()])); } }