xref: /webtrees/app/Http/RequestHandlers/FaviconIco.php (revision dfd7362b5e90e1073a8eeb1484576d68147f2457)
146431a62SGreg Roach<?php
246431a62SGreg Roach
346431a62SGreg Roach/**
446431a62SGreg Roach * webtrees: online genealogy
555134edcSGreg Roach * Copyright (C) 2020 webtrees development team
646431a62SGreg Roach * This program is free software: you can redistribute it and/or modify
746431a62SGreg Roach * it under the terms of the GNU General Public License as published by
846431a62SGreg Roach * the Free Software Foundation, either version 3 of the License, or
946431a62SGreg Roach * (at your option) any later version.
1046431a62SGreg Roach * This program is distributed in the hope that it will be useful,
1146431a62SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1246431a62SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1346431a62SGreg Roach * GNU General Public License for more details.
1446431a62SGreg Roach * You should have received a copy of the GNU General Public License
1546431a62SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
1646431a62SGreg Roach */
1746431a62SGreg Roach
1846431a62SGreg Roachdeclare(strict_types=1);
1946431a62SGreg Roach
2046431a62SGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers;
2146431a62SGreg Roach
2246431a62SGreg Roachuse Psr\Http\Message\ResponseInterface;
2346431a62SGreg Roachuse Psr\Http\Message\ServerRequestInterface;
2446431a62SGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
2546431a62SGreg Roach
2646431a62SGreg Roachuse function file_get_contents;
2746431a62SGreg Roachuse function response;
2846431a62SGreg Roach
2946431a62SGreg Roach/**
3046431a62SGreg Roach * Respond to /favicon.ico.
3146431a62SGreg Roach */
3246431a62SGreg Roachclass FaviconIco implements RequestHandlerInterface
3346431a62SGreg Roach{
3446431a62SGreg Roach    /**
3546431a62SGreg Roach     * @param ServerRequestInterface $request
3646431a62SGreg Roach     *
3746431a62SGreg Roach     * @return ResponseInterface
3846431a62SGreg Roach     */
3946431a62SGreg Roach    public function handle(ServerRequestInterface $request): ResponseInterface
4046431a62SGreg Roach    {
4146431a62SGreg Roach        $content = file_get_contents(__DIR__ . '/../../../favicon.ico');
4246431a62SGreg Roach
4346431a62SGreg Roach        return response($content)
4446431a62SGreg Roach            ->withHeader('Content-Type', 'image/x-icon')
45*dfd7362bSGreg Roach            ->withHeader('Cache-Control', 'public,max-age=31536000');
4646431a62SGreg Roach    }
4746431a62SGreg Roach}
48