xref: /webtrees/app/Http/RequestHandlers/FaviconIco.php (revision d11be7027e34e3121be11cc025421873364403f9)
146431a62SGreg Roach<?php
246431a62SGreg Roach
346431a62SGreg Roach/**
446431a62SGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 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
1589f7189bSGreg Roach * along with this program. If not, see <https://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)
446172e7f6SGreg Roach            ->withHeader('content-type', 'image/x-icon')
456172e7f6SGreg Roach            ->withHeader('cache-control', 'public,max-age=31536000');
4646431a62SGreg Roach    }
4746431a62SGreg Roach}
48