1*208909d8SGreg Roach<?php 2*208909d8SGreg Roach 3*208909d8SGreg Roach/** 4*208909d8SGreg Roach * webtrees: online genealogy 5*208909d8SGreg Roach * Copyright (C) 2022 webtrees development team 6*208909d8SGreg Roach * This program is free software: you can redistribute it and/or modify 7*208909d8SGreg Roach * it under the terms of the GNU General Public License as published by 8*208909d8SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9*208909d8SGreg Roach * (at your option) any later version. 10*208909d8SGreg Roach * This program is distributed in the hope that it will be useful, 11*208909d8SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12*208909d8SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13*208909d8SGreg Roach * GNU General Public License for more details. 14*208909d8SGreg Roach * You should have received a copy of the GNU General Public License 15*208909d8SGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16*208909d8SGreg Roach */ 17*208909d8SGreg Roach 18*208909d8SGreg Roachdeclare(strict_types=1); 19*208909d8SGreg Roach 20*208909d8SGreg Roachnamespace Fisharebest\Webtrees\Contracts; 21*208909d8SGreg Roach 22*208909d8SGreg Roachuse Fig\Http\Message\StatusCodeInterface; 23*208909d8SGreg Roachuse Fisharebest\Webtrees\Webtrees; 24*208909d8SGreg Roachuse Psr\Http\Message\ResponseInterface; 25*208909d8SGreg Roachuse Psr\Http\Message\UriInterface; 26*208909d8SGreg Roach 27*208909d8SGreg Roach/** 28*208909d8SGreg Roach * ake a PSR-7 response (using a PSR-17 response factory). 29*208909d8SGreg Roach */ 30*208909d8SGreg Roachinterface ResponseFactoryInterface 31*208909d8SGreg Roach{ 32*208909d8SGreg Roach /** 33*208909d8SGreg Roach * Redirect to a named route. 34*208909d8SGreg Roach * 35*208909d8SGreg Roach * @param string $route_name 36*208909d8SGreg Roach * @param array<bool|int|string|array<string>|null> $parameters 37*208909d8SGreg Roach * @param int $status 38*208909d8SGreg Roach * 39*208909d8SGreg Roach * @return ResponseInterface 40*208909d8SGreg Roach * 41*208909d8SGreg Roach */ 42*208909d8SGreg Roach public function redirect( 43*208909d8SGreg Roach string $route_name, 44*208909d8SGreg Roach array $parameters = [], 45*208909d8SGreg Roach int $status = StatusCodeInterface::STATUS_FOUND 46*208909d8SGreg Roach ): ResponseInterface; 47*208909d8SGreg Roach 48*208909d8SGreg Roach /** 49*208909d8SGreg Roach * Redirect to a URL. 50*208909d8SGreg Roach * 51*208909d8SGreg Roach * @param string|UriInterface $url 52*208909d8SGreg Roach * @param int $code 53*208909d8SGreg Roach * 54*208909d8SGreg Roach * @return ResponseInterface 55*208909d8SGreg Roach */ 56*208909d8SGreg Roach public function redirectUrl($url, int $code = StatusCodeInterface::STATUS_FOUND): ResponseInterface; 57*208909d8SGreg Roach 58*208909d8SGreg Roach /** 59*208909d8SGreg Roach * @param string|array<mixed>|object $content 60*208909d8SGreg Roach * @param int $code 61*208909d8SGreg Roach * @param array<string,string> $headers 62*208909d8SGreg Roach * 63*208909d8SGreg Roach * @return ResponseInterface 64*208909d8SGreg Roach */ 65*208909d8SGreg Roach public function response($content = '', int $code = StatusCodeInterface::STATUS_OK, array $headers = []): ResponseInterface; 66*208909d8SGreg Roach 67*208909d8SGreg Roach /** 68*208909d8SGreg Roach * Create and render a view, and embed it in an HTML page. 69*208909d8SGreg Roach * 70*208909d8SGreg Roach * @param string $view_name 71*208909d8SGreg Roach * @param array<mixed> $view_data 72*208909d8SGreg Roach * @param int $status 73*208909d8SGreg Roach * @param string $layout_name 74*208909d8SGreg Roach * 75*208909d8SGreg Roach * @return ResponseInterface 76*208909d8SGreg Roach */ 77*208909d8SGreg Roach public function view( 78*208909d8SGreg Roach string $view_name, 79*208909d8SGreg Roach array $view_data, 80*208909d8SGreg Roach int $status = StatusCodeInterface::STATUS_OK, 81*208909d8SGreg Roach string $layout_name = Webtrees::LAYOUT_DEFAULT 82*208909d8SGreg Roach ): ResponseInterface; 83*208909d8SGreg Roach} 84