. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Header; use Fisharebest\Webtrees\Http\ViewResponseTrait; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Location; use Fisharebest\Webtrees\Media; use Fisharebest\Webtrees\Note; use Fisharebest\Webtrees\Registry; use Fisharebest\Webtrees\Repository; use Fisharebest\Webtrees\Source; use Fisharebest\Webtrees\Submission; use Fisharebest\Webtrees\Submitter; use Fisharebest\Webtrees\Validator; use Illuminate\Support\Collection; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function redirect; /** * Display non-standard genealogy records. */ class GedcomRecordPage implements RequestHandlerInterface { use ViewResponseTrait; // These standard genealogy record types have their own pages. private const STANDARD_RECORDS = [ Family::class, Header::class, Individual::class, Location::class, Media::class, Note::class, Repository::class, Source::class, Submission::class, Submitter::class, ]; /** * Show a gedcom record's page. * * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $tree = Validator::attributes($request)->tree(); $xref = Validator::attributes($request)->isXref()->string('xref'); $record = Registry::gedcomRecordFactory()->make($xref, $tree); $record = Auth::checkRecordAccess($record); // Standard genealogy records have their own pages. if ($record->xref() !== $xref || in_array(get_class($record), self::STANDARD_RECORDS, true)) { return redirect($record->url()); } return $this->viewResponse('record-page', [ 'clipboard_facts' => new Collection(), 'linked_families' => $record->linkedFamilies($record->tag()), 'linked_individuals' => $record->linkedIndividuals($record->tag()), 'linked_media_objects' => $record->linkedMedia($record->tag()), 'linked_notes' => $record->linkedNotes($record->tag()), 'linked_sources' => $record->linkedSources($record->tag()), 'record' => $record, 'title' => $record->fullName(), 'tree' => $tree, ]); } }