. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\GedcomRecord; use Fisharebest\Webtrees\GedcomTag; use Fisharebest\Webtrees\Http\ViewResponseTrait; use Fisharebest\Webtrees\Tree; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function assert; /** * Add a new fact. */ class AddNewFact implements RequestHandlerInterface { use ViewResponseTrait; /** * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $tree = $request->getAttribute('tree'); assert($tree instanceof Tree); $xref = $request->getAttribute('xref'); $fact = $request->getAttribute('fact'); $record = GedcomRecord::getInstance($xref, $tree); Auth::checkRecordAccess($record, true); $title = $record->fullName() . ' - ' . GedcomTag::getLabel($fact, $record); return $this->viewResponse('edit/add-fact', [ 'fact' => $fact, 'record' => $record, 'title' => $title, 'tree' => $tree, ]); } }