|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
|
5
|
|
|
* |
|
6
|
|
|
* @package MyArtJaub\Webtrees |
|
7
|
|
|
* @subpackage GeoDispersion |
|
8
|
|
|
* @author Jonathan Jaubart <[email protected]> |
|
9
|
|
|
* @copyright Copyright (c) 2009-2021, 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\GeoDispersion\Http\RequestHandlers; |
|
16
|
|
|
|
|
17
|
|
|
use Fisharebest\Webtrees\I18N; |
|
18
|
|
|
use Fisharebest\Webtrees\Tree; |
|
19
|
|
|
use Fisharebest\Webtrees\Exceptions\HttpNotFoundException; |
|
20
|
|
|
use Fisharebest\Webtrees\Http\ViewResponseTrait; |
|
21
|
|
|
use Fisharebest\Webtrees\Services\ModuleService; |
|
22
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\GeoDispersionModule; |
|
23
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Services\GeoAnalysisDataService; |
|
24
|
|
|
use MyArtJaub\Webtrees\Module\GeoDispersion\Services\GeoAnalysisService; |
|
25
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
26
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
27
|
|
|
use Psr\Http\Server\RequestHandlerInterface; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Request handler for display configuration for a new geographical analysis view. |
|
31
|
|
|
*/ |
|
32
|
|
|
class GeoAnalysisViewAddPage implements RequestHandlerInterface |
|
33
|
|
|
{ |
|
34
|
|
|
use ViewResponseTrait; |
|
35
|
|
|
|
|
36
|
|
|
private ?GeoDispersionModule $module; |
|
37
|
|
|
private GeoAnalysisService $geoanalysis_service; |
|
38
|
|
|
private GeoAnalysisDataService $geoanalysis_data_service; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Constructor for GeoAnalysisViewAddPage Request Handler |
|
42
|
|
|
* |
|
43
|
|
|
* @param ModuleService $module_service |
|
44
|
|
|
* @param GeoAnalysisService $geoanalysis_service |
|
45
|
|
|
* @param GeoAnalysisDataService $geoanalysis_data_service |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct( |
|
48
|
|
|
ModuleService $module_service, |
|
49
|
|
|
GeoAnalysisService $geoanalysis_service, |
|
50
|
|
|
GeoAnalysisDataService $geoanalysis_data_service |
|
51
|
|
|
) { |
|
52
|
|
|
$this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
53
|
|
|
$this->geoanalysis_service = $geoanalysis_service; |
|
54
|
|
|
$this->geoanalysis_data_service = $geoanalysis_data_service; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* {@inheritDoc} |
|
59
|
|
|
* @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
60
|
|
|
*/ |
|
61
|
|
|
public function handle(ServerRequestInterface $request): ResponseInterface |
|
62
|
|
|
{ |
|
63
|
|
|
$this->layout = 'layouts/administration'; |
|
64
|
|
|
|
|
65
|
|
|
if ($this->module === null) { |
|
66
|
|
|
throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
67
|
|
|
} |
|
68
|
|
|
$tree = $request->getAttribute('tree'); |
|
69
|
|
|
assert($tree instanceof Tree); |
|
70
|
|
|
|
|
71
|
|
|
return $this->viewResponse($this->module->name() . '::admin/view-add', [ |
|
72
|
|
|
'module' => $this->module, |
|
73
|
|
|
'title' => I18N::translate('Add a geographical dispersion analysis view'), |
|
74
|
|
|
'tree' => $tree, |
|
75
|
|
|
'geoanalysis_list' => $this->geoanalysis_service->all(), |
|
76
|
|
|
'place_example' => $this->geoanalysis_data_service->placeHierarchyExample($tree) |
|
77
|
|
|
]); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|