|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
|
5
|
|
|
* |
|
6
|
|
|
* @package MyArtJaub\Webtrees |
|
7
|
|
|
* @subpackage MiscExtensions |
|
8
|
|
|
* @author Jonathan Jaubart <[email protected]> |
|
9
|
|
|
* @copyright Copyright (c) 2009-2022, Jonathan Jaubart |
|
10
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
declare(strict_types=1); |
|
14
|
|
|
|
|
15
|
|
|
namespace MyArtJaub\Webtrees\Module\MiscExtensions\Http\RequestHandlers; |
|
16
|
|
|
|
|
17
|
|
|
use Fisharebest\Webtrees\I18N; |
|
18
|
|
|
use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException; |
|
19
|
|
|
use Fisharebest\Webtrees\Http\ViewResponseTrait; |
|
20
|
|
|
use Fisharebest\Webtrees\Services\ModuleService; |
|
21
|
|
|
use MyArtJaub\Webtrees\Module\MiscExtensions\MiscExtensionsModule; |
|
22
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
23
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
24
|
|
|
use Psr\Http\Server\RequestHandlerInterface; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Request handler for displaying configuration of the module |
|
28
|
|
|
*/ |
|
29
|
|
|
class AdminConfigPage implements RequestHandlerInterface |
|
30
|
|
|
{ |
|
31
|
|
|
use ViewResponseTrait; |
|
32
|
|
|
|
|
33
|
|
|
private ?MiscExtensionsModule $module; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Constructor for AdminConfigPage Request Handler |
|
37
|
|
|
* |
|
38
|
|
|
* @param ModuleService $module_service |
|
39
|
|
|
*/ |
|
40
|
|
|
public function __construct(ModuleService $module_service) |
|
41
|
|
|
{ |
|
42
|
|
|
$this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* {@inheritDoc} |
|
47
|
|
|
* @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
48
|
|
|
*/ |
|
49
|
|
|
public function handle(ServerRequestInterface $request): ResponseInterface |
|
50
|
|
|
{ |
|
51
|
|
|
$this->layout = 'layouts/administration'; |
|
52
|
|
|
|
|
53
|
|
|
if ($this->module === null) { |
|
54
|
|
|
throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
58
|
|
|
'module' => $this->module, |
|
59
|
|
|
'title' => $this->module->title() |
|
60
|
|
|
]); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|