@@ -31,49 +31,49 @@ |
||
31 | 31 | */ |
32 | 32 | class GeoAnalysisViewAddPage implements RequestHandlerInterface |
33 | 33 | { |
34 | - use ViewResponseTrait; |
|
34 | + use ViewResponseTrait; |
|
35 | 35 | |
36 | - private ?GeoDispersionModule $module; |
|
37 | - private GeoAnalysisService $geoanalysis_service; |
|
38 | - private GeoAnalysisDataService $geoanalysis_data_service; |
|
36 | + private ?GeoDispersionModule $module; |
|
37 | + private GeoAnalysisService $geoanalysis_service; |
|
38 | + private GeoAnalysisDataService $geoanalysis_data_service; |
|
39 | 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 | - } |
|
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 | 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'; |
|
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 | 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); |
|
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 | 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 | - } |
|
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 | 79 | } |
@@ -34,89 +34,89 @@ |
||
34 | 34 | */ |
35 | 35 | class GeoAnalysisViewAddAction implements RequestHandlerInterface |
36 | 36 | { |
37 | - private ?GeoDispersionModule $module; |
|
38 | - private GeoAnalysisViewDataService $geoview_data_service; |
|
39 | - |
|
40 | - /** |
|
41 | - * Constructor for GeoAnalysisViewAddAction Request Handler |
|
42 | - * |
|
43 | - * @param ModuleService $module_service |
|
44 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
45 | - */ |
|
46 | - public function __construct(ModuleService $module_service, GeoAnalysisViewDataService $geoview_data_service) |
|
47 | - { |
|
48 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
49 | - $this->geoview_data_service = $geoview_data_service; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * {@inheritDoc} |
|
54 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
55 | - */ |
|
56 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
57 | - { |
|
58 | - $tree = $request->getAttribute('tree'); |
|
59 | - assert($tree instanceof Tree); |
|
60 | - |
|
61 | - $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
62 | - |
|
63 | - if ($this->module === null) { |
|
64 | - FlashMessages::addMessage( |
|
65 | - I18N::translate('The attached module could not be found.'), |
|
66 | - 'danger' |
|
67 | - ); |
|
68 | - return redirect($admin_config_route); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - $params = (array) $request->getParsedBody(); |
|
73 | - |
|
74 | - $type = $params['view_type'] ?? ''; |
|
75 | - $description = $params['view_description'] ?? ''; |
|
76 | - $place_depth = (int) ($params['view_depth'] ?? 1); |
|
77 | - |
|
78 | - $analysis = null; |
|
79 | - try { |
|
80 | - $analysis = app($params['view_analysis'] ?? ''); |
|
81 | - } catch (BindingResolutionException $ex) { |
|
82 | - } |
|
83 | - |
|
84 | - if ( |
|
85 | - !in_array($type, ['table', 'map'], true) || $place_depth <= 0 |
|
86 | - || $analysis === null || !($analysis instanceof GeoAnalysisInterface) |
|
87 | - ) { |
|
88 | - FlashMessages::addMessage( |
|
89 | - I18N::translate('The parameters for the new view are not valid.'), |
|
90 | - 'danger' |
|
91 | - ); |
|
92 | - return redirect($admin_config_route); |
|
93 | - } |
|
94 | - |
|
95 | - if ($type === 'map') { |
|
96 | - $new_view = new GeoAnalysisMap(0, $tree, true, $description, $analysis, $place_depth); |
|
97 | - } else { |
|
98 | - $new_view = new GeoAnalysisTable(0, $tree, true, $description, $analysis, $place_depth); |
|
99 | - } |
|
100 | - |
|
101 | - $new_view_id = $this->geoview_data_service->insertGetId($new_view); |
|
102 | - if ($new_view_id > 0) { |
|
103 | - FlashMessages::addMessage( |
|
104 | - I18N::translate('The geographical dispersion analysis view has been successfully added.'), |
|
105 | - 'success' |
|
106 | - ); |
|
107 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
108 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : View “' . $new_view_id . '” has been added.'); |
|
109 | - return redirect( |
|
110 | - route(GeoAnalysisViewEditPage::class, ['tree' => $tree->name(), 'view_id' => $new_view_id ]) |
|
111 | - ); |
|
112 | - } else { |
|
113 | - FlashMessages::addMessage( |
|
114 | - I18N::translate('An error occured while adding the geographical dispersion analysis view.'), |
|
115 | - 'danger' |
|
116 | - ); |
|
117 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
118 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : A new View could not be added. See error log.'); |
|
119 | - return redirect($admin_config_route); |
|
120 | - } |
|
121 | - } |
|
37 | + private ?GeoDispersionModule $module; |
|
38 | + private GeoAnalysisViewDataService $geoview_data_service; |
|
39 | + |
|
40 | + /** |
|
41 | + * Constructor for GeoAnalysisViewAddAction Request Handler |
|
42 | + * |
|
43 | + * @param ModuleService $module_service |
|
44 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
45 | + */ |
|
46 | + public function __construct(ModuleService $module_service, GeoAnalysisViewDataService $geoview_data_service) |
|
47 | + { |
|
48 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
49 | + $this->geoview_data_service = $geoview_data_service; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * {@inheritDoc} |
|
54 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
55 | + */ |
|
56 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
57 | + { |
|
58 | + $tree = $request->getAttribute('tree'); |
|
59 | + assert($tree instanceof Tree); |
|
60 | + |
|
61 | + $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
62 | + |
|
63 | + if ($this->module === null) { |
|
64 | + FlashMessages::addMessage( |
|
65 | + I18N::translate('The attached module could not be found.'), |
|
66 | + 'danger' |
|
67 | + ); |
|
68 | + return redirect($admin_config_route); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + $params = (array) $request->getParsedBody(); |
|
73 | + |
|
74 | + $type = $params['view_type'] ?? ''; |
|
75 | + $description = $params['view_description'] ?? ''; |
|
76 | + $place_depth = (int) ($params['view_depth'] ?? 1); |
|
77 | + |
|
78 | + $analysis = null; |
|
79 | + try { |
|
80 | + $analysis = app($params['view_analysis'] ?? ''); |
|
81 | + } catch (BindingResolutionException $ex) { |
|
82 | + } |
|
83 | + |
|
84 | + if ( |
|
85 | + !in_array($type, ['table', 'map'], true) || $place_depth <= 0 |
|
86 | + || $analysis === null || !($analysis instanceof GeoAnalysisInterface) |
|
87 | + ) { |
|
88 | + FlashMessages::addMessage( |
|
89 | + I18N::translate('The parameters for the new view are not valid.'), |
|
90 | + 'danger' |
|
91 | + ); |
|
92 | + return redirect($admin_config_route); |
|
93 | + } |
|
94 | + |
|
95 | + if ($type === 'map') { |
|
96 | + $new_view = new GeoAnalysisMap(0, $tree, true, $description, $analysis, $place_depth); |
|
97 | + } else { |
|
98 | + $new_view = new GeoAnalysisTable(0, $tree, true, $description, $analysis, $place_depth); |
|
99 | + } |
|
100 | + |
|
101 | + $new_view_id = $this->geoview_data_service->insertGetId($new_view); |
|
102 | + if ($new_view_id > 0) { |
|
103 | + FlashMessages::addMessage( |
|
104 | + I18N::translate('The geographical dispersion analysis view has been successfully added.'), |
|
105 | + 'success' |
|
106 | + ); |
|
107 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
108 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : View “' . $new_view_id . '” has been added.'); |
|
109 | + return redirect( |
|
110 | + route(GeoAnalysisViewEditPage::class, ['tree' => $tree->name(), 'view_id' => $new_view_id ]) |
|
111 | + ); |
|
112 | + } else { |
|
113 | + FlashMessages::addMessage( |
|
114 | + I18N::translate('An error occured while adding the geographical dispersion analysis view.'), |
|
115 | + 'danger' |
|
116 | + ); |
|
117 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
118 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : A new View could not be added. See error log.'); |
|
119 | + return redirect($admin_config_route); |
|
120 | + } |
|
121 | + } |
|
122 | 122 | } |
@@ -32,68 +32,68 @@ |
||
32 | 32 | */ |
33 | 33 | class MapAdapterEditPage implements RequestHandlerInterface |
34 | 34 | { |
35 | - use ViewResponseTrait; |
|
35 | + use ViewResponseTrait; |
|
36 | 36 | |
37 | - private ?GeoDispersionModule $module; |
|
38 | - private MapAdapterDataService $mapadapter_data_service; |
|
39 | - private MapDefinitionsService $map_definition_service; |
|
40 | - private PlaceMapperService $place_mapper_service; |
|
37 | + private ?GeoDispersionModule $module; |
|
38 | + private MapAdapterDataService $mapadapter_data_service; |
|
39 | + private MapDefinitionsService $map_definition_service; |
|
40 | + private PlaceMapperService $place_mapper_service; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Constructor for MapAdapterEditPage Request Handler |
|
44 | - * |
|
45 | - * @param ModuleService $module_service |
|
46 | - * @param MapAdapterDataService $mapadapter_data_service |
|
47 | - * @param MapDefinitionsService $map_definition_service |
|
48 | - * @param PlaceMapperService $place_mapper_service |
|
49 | - */ |
|
50 | - public function __construct( |
|
51 | - ModuleService $module_service, |
|
52 | - MapAdapterDataService $mapadapter_data_service, |
|
53 | - MapDefinitionsService $map_definition_service, |
|
54 | - PlaceMapperService $place_mapper_service |
|
55 | - ) { |
|
56 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
57 | - $this->mapadapter_data_service = $mapadapter_data_service; |
|
58 | - $this->map_definition_service = $map_definition_service; |
|
59 | - $this->place_mapper_service = $place_mapper_service; |
|
60 | - } |
|
42 | + /** |
|
43 | + * Constructor for MapAdapterEditPage Request Handler |
|
44 | + * |
|
45 | + * @param ModuleService $module_service |
|
46 | + * @param MapAdapterDataService $mapadapter_data_service |
|
47 | + * @param MapDefinitionsService $map_definition_service |
|
48 | + * @param PlaceMapperService $place_mapper_service |
|
49 | + */ |
|
50 | + public function __construct( |
|
51 | + ModuleService $module_service, |
|
52 | + MapAdapterDataService $mapadapter_data_service, |
|
53 | + MapDefinitionsService $map_definition_service, |
|
54 | + PlaceMapperService $place_mapper_service |
|
55 | + ) { |
|
56 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
57 | + $this->mapadapter_data_service = $mapadapter_data_service; |
|
58 | + $this->map_definition_service = $map_definition_service; |
|
59 | + $this->place_mapper_service = $place_mapper_service; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * {@inheritDoc} |
|
64 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
65 | - */ |
|
66 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
67 | - { |
|
68 | - $this->layout = 'layouts/administration'; |
|
62 | + /** |
|
63 | + * {@inheritDoc} |
|
64 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
65 | + */ |
|
66 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
67 | + { |
|
68 | + $this->layout = 'layouts/administration'; |
|
69 | 69 | |
70 | - if ($this->module === null) { |
|
71 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
72 | - } |
|
73 | - $tree = $request->getAttribute('tree'); |
|
74 | - assert($tree instanceof Tree); |
|
70 | + if ($this->module === null) { |
|
71 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
72 | + } |
|
73 | + $tree = $request->getAttribute('tree'); |
|
74 | + assert($tree instanceof Tree); |
|
75 | 75 | |
76 | - $adapter_id = (int) $request->getAttribute('adapter_id'); |
|
77 | - $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
76 | + $adapter_id = (int) $request->getAttribute('adapter_id'); |
|
77 | + $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
78 | 78 | |
79 | - if ($map_adapter === null) { |
|
80 | - throw new HttpNotFoundException( |
|
81 | - I18N::translate('The map configuration could not be found.') |
|
82 | - ); |
|
83 | - } |
|
79 | + if ($map_adapter === null) { |
|
80 | + throw new HttpNotFoundException( |
|
81 | + I18N::translate('The map configuration could not be found.') |
|
82 | + ); |
|
83 | + } |
|
84 | 84 | |
85 | - return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [ |
|
86 | - 'module' => $this->module, |
|
87 | - 'title' => I18N::translate('Edit the map configuration'), |
|
88 | - 'tree' => $tree, |
|
89 | - 'view_id' => $map_adapter->geoAnalysisViewId(), |
|
90 | - 'map_adapter' => $map_adapter, |
|
91 | - 'maps_list' => $this->map_definition_service->all(), |
|
92 | - 'mappers_list' => $this->place_mapper_service->all(), |
|
93 | - 'route_edit' => route(MapAdapterEditAction::class, [ |
|
94 | - 'tree' => $tree->name(), |
|
95 | - 'adapter_id' => $map_adapter->id() |
|
96 | - ]) |
|
97 | - ]); |
|
98 | - } |
|
85 | + return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [ |
|
86 | + 'module' => $this->module, |
|
87 | + 'title' => I18N::translate('Edit the map configuration'), |
|
88 | + 'tree' => $tree, |
|
89 | + 'view_id' => $map_adapter->geoAnalysisViewId(), |
|
90 | + 'map_adapter' => $map_adapter, |
|
91 | + 'maps_list' => $this->map_definition_service->all(), |
|
92 | + 'mappers_list' => $this->place_mapper_service->all(), |
|
93 | + 'route_edit' => route(MapAdapterEditAction::class, [ |
|
94 | + 'tree' => $tree->name(), |
|
95 | + 'adapter_id' => $map_adapter->id() |
|
96 | + ]) |
|
97 | + ]); |
|
98 | + } |
|
99 | 99 | } |
@@ -34,66 +34,66 @@ |
||
34 | 34 | */ |
35 | 35 | class AdminConfigPage implements RequestHandlerInterface |
36 | 36 | { |
37 | - use ViewResponseTrait; |
|
38 | - |
|
39 | - private ?GeoDispersionModule $module; |
|
40 | - |
|
41 | - private TreeService $tree_service; |
|
42 | - |
|
43 | - private GeoAnalysisDataService $geoanalysis_data_service; |
|
44 | - |
|
45 | - /** |
|
46 | - * Constructor for the AdminConfigPage Request Handler |
|
47 | - * |
|
48 | - * @param ModuleService $module_service |
|
49 | - * @param TreeService $tree_service |
|
50 | - * @param GeoAnalysisDataService $geoanalysis_data_service |
|
51 | - */ |
|
52 | - public function __construct( |
|
53 | - ModuleService $module_service, |
|
54 | - TreeService $tree_service, |
|
55 | - GeoAnalysisDataService $geoanalysis_data_service |
|
56 | - ) { |
|
57 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
58 | - $this->tree_service = $tree_service; |
|
59 | - $this->geoanalysis_data_service = $geoanalysis_data_service; |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * {@inheritDoc} |
|
64 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
65 | - */ |
|
66 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
67 | - { |
|
68 | - $this->layout = 'layouts/administration'; |
|
69 | - |
|
70 | - if ($this->module === null) { |
|
71 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
72 | - } |
|
73 | - |
|
74 | - $user = $request->getAttribute('user'); |
|
75 | - assert($user instanceof UserInterface); |
|
76 | - |
|
77 | - $all_trees = $this->tree_service->all()->filter(fn(Tree $tree) => Auth::isManager($tree, $user)); |
|
78 | - if ($all_trees->count() === 0) { |
|
79 | - throw new HttpAccessDeniedException(); |
|
80 | - } |
|
81 | - |
|
82 | - $tree = $request->getAttribute('tree') ?? $all_trees->first(); |
|
83 | - assert($tree instanceof Tree); |
|
84 | - |
|
85 | - $same_tree = fn(Tree $tree_collection): bool => $tree->id() === $tree_collection->id(); |
|
86 | - if (!$all_trees->contains($same_tree)) { |
|
87 | - throw new HttpAccessDeniedException(); |
|
88 | - } |
|
89 | - |
|
90 | - return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
91 | - 'module_name' => $this->module->name(), |
|
92 | - 'title' => $this->module->title(), |
|
93 | - 'tree' => $tree, |
|
94 | - 'other_trees' => $all_trees->reject($same_tree), |
|
95 | - 'place_example' => $this->geoanalysis_data_service->placeHierarchyExample($tree), |
|
96 | - 'js_script_url' => $this->module->assetUrl('js/geodispersion.min.js') |
|
97 | - ]); |
|
98 | - } |
|
37 | + use ViewResponseTrait; |
|
38 | + |
|
39 | + private ?GeoDispersionModule $module; |
|
40 | + |
|
41 | + private TreeService $tree_service; |
|
42 | + |
|
43 | + private GeoAnalysisDataService $geoanalysis_data_service; |
|
44 | + |
|
45 | + /** |
|
46 | + * Constructor for the AdminConfigPage Request Handler |
|
47 | + * |
|
48 | + * @param ModuleService $module_service |
|
49 | + * @param TreeService $tree_service |
|
50 | + * @param GeoAnalysisDataService $geoanalysis_data_service |
|
51 | + */ |
|
52 | + public function __construct( |
|
53 | + ModuleService $module_service, |
|
54 | + TreeService $tree_service, |
|
55 | + GeoAnalysisDataService $geoanalysis_data_service |
|
56 | + ) { |
|
57 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
58 | + $this->tree_service = $tree_service; |
|
59 | + $this->geoanalysis_data_service = $geoanalysis_data_service; |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * {@inheritDoc} |
|
64 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
65 | + */ |
|
66 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
67 | + { |
|
68 | + $this->layout = 'layouts/administration'; |
|
69 | + |
|
70 | + if ($this->module === null) { |
|
71 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
72 | + } |
|
73 | + |
|
74 | + $user = $request->getAttribute('user'); |
|
75 | + assert($user instanceof UserInterface); |
|
76 | + |
|
77 | + $all_trees = $this->tree_service->all()->filter(fn(Tree $tree) => Auth::isManager($tree, $user)); |
|
78 | + if ($all_trees->count() === 0) { |
|
79 | + throw new HttpAccessDeniedException(); |
|
80 | + } |
|
81 | + |
|
82 | + $tree = $request->getAttribute('tree') ?? $all_trees->first(); |
|
83 | + assert($tree instanceof Tree); |
|
84 | + |
|
85 | + $same_tree = fn(Tree $tree_collection): bool => $tree->id() === $tree_collection->id(); |
|
86 | + if (!$all_trees->contains($same_tree)) { |
|
87 | + throw new HttpAccessDeniedException(); |
|
88 | + } |
|
89 | + |
|
90 | + return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
91 | + 'module_name' => $this->module->name(), |
|
92 | + 'title' => $this->module->title(), |
|
93 | + 'tree' => $tree, |
|
94 | + 'other_trees' => $all_trees->reject($same_tree), |
|
95 | + 'place_example' => $this->geoanalysis_data_service->placeHierarchyExample($tree), |
|
96 | + 'js_script_url' => $this->module->assetUrl('js/geodispersion.min.js') |
|
97 | + ]); |
|
98 | + } |
|
99 | 99 | } |
@@ -31,68 +31,68 @@ |
||
31 | 31 | */ |
32 | 32 | class GeoAnalysisViewStatusAction implements RequestHandlerInterface |
33 | 33 | { |
34 | - private ?GeoDispersionModule $module; |
|
35 | - private GeoAnalysisViewDataService $geoview_data_service; |
|
34 | + private ?GeoDispersionModule $module; |
|
35 | + private GeoAnalysisViewDataService $geoview_data_service; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor for GeoAnalysisViewStatusAction Request Handler |
|
39 | - * |
|
40 | - * @param ModuleService $module_service |
|
41 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
42 | - */ |
|
43 | - public function __construct(ModuleService $module_service, GeoAnalysisViewDataService $geoview_data_service) |
|
44 | - { |
|
45 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
46 | - $this->geoview_data_service = $geoview_data_service; |
|
47 | - } |
|
37 | + /** |
|
38 | + * Constructor for GeoAnalysisViewStatusAction Request Handler |
|
39 | + * |
|
40 | + * @param ModuleService $module_service |
|
41 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
42 | + */ |
|
43 | + public function __construct(ModuleService $module_service, GeoAnalysisViewDataService $geoview_data_service) |
|
44 | + { |
|
45 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
46 | + $this->geoview_data_service = $geoview_data_service; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * {@inheritDoc} |
|
51 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
52 | - */ |
|
53 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
54 | - { |
|
55 | - $tree = $request->getAttribute('tree'); |
|
56 | - assert($tree instanceof Tree); |
|
49 | + /** |
|
50 | + * {@inheritDoc} |
|
51 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
52 | + */ |
|
53 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
54 | + { |
|
55 | + $tree = $request->getAttribute('tree'); |
|
56 | + assert($tree instanceof Tree); |
|
57 | 57 | |
58 | - $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
58 | + $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
59 | 59 | |
60 | - if ($this->module === null) { |
|
61 | - FlashMessages::addMessage( |
|
62 | - I18N::translate('The attached module could not be found.'), |
|
63 | - 'danger' |
|
64 | - ); |
|
65 | - return redirect($admin_config_route); |
|
66 | - } |
|
60 | + if ($this->module === null) { |
|
61 | + FlashMessages::addMessage( |
|
62 | + I18N::translate('The attached module could not be found.'), |
|
63 | + 'danger' |
|
64 | + ); |
|
65 | + return redirect($admin_config_route); |
|
66 | + } |
|
67 | 67 | |
68 | - $view_id = (int) $request->getAttribute('view_id'); |
|
69 | - $view = $this->geoview_data_service->find($tree, $view_id, true); |
|
68 | + $view_id = (int) $request->getAttribute('view_id'); |
|
69 | + $view = $this->geoview_data_service->find($tree, $view_id, true); |
|
70 | 70 | |
71 | - if ($view === null) { |
|
72 | - FlashMessages::addMessage( |
|
73 | - I18N::translate('The view with ID “%s” does not exist.', I18N::number($view_id)), |
|
74 | - 'danger' |
|
75 | - ); |
|
76 | - return redirect($admin_config_route); |
|
77 | - } |
|
71 | + if ($view === null) { |
|
72 | + FlashMessages::addMessage( |
|
73 | + I18N::translate('The view with ID “%s” does not exist.', I18N::number($view_id)), |
|
74 | + 'danger' |
|
75 | + ); |
|
76 | + return redirect($admin_config_route); |
|
77 | + } |
|
78 | 78 | |
79 | - try { |
|
80 | - $this->geoview_data_service->updateStatus($view, (bool) $request->getAttribute('enable', false)); |
|
81 | - FlashMessages::addMessage( |
|
82 | - I18N::translate('The geographical dispersion analysis view has been successfully updated.'), |
|
83 | - 'success' |
|
84 | - ); |
|
85 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
86 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : View “' . $view->id() . '” has been updated.'); |
|
87 | - } catch (Throwable $ex) { |
|
88 | - FlashMessages::addMessage( |
|
89 | - I18N::translate('An error occured while updating the geographical dispersion analysis view.'), |
|
90 | - 'danger' |
|
91 | - ); |
|
92 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
93 | - Log::addErrorLog('Module ' . $this->module->title() . ' : Error when updating view “' . $view->id() . '”: ' . $ex->getMessage()); |
|
94 | - } |
|
79 | + try { |
|
80 | + $this->geoview_data_service->updateStatus($view, (bool) $request->getAttribute('enable', false)); |
|
81 | + FlashMessages::addMessage( |
|
82 | + I18N::translate('The geographical dispersion analysis view has been successfully updated.'), |
|
83 | + 'success' |
|
84 | + ); |
|
85 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
86 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : View “' . $view->id() . '” has been updated.'); |
|
87 | + } catch (Throwable $ex) { |
|
88 | + FlashMessages::addMessage( |
|
89 | + I18N::translate('An error occured while updating the geographical dispersion analysis view.'), |
|
90 | + 'danger' |
|
91 | + ); |
|
92 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
93 | + Log::addErrorLog('Module ' . $this->module->title() . ' : Error when updating view “' . $view->id() . '”: ' . $ex->getMessage()); |
|
94 | + } |
|
95 | 95 | |
96 | - return redirect($admin_config_route); |
|
97 | - } |
|
96 | + return redirect($admin_config_route); |
|
97 | + } |
|
98 | 98 | } |
@@ -36,98 +36,98 @@ |
||
36 | 36 | */ |
37 | 37 | class MapAdapterAddAction implements RequestHandlerInterface |
38 | 38 | { |
39 | - private ?GeoDispersionModule $module; |
|
40 | - private GeoAnalysisViewDataService $geoview_data_service; |
|
41 | - private MapAdapterDataService $mapadapter_data_service; |
|
42 | - private MapDefinitionsService $map_definition_service; |
|
39 | + private ?GeoDispersionModule $module; |
|
40 | + private GeoAnalysisViewDataService $geoview_data_service; |
|
41 | + private MapAdapterDataService $mapadapter_data_service; |
|
42 | + private MapDefinitionsService $map_definition_service; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Constructor for MapAdapterAddAction Request Handler |
|
46 | - * |
|
47 | - * @param ModuleService $module_service |
|
48 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
49 | - * @param MapAdapterDataService $mapadapter_data_service |
|
50 | - * @param MapDefinitionsService $map_definition_service |
|
51 | - */ |
|
52 | - public function __construct( |
|
53 | - ModuleService $module_service, |
|
54 | - GeoAnalysisViewDataService $geoview_data_service, |
|
55 | - MapAdapterDataService $mapadapter_data_service, |
|
56 | - MapDefinitionsService $map_definition_service |
|
57 | - ) { |
|
58 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
59 | - $this->geoview_data_service = $geoview_data_service; |
|
60 | - $this->mapadapter_data_service = $mapadapter_data_service; |
|
61 | - $this->map_definition_service = $map_definition_service; |
|
62 | - } |
|
44 | + /** |
|
45 | + * Constructor for MapAdapterAddAction Request Handler |
|
46 | + * |
|
47 | + * @param ModuleService $module_service |
|
48 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
49 | + * @param MapAdapterDataService $mapadapter_data_service |
|
50 | + * @param MapDefinitionsService $map_definition_service |
|
51 | + */ |
|
52 | + public function __construct( |
|
53 | + ModuleService $module_service, |
|
54 | + GeoAnalysisViewDataService $geoview_data_service, |
|
55 | + MapAdapterDataService $mapadapter_data_service, |
|
56 | + MapDefinitionsService $map_definition_service |
|
57 | + ) { |
|
58 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
59 | + $this->geoview_data_service = $geoview_data_service; |
|
60 | + $this->mapadapter_data_service = $mapadapter_data_service; |
|
61 | + $this->map_definition_service = $map_definition_service; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * {@inheritDoc} |
|
66 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
67 | - */ |
|
68 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
69 | - { |
|
70 | - $tree = $request->getAttribute('tree'); |
|
71 | - assert($tree instanceof Tree); |
|
64 | + /** |
|
65 | + * {@inheritDoc} |
|
66 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
67 | + */ |
|
68 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
69 | + { |
|
70 | + $tree = $request->getAttribute('tree'); |
|
71 | + assert($tree instanceof Tree); |
|
72 | 72 | |
73 | - if ($this->module === null) { |
|
74 | - FlashMessages::addMessage( |
|
75 | - I18N::translate('The attached module could not be found.'), |
|
76 | - 'danger' |
|
77 | - ); |
|
78 | - return redirect(route(AdminConfigPage::class, ['tree' => $tree])); |
|
79 | - } |
|
73 | + if ($this->module === null) { |
|
74 | + FlashMessages::addMessage( |
|
75 | + I18N::translate('The attached module could not be found.'), |
|
76 | + 'danger' |
|
77 | + ); |
|
78 | + return redirect(route(AdminConfigPage::class, ['tree' => $tree])); |
|
79 | + } |
|
80 | 80 | |
81 | - $view_id = (int) $request->getAttribute('view_id'); |
|
82 | - $view = $this->geoview_data_service->find($tree, $view_id); |
|
81 | + $view_id = (int) $request->getAttribute('view_id'); |
|
82 | + $view = $this->geoview_data_service->find($tree, $view_id); |
|
83 | 83 | |
84 | - $params = (array) $request->getParsedBody(); |
|
84 | + $params = (array) $request->getParsedBody(); |
|
85 | 85 | |
86 | - $map = $this->map_definition_service->find($params['map_adapter_map'] ?? ''); |
|
87 | - $mapping_property = $params['map_adapter_property_selected'] ?? ''; |
|
86 | + $map = $this->map_definition_service->find($params['map_adapter_map'] ?? ''); |
|
87 | + $mapping_property = $params['map_adapter_property_selected'] ?? ''; |
|
88 | 88 | |
89 | - $mapper = null; |
|
90 | - try { |
|
91 | - $mapper = app($params['map_adapter_mapper'] ?? ''); |
|
92 | - } catch (BindingResolutionException $ex) { |
|
93 | - } |
|
89 | + $mapper = null; |
|
90 | + try { |
|
91 | + $mapper = app($params['map_adapter_mapper'] ?? ''); |
|
92 | + } catch (BindingResolutionException $ex) { |
|
93 | + } |
|
94 | 94 | |
95 | - if ($view === null || $map === null || $mapper === null || !($mapper instanceof PlaceMapperInterface)) { |
|
96 | - FlashMessages::addMessage( |
|
97 | - I18N::translate('The parameters for the map configuration are not valid.'), |
|
98 | - 'danger' |
|
99 | - ); |
|
100 | - return redirect(route(AdminConfigPage::class, ['tree' => $tree])); |
|
101 | - } |
|
95 | + if ($view === null || $map === null || $mapper === null || !($mapper instanceof PlaceMapperInterface)) { |
|
96 | + FlashMessages::addMessage( |
|
97 | + I18N::translate('The parameters for the map configuration are not valid.'), |
|
98 | + 'danger' |
|
99 | + ); |
|
100 | + return redirect(route(AdminConfigPage::class, ['tree' => $tree])); |
|
101 | + } |
|
102 | 102 | |
103 | - $new_adapter_id = $this->mapadapter_data_service->insertGetId( |
|
104 | - new GeoAnalysisMapAdapter( |
|
105 | - 0, |
|
106 | - $view_id, |
|
107 | - $map, |
|
108 | - $mapper, |
|
109 | - new MapViewConfig($mapping_property, $mapper->config()->withConfigUpdate($request)) |
|
110 | - ) |
|
111 | - ); |
|
112 | - if ($new_adapter_id > 0) { |
|
113 | - FlashMessages::addMessage( |
|
114 | - I18N::translate('The map configuration has been successfully added.'), |
|
115 | - 'success' |
|
116 | - ); |
|
117 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
118 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $new_adapter_id . '” has been added.'); |
|
119 | - } else { |
|
120 | - FlashMessages::addMessage( |
|
121 | - I18N::translate('An error occured while adding a new map configuration.'), |
|
122 | - 'danger' |
|
123 | - ); |
|
124 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
125 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter could not be added. See error log.'); |
|
126 | - } |
|
103 | + $new_adapter_id = $this->mapadapter_data_service->insertGetId( |
|
104 | + new GeoAnalysisMapAdapter( |
|
105 | + 0, |
|
106 | + $view_id, |
|
107 | + $map, |
|
108 | + $mapper, |
|
109 | + new MapViewConfig($mapping_property, $mapper->config()->withConfigUpdate($request)) |
|
110 | + ) |
|
111 | + ); |
|
112 | + if ($new_adapter_id > 0) { |
|
113 | + FlashMessages::addMessage( |
|
114 | + I18N::translate('The map configuration has been successfully added.'), |
|
115 | + 'success' |
|
116 | + ); |
|
117 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
118 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $new_adapter_id . '” has been added.'); |
|
119 | + } else { |
|
120 | + FlashMessages::addMessage( |
|
121 | + I18N::translate('An error occured while adding a new map configuration.'), |
|
122 | + 'danger' |
|
123 | + ); |
|
124 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
125 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter could not be added. See error log.'); |
|
126 | + } |
|
127 | 127 | |
128 | - return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
129 | - 'tree' => $tree->name(), |
|
130 | - 'view_id' => $view_id |
|
131 | - ])); |
|
132 | - } |
|
128 | + return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
129 | + 'tree' => $tree->name(), |
|
130 | + 'view_id' => $view_id |
|
131 | + ])); |
|
132 | + } |
|
133 | 133 | } |
@@ -31,45 +31,45 @@ |
||
31 | 31 | */ |
32 | 32 | class GeoAnalysisViewPage implements RequestHandlerInterface |
33 | 33 | { |
34 | - use ViewResponseTrait; |
|
34 | + use ViewResponseTrait; |
|
35 | 35 | |
36 | - private ?GeoDispersionModule $module; |
|
37 | - private GeoAnalysisViewDataService $geoviewdata_service; |
|
36 | + private ?GeoDispersionModule $module; |
|
37 | + private GeoAnalysisViewDataService $geoviewdata_service; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Constructor for GeoAnalysisViewPage Request Handler |
|
41 | - * |
|
42 | - * @param ModuleService $module_service |
|
43 | - */ |
|
44 | - public function __construct( |
|
45 | - ModuleService $module_service, |
|
46 | - GeoAnalysisViewDataService $geoviewdata_service |
|
47 | - ) { |
|
48 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
49 | - $this->geoviewdata_service = $geoviewdata_service; |
|
50 | - } |
|
39 | + /** |
|
40 | + * Constructor for GeoAnalysisViewPage Request Handler |
|
41 | + * |
|
42 | + * @param ModuleService $module_service |
|
43 | + */ |
|
44 | + public function __construct( |
|
45 | + ModuleService $module_service, |
|
46 | + GeoAnalysisViewDataService $geoviewdata_service |
|
47 | + ) { |
|
48 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
49 | + $this->geoviewdata_service = $geoviewdata_service; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * {@inheritDoc} |
|
54 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
55 | - */ |
|
56 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
57 | - { |
|
58 | - if ($this->module === null) { |
|
59 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
60 | - } |
|
52 | + /** |
|
53 | + * {@inheritDoc} |
|
54 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
55 | + */ |
|
56 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
57 | + { |
|
58 | + if ($this->module === null) { |
|
59 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
60 | + } |
|
61 | 61 | |
62 | - $tree = $request->getAttribute('tree'); |
|
63 | - assert($tree instanceof Tree); |
|
62 | + $tree = $request->getAttribute('tree'); |
|
63 | + assert($tree instanceof Tree); |
|
64 | 64 | |
65 | - $view_id = $request->getAttribute('view_id'); |
|
66 | - $view_id = is_numeric($view_id) ? (int) $view_id : 0; |
|
65 | + $view_id = $request->getAttribute('view_id'); |
|
66 | + $view_id = is_numeric($view_id) ? (int) $view_id : 0; |
|
67 | 67 | |
68 | - return $this->viewResponse($this->module->name() . '::geoanalysisview-page', [ |
|
69 | - 'module_name' => $this->module->name(), |
|
70 | - 'title' => I18N::translate('Geographical dispersion'), |
|
71 | - 'tree' => $tree, |
|
72 | - 'view' => $this->geoviewdata_service->find($tree, $view_id) |
|
73 | - ]); |
|
74 | - } |
|
68 | + return $this->viewResponse($this->module->name() . '::geoanalysisview-page', [ |
|
69 | + 'module_name' => $this->module->name(), |
|
70 | + 'title' => I18N::translate('Geographical dispersion'), |
|
71 | + 'tree' => $tree, |
|
72 | + 'view' => $this->geoviewdata_service->find($tree, $view_id) |
|
73 | + ]); |
|
74 | + } |
|
75 | 75 | } |
@@ -30,67 +30,67 @@ |
||
30 | 30 | */ |
31 | 31 | class GeoAnalysisViewDeleteAction implements RequestHandlerInterface |
32 | 32 | { |
33 | - private ?GeoDispersionModule $module; |
|
34 | - private GeoAnalysisViewDataService $geoview_data_service; |
|
33 | + private ?GeoDispersionModule $module; |
|
34 | + private GeoAnalysisViewDataService $geoview_data_service; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Constructor for GeoAnalysisViewDeleteAction Request Handler |
|
38 | - * |
|
39 | - * @param ModuleService $module_service |
|
40 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
41 | - */ |
|
42 | - public function __construct(ModuleService $module_service, GeoAnalysisViewDataService $geoview_data_service) |
|
43 | - { |
|
44 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
45 | - $this->geoview_data_service = $geoview_data_service; |
|
46 | - } |
|
36 | + /** |
|
37 | + * Constructor for GeoAnalysisViewDeleteAction Request Handler |
|
38 | + * |
|
39 | + * @param ModuleService $module_service |
|
40 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
41 | + */ |
|
42 | + public function __construct(ModuleService $module_service, GeoAnalysisViewDataService $geoview_data_service) |
|
43 | + { |
|
44 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
45 | + $this->geoview_data_service = $geoview_data_service; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * {@inheritDoc} |
|
50 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
51 | - */ |
|
52 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
53 | - { |
|
54 | - $tree = $request->getAttribute('tree'); |
|
55 | - assert($tree instanceof Tree); |
|
48 | + /** |
|
49 | + * {@inheritDoc} |
|
50 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
51 | + */ |
|
52 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
53 | + { |
|
54 | + $tree = $request->getAttribute('tree'); |
|
55 | + assert($tree instanceof Tree); |
|
56 | 56 | |
57 | - $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
57 | + $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
58 | 58 | |
59 | - if ($this->module === null) { |
|
60 | - FlashMessages::addMessage( |
|
61 | - I18N::translate('The attached module could not be found.'), |
|
62 | - 'danger' |
|
63 | - ); |
|
64 | - return redirect($admin_config_route); |
|
65 | - } |
|
59 | + if ($this->module === null) { |
|
60 | + FlashMessages::addMessage( |
|
61 | + I18N::translate('The attached module could not be found.'), |
|
62 | + 'danger' |
|
63 | + ); |
|
64 | + return redirect($admin_config_route); |
|
65 | + } |
|
66 | 66 | |
67 | - $view_id = (int) $request->getAttribute('view_id'); |
|
68 | - $view = $this->geoview_data_service->find($tree, $view_id, true); |
|
67 | + $view_id = (int) $request->getAttribute('view_id'); |
|
68 | + $view = $this->geoview_data_service->find($tree, $view_id, true); |
|
69 | 69 | |
70 | - if ($view === null) { |
|
71 | - FlashMessages::addMessage( |
|
72 | - I18N::translate('The view with ID “%s” does not exist.', I18N::number($view_id)), |
|
73 | - 'danger' |
|
74 | - ); |
|
75 | - return redirect($admin_config_route); |
|
76 | - } |
|
70 | + if ($view === null) { |
|
71 | + FlashMessages::addMessage( |
|
72 | + I18N::translate('The view with ID “%s” does not exist.', I18N::number($view_id)), |
|
73 | + 'danger' |
|
74 | + ); |
|
75 | + return redirect($admin_config_route); |
|
76 | + } |
|
77 | 77 | |
78 | - if ($this->geoview_data_service->delete($view) > 0) { |
|
79 | - FlashMessages::addMessage( |
|
80 | - I18N::translate('The geographical dispersion analysis view has been successfully deleted.'), |
|
81 | - 'success' |
|
82 | - ); |
|
83 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
84 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : View “' . $view->id() . '” has been deleted.'); |
|
85 | - } else { |
|
86 | - FlashMessages::addMessage( |
|
87 | - I18N::translate('An error occured while deleting the geographical dispersion analysis view.'), |
|
88 | - 'danger' |
|
89 | - ); |
|
90 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
91 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : View “' . $view->id() . '” could not be deleted. See error log.'); |
|
92 | - } |
|
78 | + if ($this->geoview_data_service->delete($view) > 0) { |
|
79 | + FlashMessages::addMessage( |
|
80 | + I18N::translate('The geographical dispersion analysis view has been successfully deleted.'), |
|
81 | + 'success' |
|
82 | + ); |
|
83 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
84 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : View “' . $view->id() . '” has been deleted.'); |
|
85 | + } else { |
|
86 | + FlashMessages::addMessage( |
|
87 | + I18N::translate('An error occured while deleting the geographical dispersion analysis view.'), |
|
88 | + 'danger' |
|
89 | + ); |
|
90 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
91 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : View “' . $view->id() . '” could not be deleted. See error log.'); |
|
92 | + } |
|
93 | 93 | |
94 | - return redirect($admin_config_route); |
|
95 | - } |
|
94 | + return redirect($admin_config_route); |
|
95 | + } |
|
96 | 96 | } |
@@ -30,69 +30,69 @@ |
||
30 | 30 | */ |
31 | 31 | class MapAdapterDeleteAction implements RequestHandlerInterface |
32 | 32 | { |
33 | - private ?GeoDispersionModule $module; |
|
34 | - private MapAdapterDataService $mapadapter_data_service; |
|
33 | + private ?GeoDispersionModule $module; |
|
34 | + private MapAdapterDataService $mapadapter_data_service; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Constructor for MapAdapterDeleteAction Request Handler |
|
38 | - * |
|
39 | - * @param ModuleService $module_service |
|
40 | - * @param MapAdapterDataService $mapadapter_data_service |
|
41 | - */ |
|
42 | - public function __construct(ModuleService $module_service, MapAdapterDataService $mapadapter_data_service) |
|
43 | - { |
|
44 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
45 | - $this->mapadapter_data_service = $mapadapter_data_service; |
|
46 | - } |
|
36 | + /** |
|
37 | + * Constructor for MapAdapterDeleteAction Request Handler |
|
38 | + * |
|
39 | + * @param ModuleService $module_service |
|
40 | + * @param MapAdapterDataService $mapadapter_data_service |
|
41 | + */ |
|
42 | + public function __construct(ModuleService $module_service, MapAdapterDataService $mapadapter_data_service) |
|
43 | + { |
|
44 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
45 | + $this->mapadapter_data_service = $mapadapter_data_service; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * {@inheritDoc} |
|
50 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
51 | - */ |
|
52 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
53 | - { |
|
54 | - $tree = $request->getAttribute('tree'); |
|
55 | - assert($tree instanceof Tree); |
|
48 | + /** |
|
49 | + * {@inheritDoc} |
|
50 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
51 | + */ |
|
52 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
53 | + { |
|
54 | + $tree = $request->getAttribute('tree'); |
|
55 | + assert($tree instanceof Tree); |
|
56 | 56 | |
57 | - $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
57 | + $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
58 | 58 | |
59 | - if ($this->module === null) { |
|
60 | - FlashMessages::addMessage( |
|
61 | - I18N::translate('The attached module could not be found.'), |
|
62 | - 'danger' |
|
63 | - ); |
|
64 | - return redirect($admin_config_route); |
|
65 | - } |
|
66 | - $adapter_id = (int) $request->getAttribute('adapter_id'); |
|
67 | - $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
59 | + if ($this->module === null) { |
|
60 | + FlashMessages::addMessage( |
|
61 | + I18N::translate('The attached module could not be found.'), |
|
62 | + 'danger' |
|
63 | + ); |
|
64 | + return redirect($admin_config_route); |
|
65 | + } |
|
66 | + $adapter_id = (int) $request->getAttribute('adapter_id'); |
|
67 | + $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
68 | 68 | |
69 | - if ($map_adapter === null) { |
|
70 | - FlashMessages::addMessage( |
|
71 | - I18N::translate('The map configuration with ID “%d” does not exist.', I18N::number($adapter_id)), |
|
72 | - 'danger' |
|
73 | - ); |
|
74 | - return redirect($admin_config_route); |
|
75 | - } |
|
69 | + if ($map_adapter === null) { |
|
70 | + FlashMessages::addMessage( |
|
71 | + I18N::translate('The map configuration with ID “%d” does not exist.', I18N::number($adapter_id)), |
|
72 | + 'danger' |
|
73 | + ); |
|
74 | + return redirect($admin_config_route); |
|
75 | + } |
|
76 | 76 | |
77 | - if ($this->mapadapter_data_service->delete($map_adapter) > 0) { |
|
78 | - FlashMessages::addMessage( |
|
79 | - I18N::translate('The map configuration has been successfully deleted.'), |
|
80 | - 'success' |
|
81 | - ); |
|
82 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
83 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been deleted.'); |
|
84 | - } else { |
|
85 | - FlashMessages::addMessage( |
|
86 | - I18N::translate('An error occured while deleting the map configuration.'), |
|
87 | - 'danger' |
|
88 | - ); |
|
89 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
90 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” could not be deleted. See error log.'); |
|
91 | - } |
|
77 | + if ($this->mapadapter_data_service->delete($map_adapter) > 0) { |
|
78 | + FlashMessages::addMessage( |
|
79 | + I18N::translate('The map configuration has been successfully deleted.'), |
|
80 | + 'success' |
|
81 | + ); |
|
82 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
83 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been deleted.'); |
|
84 | + } else { |
|
85 | + FlashMessages::addMessage( |
|
86 | + I18N::translate('An error occured while deleting the map configuration.'), |
|
87 | + 'danger' |
|
88 | + ); |
|
89 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
90 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” could not be deleted. See error log.'); |
|
91 | + } |
|
92 | 92 | |
93 | - return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
94 | - 'tree' => $tree->name(), |
|
95 | - 'view_id' => $map_adapter->geoAnalysisViewId() |
|
96 | - ])); |
|
97 | - } |
|
93 | + return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
94 | + 'tree' => $tree->name(), |
|
95 | + 'view_id' => $map_adapter->geoAnalysisViewId() |
|
96 | + ])); |
|
97 | + } |
|
98 | 98 | } |