10cfd6963SGreg Roach<?php 23976b470SGreg Roach 30cfd6963SGreg Roach/** 40cfd6963SGreg Roach * webtrees: online genealogy 5*d11be702SGreg Roach * Copyright (C) 2023 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 1589f7189bSGreg 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{ 34c4943cffSGreg Roach private ModuleService $module_service; 358fb0f35eSGreg Roach 36c4943cffSGreg Roach private ModuleThemeInterface $theme; 378fb0f35eSGreg Roach 388fb0f35eSGreg Roach /** 398fb0f35eSGreg Roach * @param ModuleService $module_service 408fb0f35eSGreg Roach * @param ModuleThemeInterface $theme 418fb0f35eSGreg Roach */ 428fb0f35eSGreg Roach public function __construct(ModuleService $module_service, ModuleThemeInterface $theme) 438fb0f35eSGreg Roach { 448fb0f35eSGreg Roach $this->module_service = $module_service; 458fb0f35eSGreg Roach $this->theme = $theme; 468fb0f35eSGreg Roach } 478fb0f35eSGreg Roach 480cfd6963SGreg Roach /** 496ccdf4f0SGreg Roach * @param ServerRequestInterface $request 506ccdf4f0SGreg Roach * @param RequestHandlerInterface $handler 510cfd6963SGreg Roach * 526ccdf4f0SGreg Roach * @return ResponseInterface 530cfd6963SGreg Roach */ 546ccdf4f0SGreg Roach public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface 550cfd6963SGreg Roach { 5671378461SGreg Roach $this->module_service->bootModules($this->theme); 570cfd6963SGreg Roach 586ccdf4f0SGreg Roach return $handler->handle($request); 590cfd6963SGreg Roach } 600cfd6963SGreg Roach} 61