. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Http\ViewResponseTrait; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Services\AdminService; use Fisharebest\Webtrees\Validator; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function e; /** * Renumber the XREFs in a family tree. */ class RenumberTreePage implements RequestHandlerInterface { use ViewResponseTrait; private AdminService $admin_service; /** * @param AdminService $admin_service */ public function __construct(AdminService $admin_service) { $this->admin_service = $admin_service; } /** * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $this->layout = 'layouts/administration'; $tree = Validator::attributes($request)->tree(); $xrefs = $this->admin_service->duplicateXrefs($tree); /* I18N: Renumber the records in a family tree */ $title = I18N::translate('Renumber XREFs') . ' — ' . e($tree->title()); return $this->viewResponse('admin/trees-renumber', [ 'title' => $title, 'tree' => $tree, 'xrefs' => $xrefs, ]); } }