|
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-2020, 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 Fig\Http\Message\StatusCodeInterface; |
|
18
|
|
|
use Fisharebest\Webtrees\I18N; |
|
19
|
|
|
use Fisharebest\Webtrees\Tree; |
|
20
|
|
|
use Fisharebest\Webtrees\Services\ModuleService; |
|
21
|
|
|
use Fisharebest\Webtrees\Services\UserService; |
|
22
|
|
|
use MyArtJaub\Webtrees\Module\Sosa\SosaModule; |
|
23
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
24
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
25
|
|
|
use Psr\Http\Server\RequestHandlerInterface; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Request handler for displaying the modal window for computing Sosa ancestors |
|
29
|
|
|
*/ |
|
30
|
|
|
class SosaComputeModal implements RequestHandlerInterface |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @var SosaModule $module |
|
34
|
|
|
*/ |
|
35
|
|
|
private $module; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Constructor for SosaComputeModal Request Handler |
|
39
|
|
|
* |
|
40
|
|
|
* @param ModuleService $module_service |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct(ModuleService $module_service) |
|
43
|
|
|
{ |
|
44
|
|
|
$this->module = $module_service->findByInterface(SosaModule::class)->first(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* {@inheritDoc} |
|
49
|
|
|
* @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
50
|
|
|
*/ |
|
51
|
|
|
public function handle(ServerRequestInterface $request): ResponseInterface |
|
52
|
|
|
{ |
|
53
|
|
|
if ($this->module === null) { |
|
54
|
|
|
return response( |
|
55
|
|
|
I18N::translate('The attached module could not be found.'), |
|
56
|
|
|
StatusCodeInterface::STATUS_NOT_FOUND |
|
57
|
|
|
); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
$tree = $request->getAttribute('tree'); |
|
61
|
|
|
assert($tree instanceof Tree); |
|
62
|
|
|
|
|
63
|
|
|
return response(view($this->module->name() . '::modals/sosa-compute', [ |
|
64
|
|
|
'tree' => $tree, |
|
65
|
|
|
'xref' => $request->getAttribute('xref') |
|
66
|
|
|
])); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|