xref: /webtrees/app/Http/Middleware/BootModules.php (revision 89f7189b61a494347591c99bdb92afb7d8b66e1b)
10cfd6963SGreg Roach<?php
23976b470SGreg Roach
30cfd6963SGreg Roach/**
40cfd6963SGreg Roach * webtrees: online genealogy
5*89f7189bSGreg Roach * Copyright (C) 2021 webtrees development team
60cfd6963SGreg Roach * This program is free software: you can redistribute it and/or modify
70cfd6963SGreg Roach * it under the terms of the GNU General Public License as published by
80cfd6963SGreg Roach * the Free Software Foundation, either version 3 of the License, or
90cfd6963SGreg Roach * (at your option) any later version.
100cfd6963SGreg Roach * This program is distributed in the hope that it will be useful,
110cfd6963SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
120cfd6963SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
130cfd6963SGreg Roach * GNU General Public License for more details.
140cfd6963SGreg Roach * You should have received a copy of the GNU General Public License
15*89f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
160cfd6963SGreg Roach */
17fcfa147eSGreg Roach
180cfd6963SGreg Roachdeclare(strict_types=1);
190cfd6963SGreg Roach
200cfd6963SGreg Roachnamespace Fisharebest\Webtrees\Http\Middleware;
210cfd6963SGreg Roach
220cfd6963SGreg Roachuse Fisharebest\Webtrees\Module\ModuleThemeInterface;
230cfd6963SGreg Roachuse Fisharebest\Webtrees\Services\ModuleService;
246ccdf4f0SGreg Roachuse Psr\Http\Message\ResponseInterface;
256ccdf4f0SGreg Roachuse Psr\Http\Message\ServerRequestInterface;
266ccdf4f0SGreg Roachuse Psr\Http\Server\MiddlewareInterface;
276ccdf4f0SGreg Roachuse Psr\Http\Server\RequestHandlerInterface;
2871378461SGreg Roach
290cfd6963SGreg Roach/**
300cfd6963SGreg Roach * Middleware to bootstrap the modules.
310cfd6963SGreg Roach */
320cfd6963SGreg Roachclass BootModules implements MiddlewareInterface
330cfd6963SGreg Roach{
348fb0f35eSGreg Roach    /** @var ModuleService */
358fb0f35eSGreg Roach    private $module_service;
368fb0f35eSGreg Roach
378fb0f35eSGreg Roach    /** @var ModuleThemeInterface */
388fb0f35eSGreg Roach    private $theme;
398fb0f35eSGreg Roach
408fb0f35eSGreg Roach    /**
418fb0f35eSGreg Roach     * BootModules constructor.
428fb0f35eSGreg Roach     *
438fb0f35eSGreg Roach     * @param ModuleService        $module_service
448fb0f35eSGreg Roach     * @param ModuleThemeInterface $theme
458fb0f35eSGreg Roach     */
468fb0f35eSGreg Roach    public function __construct(ModuleService $module_service, ModuleThemeInterface $theme)
478fb0f35eSGreg Roach    {
488fb0f35eSGreg Roach        $this->module_service = $module_service;
498fb0f35eSGreg Roach        $this->theme          = $theme;
508fb0f35eSGreg Roach    }
518fb0f35eSGreg Roach
520cfd6963SGreg Roach    /**
536ccdf4f0SGreg Roach     * @param ServerRequestInterface  $request
546ccdf4f0SGreg Roach     * @param RequestHandlerInterface $handler
550cfd6963SGreg Roach     *
566ccdf4f0SGreg Roach     * @return ResponseInterface
570cfd6963SGreg Roach     */
586ccdf4f0SGreg Roach    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
590cfd6963SGreg Roach    {
6071378461SGreg Roach        $this->module_service->bootModules($this->theme);
610cfd6963SGreg Roach
626ccdf4f0SGreg Roach        return $handler->handle($request);
630cfd6963SGreg Roach    }
640cfd6963SGreg Roach}
65