. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Http\RequestHandlers; use Fig\Http\Message\StatusCodeInterface; use Fisharebest\Webtrees\Contracts\UserInterface; use Fisharebest\Webtrees\Session; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function response; /** * Select a new theme for the current session. */ class SelectTheme implements RequestHandlerInterface, StatusCodeInterface { /** @var UserInterface */ private $user; /** * @param UserInterface $user */ public function __construct(UserInterface $user) { $this->user = $user; } /** * @param ServerRequestInterface $request * * @return ResponseInterface */ public function handle(ServerRequestInterface $request): ResponseInterface { $theme = $request->getParsedBody()['theme']; Session::put('theme', $theme); $this->user->setPreference('theme', $theme); return response('', self::STATUS_NO_CONTENT); } }