1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
5
|
|
|
* |
6
|
|
|
* @package MyArtJaub\Webtrees |
7
|
|
|
* @subpackage Sosa |
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\Sosa\Http\RequestHandlers; |
16
|
|
|
|
17
|
|
|
use Fisharebest\Webtrees\I18N; |
18
|
|
|
use Fisharebest\Webtrees\Registry; |
19
|
|
|
use Fisharebest\Webtrees\Validator; |
20
|
|
|
use Fisharebest\Webtrees\Services\ModuleService; |
21
|
|
|
use MyArtJaub\Webtrees\Module\Sosa\SosaModule; |
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 the modal window for computing Sosa ancestors |
28
|
|
|
*/ |
29
|
|
|
class SosaComputeModal implements RequestHandlerInterface |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @var SosaModule|null $module |
33
|
|
|
*/ |
34
|
|
|
private $module; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Constructor for SosaComputeModal Request Handler |
38
|
|
|
* |
39
|
|
|
* @param ModuleService $module_service |
40
|
|
|
*/ |
41
|
|
|
public function __construct(ModuleService $module_service) |
42
|
|
|
{ |
43
|
|
|
$this->module = $module_service->findByInterface(SosaModule::class)->first(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritDoc} |
48
|
|
|
* @see \Psr\Http\Server\RequestHandlerInterface::handle() |
49
|
|
|
*/ |
50
|
|
|
public function handle(ServerRequestInterface $request): ResponseInterface |
51
|
|
|
{ |
52
|
|
|
if ($this->module === null) { |
53
|
|
|
return Registry::responseFactory()->response(view('modals/error', [ |
54
|
|
|
'title' => I18N::translate('Error'), |
55
|
|
|
'error' => I18N::translate('The attached module could not be found.') |
56
|
|
|
])); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$tree = Validator::attributes($request)->tree(); |
60
|
|
|
|
61
|
|
|
return Registry::responseFactory()->response(view($this->module->name() . '::modals/sosa-compute', [ |
62
|
|
|
'tree' => $tree, |
63
|
|
|
'xref' => Validator::attributes($request)->isXref()->string('xref', '') |
64
|
|
|
])); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|