. */ 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\Services\TreeService; use Fisharebest\Webtrees\Tree; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function assert; use function e; /** * Renumber the XREFs in a family tree. */ class RenumberTreePage implements RequestHandlerInterface { use ViewResponseTrait; /** @var AdminService */ private $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 = $request->getAttribute('tree'); assert($tree instanceof Tree); $xrefs = $this->admin_service->duplicateXrefs($tree); /* I18N: Renumber the records in a family tree */ $title = I18N::translate('Renumber family tree') . ' — ' . e($tree->title()); return $this->viewResponse('admin/trees-renumber', [ 'title' => $title, 'tree' => $tree, 'xrefs' => $xrefs, ]); } }