. */ 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\Tree; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function assert; use function e; /** * Find potential duplicate records in a tree. */ class FindDuplicateRecords 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 = $request->getAttribute('tree'); assert($tree instanceof Tree); $duplicates = $this->admin_service->duplicateRecords($tree); $title = I18N::translate('Find duplicates') . ' — ' . e($tree->title()); return $this->viewResponse('admin/trees-duplicates', [ 'duplicates' => $duplicates, 'title' => $title, 'tree' => $tree, ]); } }