@@ -33,68 +33,68 @@ |
||
33 | 33 | */ |
34 | 34 | class MapAdapterEditPage implements RequestHandlerInterface |
35 | 35 | { |
36 | - use ViewResponseTrait; |
|
36 | + use ViewResponseTrait; |
|
37 | 37 | |
38 | - private ?GeoDispersionModule $module; |
|
39 | - private MapAdapterDataService $mapadapter_data_service; |
|
40 | - private MapDefinitionsService $map_definition_service; |
|
41 | - private PlaceMapperService $place_mapper_service; |
|
38 | + private ?GeoDispersionModule $module; |
|
39 | + private MapAdapterDataService $mapadapter_data_service; |
|
40 | + private MapDefinitionsService $map_definition_service; |
|
41 | + private PlaceMapperService $place_mapper_service; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Constructor for MapAdapterEditPage Request Handler |
|
45 | - * |
|
46 | - * @param ModuleService $module_service |
|
47 | - * @param MapAdapterDataService $mapadapter_data_service |
|
48 | - * @param MapDefinitionsService $map_definition_service |
|
49 | - * @param PlaceMapperService $place_mapper_service |
|
50 | - */ |
|
51 | - public function __construct( |
|
52 | - ModuleService $module_service, |
|
53 | - MapAdapterDataService $mapadapter_data_service, |
|
54 | - MapDefinitionsService $map_definition_service, |
|
55 | - PlaceMapperService $place_mapper_service |
|
56 | - ) { |
|
57 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
58 | - $this->mapadapter_data_service = $mapadapter_data_service; |
|
59 | - $this->map_definition_service = $map_definition_service; |
|
60 | - $this->place_mapper_service = $place_mapper_service; |
|
61 | - } |
|
43 | + /** |
|
44 | + * Constructor for MapAdapterEditPage Request Handler |
|
45 | + * |
|
46 | + * @param ModuleService $module_service |
|
47 | + * @param MapAdapterDataService $mapadapter_data_service |
|
48 | + * @param MapDefinitionsService $map_definition_service |
|
49 | + * @param PlaceMapperService $place_mapper_service |
|
50 | + */ |
|
51 | + public function __construct( |
|
52 | + ModuleService $module_service, |
|
53 | + MapAdapterDataService $mapadapter_data_service, |
|
54 | + MapDefinitionsService $map_definition_service, |
|
55 | + PlaceMapperService $place_mapper_service |
|
56 | + ) { |
|
57 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
58 | + $this->mapadapter_data_service = $mapadapter_data_service; |
|
59 | + $this->map_definition_service = $map_definition_service; |
|
60 | + $this->place_mapper_service = $place_mapper_service; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * {@inheritDoc} |
|
65 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
66 | - */ |
|
67 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
68 | - { |
|
69 | - $this->layout = 'layouts/administration'; |
|
63 | + /** |
|
64 | + * {@inheritDoc} |
|
65 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
66 | + */ |
|
67 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
68 | + { |
|
69 | + $this->layout = 'layouts/administration'; |
|
70 | 70 | |
71 | - if ($this->module === null) { |
|
72 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
73 | - } |
|
71 | + if ($this->module === null) { |
|
72 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
73 | + } |
|
74 | 74 | |
75 | - $tree = Validator::attributes($request)->tree(); |
|
75 | + $tree = Validator::attributes($request)->tree(); |
|
76 | 76 | |
77 | - $adapter_id = Validator::attributes($request)->integer('adapter_id', -1); |
|
78 | - $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
77 | + $adapter_id = Validator::attributes($request)->integer('adapter_id', -1); |
|
78 | + $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
79 | 79 | |
80 | - if ($map_adapter === null) { |
|
81 | - throw new HttpNotFoundException( |
|
82 | - I18N::translate('The map configuration could not be found.') |
|
83 | - ); |
|
84 | - } |
|
80 | + if ($map_adapter === null) { |
|
81 | + throw new HttpNotFoundException( |
|
82 | + I18N::translate('The map configuration could not be found.') |
|
83 | + ); |
|
84 | + } |
|
85 | 85 | |
86 | - return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [ |
|
87 | - 'module' => $this->module, |
|
88 | - 'title' => I18N::translate('Edit the map configuration'), |
|
89 | - 'tree' => $tree, |
|
90 | - 'view_id' => $map_adapter->geoAnalysisViewId(), |
|
91 | - 'map_adapter' => $map_adapter, |
|
92 | - 'maps_list' => $this->map_definition_service->all(), |
|
93 | - 'mappers_list' => $this->place_mapper_service->all(), |
|
94 | - 'route_edit' => route(MapAdapterEditAction::class, [ |
|
95 | - 'tree' => $tree->name(), |
|
96 | - 'adapter_id' => $map_adapter->id() |
|
97 | - ]) |
|
98 | - ]); |
|
99 | - } |
|
86 | + return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [ |
|
87 | + 'module' => $this->module, |
|
88 | + 'title' => I18N::translate('Edit the map configuration'), |
|
89 | + 'tree' => $tree, |
|
90 | + 'view_id' => $map_adapter->geoAnalysisViewId(), |
|
91 | + 'map_adapter' => $map_adapter, |
|
92 | + 'maps_list' => $this->map_definition_service->all(), |
|
93 | + 'mappers_list' => $this->place_mapper_service->all(), |
|
94 | + 'route_edit' => route(MapAdapterEditAction::class, [ |
|
95 | + 'tree' => $tree->name(), |
|
96 | + 'adapter_id' => $map_adapter->id() |
|
97 | + ]) |
|
98 | + ]); |
|
99 | + } |
|
100 | 100 | } |
@@ -31,66 +31,66 @@ |
||
31 | 31 | */ |
32 | 32 | class GeoAnalysisViewDeleteAction 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 GeoAnalysisViewDeleteAction 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 GeoAnalysisViewDeleteAction 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 = Validator::attributes($request)->tree(); |
|
49 | + /** |
|
50 | + * {@inheritDoc} |
|
51 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
52 | + */ |
|
53 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
54 | + { |
|
55 | + $tree = Validator::attributes($request)->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 = Validator::attributes($request)->integer('view_id', -1); |
|
68 | - $view = $this->geoview_data_service->find($tree, $view_id, true); |
|
67 | + $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
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 | } |
@@ -35,64 +35,64 @@ |
||
35 | 35 | */ |
36 | 36 | class AdminConfigPage implements RequestHandlerInterface |
37 | 37 | { |
38 | - use ViewResponseTrait; |
|
39 | - |
|
40 | - private ?GeoDispersionModule $module; |
|
41 | - |
|
42 | - private TreeService $tree_service; |
|
43 | - |
|
44 | - private GeoAnalysisDataService $geoanalysis_data_service; |
|
45 | - |
|
46 | - /** |
|
47 | - * Constructor for the AdminConfigPage Request Handler |
|
48 | - * |
|
49 | - * @param ModuleService $module_service |
|
50 | - * @param TreeService $tree_service |
|
51 | - * @param GeoAnalysisDataService $geoanalysis_data_service |
|
52 | - */ |
|
53 | - public function __construct( |
|
54 | - ModuleService $module_service, |
|
55 | - TreeService $tree_service, |
|
56 | - GeoAnalysisDataService $geoanalysis_data_service |
|
57 | - ) { |
|
58 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
59 | - $this->tree_service = $tree_service; |
|
60 | - $this->geoanalysis_data_service = $geoanalysis_data_service; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * {@inheritDoc} |
|
65 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
66 | - */ |
|
67 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
68 | - { |
|
69 | - $this->layout = 'layouts/administration'; |
|
70 | - |
|
71 | - if ($this->module === null) { |
|
72 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
73 | - } |
|
74 | - |
|
75 | - $user = Validator::attributes($request)->user(); |
|
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 = Validator::attributes($request)->treeOptional() ?? $all_trees->first(); |
|
83 | - |
|
84 | - $same_tree = fn(Tree $tree_collection): bool => $tree->id() === $tree_collection->id(); |
|
85 | - if (!$all_trees->contains($same_tree)) { |
|
86 | - throw new HttpAccessDeniedException(); |
|
87 | - } |
|
88 | - |
|
89 | - return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
90 | - 'module_name' => $this->module->name(), |
|
91 | - 'title' => $this->module->title(), |
|
92 | - 'tree' => $tree, |
|
93 | - 'other_trees' => $all_trees->reject($same_tree), |
|
94 | - 'place_example' => $this->geoanalysis_data_service->placeHierarchyExample($tree), |
|
95 | - 'js_script_url' => $this->module->assetUrl('js/geodispersion.min.js') |
|
96 | - ]); |
|
97 | - } |
|
38 | + use ViewResponseTrait; |
|
39 | + |
|
40 | + private ?GeoDispersionModule $module; |
|
41 | + |
|
42 | + private TreeService $tree_service; |
|
43 | + |
|
44 | + private GeoAnalysisDataService $geoanalysis_data_service; |
|
45 | + |
|
46 | + /** |
|
47 | + * Constructor for the AdminConfigPage Request Handler |
|
48 | + * |
|
49 | + * @param ModuleService $module_service |
|
50 | + * @param TreeService $tree_service |
|
51 | + * @param GeoAnalysisDataService $geoanalysis_data_service |
|
52 | + */ |
|
53 | + public function __construct( |
|
54 | + ModuleService $module_service, |
|
55 | + TreeService $tree_service, |
|
56 | + GeoAnalysisDataService $geoanalysis_data_service |
|
57 | + ) { |
|
58 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
59 | + $this->tree_service = $tree_service; |
|
60 | + $this->geoanalysis_data_service = $geoanalysis_data_service; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * {@inheritDoc} |
|
65 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
66 | + */ |
|
67 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
68 | + { |
|
69 | + $this->layout = 'layouts/administration'; |
|
70 | + |
|
71 | + if ($this->module === null) { |
|
72 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
73 | + } |
|
74 | + |
|
75 | + $user = Validator::attributes($request)->user(); |
|
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 = Validator::attributes($request)->treeOptional() ?? $all_trees->first(); |
|
83 | + |
|
84 | + $same_tree = fn(Tree $tree_collection): bool => $tree->id() === $tree_collection->id(); |
|
85 | + if (!$all_trees->contains($same_tree)) { |
|
86 | + throw new HttpAccessDeniedException(); |
|
87 | + } |
|
88 | + |
|
89 | + return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
90 | + 'module_name' => $this->module->name(), |
|
91 | + 'title' => $this->module->title(), |
|
92 | + 'tree' => $tree, |
|
93 | + 'other_trees' => $all_trees->reject($same_tree), |
|
94 | + 'place_example' => $this->geoanalysis_data_service->placeHierarchyExample($tree), |
|
95 | + 'js_script_url' => $this->module->assetUrl('js/geodispersion.min.js') |
|
96 | + ]); |
|
97 | + } |
|
98 | 98 | } |
@@ -33,67 +33,67 @@ |
||
33 | 33 | */ |
34 | 34 | class MapAdapterMapperConfig implements RequestHandlerInterface |
35 | 35 | { |
36 | - use ViewResponseTrait; |
|
36 | + use ViewResponseTrait; |
|
37 | 37 | |
38 | - private ?GeoDispersionModule $module; |
|
39 | - private MapAdapterDataService $mapadapter_data_service; |
|
38 | + private ?GeoDispersionModule $module; |
|
39 | + private MapAdapterDataService $mapadapter_data_service; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor for MapAdapterMapperConfig Request Handler |
|
43 | - * |
|
44 | - * @param ModuleService $module_service |
|
45 | - * @param MapAdapterDataService $mapadapter_data_service |
|
46 | - */ |
|
47 | - public function __construct( |
|
48 | - ModuleService $module_service, |
|
49 | - MapAdapterDataService $mapadapter_data_service |
|
50 | - ) { |
|
51 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
52 | - $this->mapadapter_data_service = $mapadapter_data_service; |
|
53 | - } |
|
41 | + /** |
|
42 | + * Constructor for MapAdapterMapperConfig Request Handler |
|
43 | + * |
|
44 | + * @param ModuleService $module_service |
|
45 | + * @param MapAdapterDataService $mapadapter_data_service |
|
46 | + */ |
|
47 | + public function __construct( |
|
48 | + ModuleService $module_service, |
|
49 | + MapAdapterDataService $mapadapter_data_service |
|
50 | + ) { |
|
51 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
52 | + $this->mapadapter_data_service = $mapadapter_data_service; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * {@inheritDoc} |
|
57 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
58 | - */ |
|
59 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
60 | - { |
|
61 | - $this->layout = 'layouts/ajax'; |
|
55 | + /** |
|
56 | + * {@inheritDoc} |
|
57 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
58 | + */ |
|
59 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
60 | + { |
|
61 | + $this->layout = 'layouts/ajax'; |
|
62 | 62 | |
63 | - if ($this->module === null) { |
|
64 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
65 | - } |
|
66 | - $tree = Validator::attributes($request)->tree(); |
|
63 | + if ($this->module === null) { |
|
64 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
65 | + } |
|
66 | + $tree = Validator::attributes($request)->tree(); |
|
67 | 67 | |
68 | - $adapter_id = Validator::attributes($request)->integer('adapter_id', -1); |
|
69 | - $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
68 | + $adapter_id = Validator::attributes($request)->integer('adapter_id', -1); |
|
69 | + $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
70 | 70 | |
71 | - $mapper_class = Validator::queryParams($request)->string('mapper', ''); |
|
72 | - $mapper = null; |
|
73 | - if ($mapper_class === '' && $map_adapter !== null) { |
|
74 | - $mapper = $map_adapter->placeMapper(); |
|
75 | - } else { |
|
76 | - try { |
|
77 | - $mapper = app($mapper_class); |
|
78 | - } catch (BindingResolutionException $ex) { |
|
79 | - } |
|
71 | + $mapper_class = Validator::queryParams($request)->string('mapper', ''); |
|
72 | + $mapper = null; |
|
73 | + if ($mapper_class === '' && $map_adapter !== null) { |
|
74 | + $mapper = $map_adapter->placeMapper(); |
|
75 | + } else { |
|
76 | + try { |
|
77 | + $mapper = app($mapper_class); |
|
78 | + } catch (BindingResolutionException $ex) { |
|
79 | + } |
|
80 | 80 | |
81 | - if ( |
|
82 | - $mapper !== null && $map_adapter !== null && |
|
83 | - get_class($map_adapter->placeMapper()) === get_class($mapper) |
|
84 | - ) { |
|
85 | - $mapper = $map_adapter->placeMapper(); |
|
86 | - } |
|
87 | - } |
|
81 | + if ( |
|
82 | + $mapper !== null && $map_adapter !== null && |
|
83 | + get_class($map_adapter->placeMapper()) === get_class($mapper) |
|
84 | + ) { |
|
85 | + $mapper = $map_adapter->placeMapper(); |
|
86 | + } |
|
87 | + } |
|
88 | 88 | |
89 | - if ($mapper === null || !($mapper instanceof PlaceMapperInterface)) { |
|
90 | - throw new HttpNotFoundException( |
|
91 | - I18N::translate('The configuration for the place mapper could not be found.') |
|
92 | - ); |
|
93 | - } |
|
89 | + if ($mapper === null || !($mapper instanceof PlaceMapperInterface)) { |
|
90 | + throw new HttpNotFoundException( |
|
91 | + I18N::translate('The configuration for the place mapper could not be found.') |
|
92 | + ); |
|
93 | + } |
|
94 | 94 | |
95 | - return $this->viewResponse('layouts/ajax', [ |
|
96 | - 'content' => $mapper->config()->configContent($this->module, $tree) |
|
97 | - ]); |
|
98 | - } |
|
95 | + return $this->viewResponse('layouts/ajax', [ |
|
96 | + 'content' => $mapper->config()->configContent($this->module, $tree) |
|
97 | + ]); |
|
98 | + } |
|
99 | 99 | } |
@@ -35,77 +35,77 @@ |
||
35 | 35 | */ |
36 | 36 | class MapAdapterDeleteInvalidAction implements RequestHandlerInterface |
37 | 37 | { |
38 | - private ?GeoDispersionModule $module; |
|
39 | - private GeoAnalysisViewDataService $geoview_data_service; |
|
40 | - private MapAdapterDataService $mapadapter_data_service; |
|
38 | + private ?GeoDispersionModule $module; |
|
39 | + private GeoAnalysisViewDataService $geoview_data_service; |
|
40 | + private MapAdapterDataService $mapadapter_data_service; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Constructor for MapAdapterDeleteInvalidAction Request Handler |
|
44 | - * |
|
45 | - * @param ModuleService $module_service |
|
46 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
47 | - * @param MapAdapterDataService $mapadapter_data_service |
|
48 | - */ |
|
49 | - public function __construct( |
|
50 | - ModuleService $module_service, |
|
51 | - GeoAnalysisViewDataService $geoview_data_service, |
|
52 | - MapAdapterDataService $mapadapter_data_service |
|
53 | - ) { |
|
54 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
55 | - $this->geoview_data_service = $geoview_data_service; |
|
56 | - $this->mapadapter_data_service = $mapadapter_data_service; |
|
57 | - } |
|
42 | + /** |
|
43 | + * Constructor for MapAdapterDeleteInvalidAction Request Handler |
|
44 | + * |
|
45 | + * @param ModuleService $module_service |
|
46 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
47 | + * @param MapAdapterDataService $mapadapter_data_service |
|
48 | + */ |
|
49 | + public function __construct( |
|
50 | + ModuleService $module_service, |
|
51 | + GeoAnalysisViewDataService $geoview_data_service, |
|
52 | + MapAdapterDataService $mapadapter_data_service |
|
53 | + ) { |
|
54 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
55 | + $this->geoview_data_service = $geoview_data_service; |
|
56 | + $this->mapadapter_data_service = $mapadapter_data_service; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * {@inheritDoc} |
|
61 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
62 | - */ |
|
63 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
64 | - { |
|
65 | - $tree = Validator::attributes($request)->tree(); |
|
59 | + /** |
|
60 | + * {@inheritDoc} |
|
61 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
62 | + */ |
|
63 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
64 | + { |
|
65 | + $tree = Validator::attributes($request)->tree(); |
|
66 | 66 | |
67 | - if ($this->module === null) { |
|
68 | - FlashMessages::addMessage( |
|
69 | - I18N::translate('The attached module could not be found.'), |
|
70 | - 'danger' |
|
71 | - ); |
|
72 | - return redirect(route(AdminConfigPage::class, ['tree' => $tree->name()])); |
|
73 | - } |
|
67 | + if ($this->module === null) { |
|
68 | + FlashMessages::addMessage( |
|
69 | + I18N::translate('The attached module could not be found.'), |
|
70 | + 'danger' |
|
71 | + ); |
|
72 | + return redirect(route(AdminConfigPage::class, ['tree' => $tree->name()])); |
|
73 | + } |
|
74 | 74 | |
75 | - $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
76 | - $view = $this->geoview_data_service->find($tree, $view_id); |
|
75 | + $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
76 | + $view = $this->geoview_data_service->find($tree, $view_id); |
|
77 | 77 | |
78 | - if ($view === null || !($view instanceof GeoAnalysisMap)) { |
|
79 | - FlashMessages::addMessage( |
|
80 | - I18N::translate('The view with ID “%s” does not exist.', I18N::number($view_id)), |
|
81 | - 'danger' |
|
82 | - ); |
|
83 | - return redirect(route(AdminConfigPage::class, ['tree' => $tree->name()])); |
|
84 | - } |
|
78 | + if ($view === null || !($view instanceof GeoAnalysisMap)) { |
|
79 | + FlashMessages::addMessage( |
|
80 | + I18N::translate('The view with ID “%s” does not exist.', I18N::number($view_id)), |
|
81 | + 'danger' |
|
82 | + ); |
|
83 | + return redirect(route(AdminConfigPage::class, ['tree' => $tree->name()])); |
|
84 | + } |
|
85 | 85 | |
86 | - /** @var \Illuminate\Support\Collection<int> $valid_map_adapters */ |
|
87 | - $valid_map_adapters = $this->mapadapter_data_service |
|
88 | - ->allForView($view) |
|
89 | - ->map(fn(GeoAnalysisMapAdapter $map_adapter): int => $map_adapter->id()); |
|
86 | + /** @var \Illuminate\Support\Collection<int> $valid_map_adapters */ |
|
87 | + $valid_map_adapters = $this->mapadapter_data_service |
|
88 | + ->allForView($view) |
|
89 | + ->map(fn(GeoAnalysisMapAdapter $map_adapter): int => $map_adapter->id()); |
|
90 | 90 | |
91 | - try { |
|
92 | - $this->mapadapter_data_service->deleteInvalid($view, $valid_map_adapters); |
|
93 | - FlashMessages::addMessage( |
|
94 | - I18N::translate('The invalid map configurations have been successfully deleted.'), |
|
95 | - 'success' |
|
96 | - ); |
|
97 | - } catch (Throwable $ex) { |
|
98 | - FlashMessages::addMessage( |
|
99 | - I18N::translate('An error occured while deleting the invalid map configurations.'), |
|
100 | - 'danger' |
|
101 | - ); |
|
102 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
103 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Error when deleting invalid map configurations: ' . $ex->getMessage()); |
|
104 | - } |
|
91 | + try { |
|
92 | + $this->mapadapter_data_service->deleteInvalid($view, $valid_map_adapters); |
|
93 | + FlashMessages::addMessage( |
|
94 | + I18N::translate('The invalid map configurations have been successfully deleted.'), |
|
95 | + 'success' |
|
96 | + ); |
|
97 | + } catch (Throwable $ex) { |
|
98 | + FlashMessages::addMessage( |
|
99 | + I18N::translate('An error occured while deleting the invalid map configurations.'), |
|
100 | + 'danger' |
|
101 | + ); |
|
102 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
103 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Error when deleting invalid map configurations: ' . $ex->getMessage()); |
|
104 | + } |
|
105 | 105 | |
106 | - return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
107 | - 'tree' => $tree->name(), |
|
108 | - 'view_id' => $view_id |
|
109 | - ])); |
|
110 | - } |
|
106 | + return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
107 | + 'tree' => $tree->name(), |
|
108 | + 'view_id' => $view_id |
|
109 | + ])); |
|
110 | + } |
|
111 | 111 | } |
@@ -30,51 +30,51 @@ |
||
30 | 30 | */ |
31 | 31 | class MapFeaturePropertyData implements RequestHandlerInterface |
32 | 32 | { |
33 | - private MapDefinitionsService $map_definition_service; |
|
33 | + private MapDefinitionsService $map_definition_service; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Constructor for MapFeaturePropertyData Request Handler |
|
37 | - * |
|
38 | - * @param MapDefinitionsService $map_definition_service |
|
39 | - */ |
|
40 | - public function __construct( |
|
41 | - MapDefinitionsService $map_definition_service |
|
42 | - ) { |
|
43 | - $this->map_definition_service = $map_definition_service; |
|
44 | - } |
|
35 | + /** |
|
36 | + * Constructor for MapFeaturePropertyData Request Handler |
|
37 | + * |
|
38 | + * @param MapDefinitionsService $map_definition_service |
|
39 | + */ |
|
40 | + public function __construct( |
|
41 | + MapDefinitionsService $map_definition_service |
|
42 | + ) { |
|
43 | + $this->map_definition_service = $map_definition_service; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * {@inheritDoc} |
|
48 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
49 | - */ |
|
50 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
51 | - { |
|
52 | - $map_id = Validator::queryParams($request)->string( |
|
53 | - 'map_id', |
|
54 | - Validator::attributes($request)->string('map_id', '') |
|
55 | - ); |
|
46 | + /** |
|
47 | + * {@inheritDoc} |
|
48 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
49 | + */ |
|
50 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
51 | + { |
|
52 | + $map_id = Validator::queryParams($request)->string( |
|
53 | + 'map_id', |
|
54 | + Validator::attributes($request)->string('map_id', '') |
|
55 | + ); |
|
56 | 56 | |
57 | - return response(Registry::cache()->file()->remember( |
|
58 | - 'map-properties-' . $map_id, |
|
59 | - function () use ($map_id): array { |
|
60 | - $map = $this->map_definition_service->find($map_id); |
|
61 | - if ($map === null) { |
|
62 | - throw new HttpNotFoundException(I18N::translate('The map could not be found.')); |
|
63 | - } |
|
57 | + return response(Registry::cache()->file()->remember( |
|
58 | + 'map-properties-' . $map_id, |
|
59 | + function () use ($map_id): array { |
|
60 | + $map = $this->map_definition_service->find($map_id); |
|
61 | + if ($map === null) { |
|
62 | + throw new HttpNotFoundException(I18N::translate('The map could not be found.')); |
|
63 | + } |
|
64 | 64 | |
65 | - $features = []; |
|
66 | - collect($map->features()) |
|
67 | - ->map(fn(Feature $feature): ?stdClass => $feature->getProperties()) |
|
68 | - ->filter() |
|
69 | - ->map(fn(stdClass $properties): array => array_keys(get_object_vars($properties))) |
|
70 | - ->each(function (array $properties) use (&$features): void { |
|
71 | - $features = count($features) === 0 ? $properties : array_intersect($features, $properties); |
|
72 | - }); |
|
65 | + $features = []; |
|
66 | + collect($map->features()) |
|
67 | + ->map(fn(Feature $feature): ?stdClass => $feature->getProperties()) |
|
68 | + ->filter() |
|
69 | + ->map(fn(stdClass $properties): array => array_keys(get_object_vars($properties))) |
|
70 | + ->each(function (array $properties) use (&$features): void { |
|
71 | + $features = count($features) === 0 ? $properties : array_intersect($features, $properties); |
|
72 | + }); |
|
73 | 73 | |
74 | - usort($features, I18N::comparator()); |
|
75 | - return $features; |
|
76 | - }, |
|
77 | - 86400000 |
|
78 | - )); |
|
79 | - } |
|
74 | + usort($features, I18N::comparator()); |
|
75 | + return $features; |
|
76 | + }, |
|
77 | + 86400000 |
|
78 | + )); |
|
79 | + } |
|
80 | 80 | } |
@@ -35,82 +35,82 @@ |
||
35 | 35 | */ |
36 | 36 | class GeoAnalysisViewAddAction implements RequestHandlerInterface |
37 | 37 | { |
38 | - private ?GeoDispersionModule $module; |
|
39 | - private GeoAnalysisViewDataService $geoview_data_service; |
|
38 | + private ?GeoDispersionModule $module; |
|
39 | + private GeoAnalysisViewDataService $geoview_data_service; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Constructor for GeoAnalysisViewAddAction Request Handler |
|
43 | - * |
|
44 | - * @param ModuleService $module_service |
|
45 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
46 | - */ |
|
47 | - public function __construct(ModuleService $module_service, GeoAnalysisViewDataService $geoview_data_service) |
|
48 | - { |
|
49 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
50 | - $this->geoview_data_service = $geoview_data_service; |
|
51 | - } |
|
41 | + /** |
|
42 | + * Constructor for GeoAnalysisViewAddAction Request Handler |
|
43 | + * |
|
44 | + * @param ModuleService $module_service |
|
45 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
46 | + */ |
|
47 | + public function __construct(ModuleService $module_service, GeoAnalysisViewDataService $geoview_data_service) |
|
48 | + { |
|
49 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
50 | + $this->geoview_data_service = $geoview_data_service; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * {@inheritDoc} |
|
55 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
56 | - */ |
|
57 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
58 | - { |
|
59 | - $tree = Validator::attributes($request)->tree(); |
|
53 | + /** |
|
54 | + * {@inheritDoc} |
|
55 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
56 | + */ |
|
57 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
58 | + { |
|
59 | + $tree = Validator::attributes($request)->tree(); |
|
60 | 60 | |
61 | - $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
61 | + $admin_config_route = route(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
62 | 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 | - } |
|
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 | 70 | |
71 | - $type = Validator::parsedBody($request)->isInArray(['table', 'map'])->string('view_type', ''); |
|
72 | - $description = Validator::parsedBody($request)->string('view_description', ''); |
|
73 | - $place_depth = Validator::parsedBody($request)->integer('view_depth', 1); |
|
71 | + $type = Validator::parsedBody($request)->isInArray(['table', 'map'])->string('view_type', ''); |
|
72 | + $description = Validator::parsedBody($request)->string('view_description', ''); |
|
73 | + $place_depth = Validator::parsedBody($request)->integer('view_depth', 1); |
|
74 | 74 | |
75 | - $analysis = null; |
|
76 | - try { |
|
77 | - $analysis = app(Validator::parsedBody($request)->string('view_analysis', '')); |
|
78 | - } catch (BindingResolutionException $ex) { |
|
79 | - } |
|
75 | + $analysis = null; |
|
76 | + try { |
|
77 | + $analysis = app(Validator::parsedBody($request)->string('view_analysis', '')); |
|
78 | + } catch (BindingResolutionException $ex) { |
|
79 | + } |
|
80 | 80 | |
81 | - if ($type === '' || $place_depth <= 0 || $analysis === null || !($analysis instanceof GeoAnalysisInterface)) { |
|
82 | - FlashMessages::addMessage( |
|
83 | - I18N::translate('The parameters for the new view are not valid.'), |
|
84 | - 'danger' |
|
85 | - ); |
|
86 | - return redirect($admin_config_route); |
|
87 | - } |
|
81 | + if ($type === '' || $place_depth <= 0 || $analysis === null || !($analysis instanceof GeoAnalysisInterface)) { |
|
82 | + FlashMessages::addMessage( |
|
83 | + I18N::translate('The parameters for the new view are not valid.'), |
|
84 | + 'danger' |
|
85 | + ); |
|
86 | + return redirect($admin_config_route); |
|
87 | + } |
|
88 | 88 | |
89 | - if ($type === 'map') { |
|
90 | - $new_view = new GeoAnalysisMap(0, $tree, true, $description, $analysis, $place_depth); |
|
91 | - } else { |
|
92 | - $new_view = new GeoAnalysisTable(0, $tree, true, $description, $analysis, $place_depth); |
|
93 | - } |
|
89 | + if ($type === 'map') { |
|
90 | + $new_view = new GeoAnalysisMap(0, $tree, true, $description, $analysis, $place_depth); |
|
91 | + } else { |
|
92 | + $new_view = new GeoAnalysisTable(0, $tree, true, $description, $analysis, $place_depth); |
|
93 | + } |
|
94 | 94 | |
95 | - $new_view_id = $this->geoview_data_service->insertGetId($new_view); |
|
96 | - if ($new_view_id > 0) { |
|
97 | - FlashMessages::addMessage( |
|
98 | - I18N::translate('The geographical dispersion analysis view has been successfully added.'), |
|
99 | - 'success' |
|
100 | - ); |
|
101 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
102 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : View “' . $new_view_id . '” has been added.'); |
|
103 | - return redirect( |
|
104 | - route(GeoAnalysisViewEditPage::class, ['tree' => $tree->name(), 'view_id' => $new_view_id ]) |
|
105 | - ); |
|
106 | - } else { |
|
107 | - FlashMessages::addMessage( |
|
108 | - I18N::translate('An error occured while adding the geographical dispersion analysis view.'), |
|
109 | - 'danger' |
|
110 | - ); |
|
111 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
112 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : A new View could not be added. See error log.'); |
|
113 | - return redirect($admin_config_route); |
|
114 | - } |
|
115 | - } |
|
95 | + $new_view_id = $this->geoview_data_service->insertGetId($new_view); |
|
96 | + if ($new_view_id > 0) { |
|
97 | + FlashMessages::addMessage( |
|
98 | + I18N::translate('The geographical dispersion analysis view has been successfully added.'), |
|
99 | + 'success' |
|
100 | + ); |
|
101 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
102 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : View “' . $new_view_id . '” has been added.'); |
|
103 | + return redirect( |
|
104 | + route(GeoAnalysisViewEditPage::class, ['tree' => $tree->name(), 'view_id' => $new_view_id ]) |
|
105 | + ); |
|
106 | + } else { |
|
107 | + FlashMessages::addMessage( |
|
108 | + I18N::translate('An error occured while adding the geographical dispersion analysis view.'), |
|
109 | + 'danger' |
|
110 | + ); |
|
111 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
112 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : A new View could not be added. See error log.'); |
|
113 | + return redirect($admin_config_route); |
|
114 | + } |
|
115 | + } |
|
116 | 116 | } |
@@ -33,68 +33,68 @@ |
||
33 | 33 | */ |
34 | 34 | class MapAdapterAddPage implements RequestHandlerInterface |
35 | 35 | { |
36 | - use ViewResponseTrait; |
|
36 | + use ViewResponseTrait; |
|
37 | 37 | |
38 | - private ?GeoDispersionModule $module; |
|
39 | - private GeoAnalysisViewDataService $geoview_data_service; |
|
40 | - private MapDefinitionsService $map_definition_service; |
|
41 | - private PlaceMapperService $place_mapper_service; |
|
38 | + private ?GeoDispersionModule $module; |
|
39 | + private GeoAnalysisViewDataService $geoview_data_service; |
|
40 | + private MapDefinitionsService $map_definition_service; |
|
41 | + private PlaceMapperService $place_mapper_service; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Constructor for MapAdapterAddPage Request Handler |
|
45 | - * |
|
46 | - * @param ModuleService $module_service |
|
47 | - * @param GeoAnalysisViewDataService $geoview_data_service |
|
48 | - * @param MapDefinitionsService $map_definition_service |
|
49 | - * @param PlaceMapperService $place_mapper_service |
|
50 | - */ |
|
51 | - public function __construct( |
|
52 | - ModuleService $module_service, |
|
53 | - GeoAnalysisViewDataService $geoview_data_service, |
|
54 | - MapDefinitionsService $map_definition_service, |
|
55 | - PlaceMapperService $place_mapper_service |
|
56 | - ) { |
|
57 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
58 | - $this->geoview_data_service = $geoview_data_service; |
|
59 | - $this->map_definition_service = $map_definition_service; |
|
60 | - $this->place_mapper_service = $place_mapper_service; |
|
61 | - } |
|
43 | + /** |
|
44 | + * Constructor for MapAdapterAddPage Request Handler |
|
45 | + * |
|
46 | + * @param ModuleService $module_service |
|
47 | + * @param GeoAnalysisViewDataService $geoview_data_service |
|
48 | + * @param MapDefinitionsService $map_definition_service |
|
49 | + * @param PlaceMapperService $place_mapper_service |
|
50 | + */ |
|
51 | + public function __construct( |
|
52 | + ModuleService $module_service, |
|
53 | + GeoAnalysisViewDataService $geoview_data_service, |
|
54 | + MapDefinitionsService $map_definition_service, |
|
55 | + PlaceMapperService $place_mapper_service |
|
56 | + ) { |
|
57 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
58 | + $this->geoview_data_service = $geoview_data_service; |
|
59 | + $this->map_definition_service = $map_definition_service; |
|
60 | + $this->place_mapper_service = $place_mapper_service; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * {@inheritDoc} |
|
65 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
66 | - */ |
|
67 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
68 | - { |
|
69 | - $this->layout = 'layouts/administration'; |
|
63 | + /** |
|
64 | + * {@inheritDoc} |
|
65 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
66 | + */ |
|
67 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
68 | + { |
|
69 | + $this->layout = 'layouts/administration'; |
|
70 | 70 | |
71 | - if ($this->module === null) { |
|
72 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
73 | - } |
|
71 | + if ($this->module === null) { |
|
72 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
73 | + } |
|
74 | 74 | |
75 | - $tree = Validator::attributes($request)->tree(); |
|
75 | + $tree = Validator::attributes($request)->tree(); |
|
76 | 76 | |
77 | - $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
78 | - $view = $this->geoview_data_service->find($tree, $view_id, true); |
|
77 | + $view_id = Validator::attributes($request)->integer('view_id', -1); |
|
78 | + $view = $this->geoview_data_service->find($tree, $view_id, true); |
|
79 | 79 | |
80 | - if ($view === null) { |
|
81 | - throw new HttpNotFoundException( |
|
82 | - I18N::translate('The geographical dispersion analysis view could not be found.') |
|
83 | - ); |
|
84 | - } |
|
80 | + if ($view === null) { |
|
81 | + throw new HttpNotFoundException( |
|
82 | + I18N::translate('The geographical dispersion analysis view could not be found.') |
|
83 | + ); |
|
84 | + } |
|
85 | 85 | |
86 | - return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [ |
|
87 | - 'module' => $this->module, |
|
88 | - 'title' => I18N::translate('Add a map configuration'), |
|
89 | - 'tree' => $tree, |
|
90 | - 'view_id' => $view_id, |
|
91 | - 'map_adapter' => null, |
|
92 | - 'maps_list' => $this->map_definition_service->all(), |
|
93 | - 'mappers_list' => $this->place_mapper_service->all(), |
|
94 | - 'route_edit' => route(MapAdapterAddAction::class, [ |
|
95 | - 'tree' => $tree->name(), |
|
96 | - 'view_id' => $view_id |
|
97 | - ]) |
|
98 | - ]); |
|
99 | - } |
|
86 | + return $this->viewResponse($this->module->name() . '::admin/map-adapter-edit', [ |
|
87 | + 'module' => $this->module, |
|
88 | + 'title' => I18N::translate('Add a map configuration'), |
|
89 | + 'tree' => $tree, |
|
90 | + 'view_id' => $view_id, |
|
91 | + 'map_adapter' => null, |
|
92 | + 'maps_list' => $this->map_definition_service->all(), |
|
93 | + 'mappers_list' => $this->place_mapper_service->all(), |
|
94 | + 'route_edit' => route(MapAdapterAddAction::class, [ |
|
95 | + 'tree' => $tree->name(), |
|
96 | + 'view_id' => $view_id |
|
97 | + ]) |
|
98 | + ]); |
|
99 | + } |
|
100 | 100 | } |
@@ -31,69 +31,69 @@ |
||
31 | 31 | */ |
32 | 32 | class MapAdapterDeleteAction implements RequestHandlerInterface |
33 | 33 | { |
34 | - private ?GeoDispersionModule $module; |
|
35 | - private MapAdapterDataService $mapadapter_data_service; |
|
34 | + private ?GeoDispersionModule $module; |
|
35 | + private MapAdapterDataService $mapadapter_data_service; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor for MapAdapterDeleteAction Request Handler |
|
39 | - * |
|
40 | - * @param ModuleService $module_service |
|
41 | - * @param MapAdapterDataService $mapadapter_data_service |
|
42 | - */ |
|
43 | - public function __construct(ModuleService $module_service, MapAdapterDataService $mapadapter_data_service) |
|
44 | - { |
|
45 | - $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
46 | - $this->mapadapter_data_service = $mapadapter_data_service; |
|
47 | - } |
|
37 | + /** |
|
38 | + * Constructor for MapAdapterDeleteAction Request Handler |
|
39 | + * |
|
40 | + * @param ModuleService $module_service |
|
41 | + * @param MapAdapterDataService $mapadapter_data_service |
|
42 | + */ |
|
43 | + public function __construct(ModuleService $module_service, MapAdapterDataService $mapadapter_data_service) |
|
44 | + { |
|
45 | + $this->module = $module_service->findByInterface(GeoDispersionModule::class)->first(); |
|
46 | + $this->mapadapter_data_service = $mapadapter_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 = Validator::attributes($request)->tree(); |
|
49 | + /** |
|
50 | + * {@inheritDoc} |
|
51 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
52 | + */ |
|
53 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
54 | + { |
|
55 | + $tree = Validator::attributes($request)->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 | - $adapter_id = Validator::attributes($request)->integer('adapter_id', -1); |
|
68 | - $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
67 | + $adapter_id = Validator::attributes($request)->integer('adapter_id', -1); |
|
68 | + $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
69 | 69 | |
70 | - if ($map_adapter === null) { |
|
71 | - FlashMessages::addMessage( |
|
72 | - I18N::translate('The map configuration with ID “%d” does not exist.', I18N::number($adapter_id)), |
|
73 | - 'danger' |
|
74 | - ); |
|
75 | - return redirect($admin_config_route); |
|
76 | - } |
|
70 | + if ($map_adapter === null) { |
|
71 | + FlashMessages::addMessage( |
|
72 | + I18N::translate('The map configuration with ID “%d” does not exist.', I18N::number($adapter_id)), |
|
73 | + 'danger' |
|
74 | + ); |
|
75 | + return redirect($admin_config_route); |
|
76 | + } |
|
77 | 77 | |
78 | - if ($this->mapadapter_data_service->delete($map_adapter) > 0) { |
|
79 | - FlashMessages::addMessage( |
|
80 | - I18N::translate('The map configuration has been successfully deleted.'), |
|
81 | - 'success' |
|
82 | - ); |
|
83 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
84 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been deleted.'); |
|
85 | - } else { |
|
86 | - FlashMessages::addMessage( |
|
87 | - I18N::translate('An error occured while deleting the map configuration.'), |
|
88 | - 'danger' |
|
89 | - ); |
|
90 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
91 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” could not be deleted. See error log.'); |
|
92 | - } |
|
78 | + if ($this->mapadapter_data_service->delete($map_adapter) > 0) { |
|
79 | + FlashMessages::addMessage( |
|
80 | + I18N::translate('The map configuration has been successfully deleted.'), |
|
81 | + 'success' |
|
82 | + ); |
|
83 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
84 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been deleted.'); |
|
85 | + } else { |
|
86 | + FlashMessages::addMessage( |
|
87 | + I18N::translate('An error occured while deleting the map configuration.'), |
|
88 | + 'danger' |
|
89 | + ); |
|
90 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
91 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” could not be deleted. See error log.'); |
|
92 | + } |
|
93 | 93 | |
94 | - return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
95 | - 'tree' => $tree->name(), |
|
96 | - 'view_id' => $map_adapter->geoAnalysisViewId() |
|
97 | - ])); |
|
98 | - } |
|
94 | + return redirect(route(GeoAnalysisViewEditPage::class, [ |
|
95 | + 'tree' => $tree->name(), |
|
96 | + 'view_id' => $map_adapter->geoAnalysisViewId() |
|
97 | + ])); |
|
98 | + } |
|
99 | 99 | } |