@@ -31,67 +31,67 @@ |
||
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 | - if ($this->module === null) { |
|
58 | - FlashMessages::addMessage( |
|
59 | - I18N::translate('The attached module could not be found.'), |
|
60 | - 'danger' |
|
61 | - ); |
|
62 | - return Registry::responseFactory()->redirect(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
63 | - } |
|
57 | + if ($this->module === null) { |
|
58 | + FlashMessages::addMessage( |
|
59 | + I18N::translate('The attached module could not be found.'), |
|
60 | + 'danger' |
|
61 | + ); |
|
62 | + return Registry::responseFactory()->redirect(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
63 | + } |
|
64 | 64 | |
65 | - $adapter_id = Validator::attributes($request)->integer('adapter_id', -1); |
|
66 | - $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
65 | + $adapter_id = Validator::attributes($request)->integer('adapter_id', -1); |
|
66 | + $map_adapter = $this->mapadapter_data_service->find($adapter_id); |
|
67 | 67 | |
68 | - if ($map_adapter === null) { |
|
69 | - FlashMessages::addMessage( |
|
70 | - I18N::translate('The map configuration with ID “%s” does not exist.', I18N::number($adapter_id)), |
|
71 | - 'danger' |
|
72 | - ); |
|
73 | - return Registry::responseFactory()->redirect(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
74 | - } |
|
68 | + if ($map_adapter === null) { |
|
69 | + FlashMessages::addMessage( |
|
70 | + I18N::translate('The map configuration with ID “%s” does not exist.', I18N::number($adapter_id)), |
|
71 | + 'danger' |
|
72 | + ); |
|
73 | + return Registry::responseFactory()->redirect(AdminConfigPage::class, ['tree' => $tree->name()]); |
|
74 | + } |
|
75 | 75 | |
76 | - if ($this->mapadapter_data_service->delete($map_adapter) > 0) { |
|
77 | - FlashMessages::addMessage( |
|
78 | - I18N::translate('The map configuration has been successfully deleted.'), |
|
79 | - 'success' |
|
80 | - ); |
|
81 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
82 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been deleted.'); |
|
83 | - } else { |
|
84 | - FlashMessages::addMessage( |
|
85 | - I18N::translate('An error occured while deleting the map configuration.'), |
|
86 | - 'danger' |
|
87 | - ); |
|
88 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
89 | - Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” could not be deleted. See error log.'); |
|
90 | - } |
|
76 | + if ($this->mapadapter_data_service->delete($map_adapter) > 0) { |
|
77 | + FlashMessages::addMessage( |
|
78 | + I18N::translate('The map configuration has been successfully deleted.'), |
|
79 | + 'success' |
|
80 | + ); |
|
81 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
82 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” has been deleted.'); |
|
83 | + } else { |
|
84 | + FlashMessages::addMessage( |
|
85 | + I18N::translate('An error occured while deleting the map configuration.'), |
|
86 | + 'danger' |
|
87 | + ); |
|
88 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
89 | + Log::addConfigurationLog('Module ' . $this->module->title() . ' : Map Adapter “' . $map_adapter->id() . '” could not be deleted. See error log.'); |
|
90 | + } |
|
91 | 91 | |
92 | - return Registry::responseFactory()->redirect(GeoAnalysisViewEditPage::class, [ |
|
93 | - 'tree' => $tree->name(), |
|
94 | - 'view_id' => $map_adapter->geoAnalysisViewId() |
|
95 | - ]); |
|
96 | - } |
|
92 | + return Registry::responseFactory()->redirect(GeoAnalysisViewEditPage::class, [ |
|
93 | + 'tree' => $tree->name(), |
|
94 | + 'view_id' => $map_adapter->geoAnalysisViewId() |
|
95 | + ]); |
|
96 | + } |
|
97 | 97 | } |
@@ -59,188 +59,188 @@ |
||
59 | 59 | * Geographical Dispersion Module. |
60 | 60 | */ |
61 | 61 | class GeoDispersionModule extends AbstractModule implements |
62 | - ModuleMyArtJaubInterface, |
|
63 | - ModuleChartInterface, |
|
64 | - ModuleConfigInterface, |
|
65 | - ModuleGlobalInterface, |
|
66 | - ModuleGeoAnalysisProviderInterface, |
|
67 | - ModulePlaceMapperProviderInterface |
|
62 | + ModuleMyArtJaubInterface, |
|
63 | + ModuleChartInterface, |
|
64 | + ModuleConfigInterface, |
|
65 | + ModuleGlobalInterface, |
|
66 | + ModuleGeoAnalysisProviderInterface, |
|
67 | + ModulePlaceMapperProviderInterface |
|
68 | 68 | { |
69 | - use ModuleMyArtJaubTrait { |
|
70 | - boot as traitBoot; |
|
71 | - } |
|
72 | - use ModuleChartTrait; |
|
73 | - use ModuleConfigTrait; |
|
74 | - use ModuleGlobalTrait; |
|
75 | - |
|
76 | - // How to update the database schema for this module |
|
77 | - private const SCHEMA_TARGET_VERSION = 3; |
|
78 | - private const SCHEMA_SETTING_NAME = 'MAJ_GEODISP_SCHEMA_VERSION'; |
|
79 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
80 | - |
|
81 | - /** |
|
82 | - * {@inheritDoc} |
|
83 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
84 | - */ |
|
85 | - public function title(): string |
|
86 | - { |
|
87 | - return /* I18N: Name of the “GeoDispersion” module */ I18N::translate('Geographical dispersion'); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * {@inheritDoc} |
|
92 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
93 | - */ |
|
94 | - public function description(): string |
|
95 | - { |
|
96 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
97 | - return /* I18N: Description of the “GeoDispersion” module */ I18N::translate('Perform and display geographical dispersion analyses.'); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * {@inheritDoc} |
|
102 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
103 | - */ |
|
104 | - public function boot(): void |
|
105 | - { |
|
106 | - $this->traitBoot(); |
|
107 | - app(MigrationService::class)->updateSchema( |
|
108 | - self::SCHEMA_MIGRATION_PREFIX, |
|
109 | - self::SCHEMA_SETTING_NAME, |
|
110 | - self::SCHEMA_TARGET_VERSION |
|
111 | - ); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * {@inheritDoc} |
|
116 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
117 | - */ |
|
118 | - public function customModuleVersion(): string |
|
119 | - { |
|
120 | - return '2.1.3-v.2'; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * {@inheritDoc} |
|
125 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
126 | - */ |
|
127 | - public function loadRoutes(Map $router): void |
|
128 | - { |
|
129 | - $router->attach('', '', static function (Map $router): void { |
|
130 | - |
|
131 | - $router->attach('', '/module-maj/geodispersion', static function (Map $router): void { |
|
132 | - $router->attach('', '/admin', static function (Map $router): void { |
|
133 | - $router->get(AdminConfigPage::class, '/config{/tree}', AdminConfigPage::class); |
|
134 | - |
|
135 | - $router->attach('', '/analysis-views/{tree}', static function (Map $router): void { |
|
136 | - $router->tokens(['view_id' => '\d+', 'enable' => '[01]']); |
|
137 | - $router->extras([ |
|
138 | - 'middleware' => [ |
|
139 | - AuthManager::class, |
|
140 | - ], |
|
141 | - ]); |
|
142 | - $router->get(GeoAnalysisViewListData::class, '', GeoAnalysisViewListData::class); |
|
143 | - |
|
144 | - $router->get(GeoAnalysisViewAddPage::class, '/add', GeoAnalysisViewAddPage::class); |
|
145 | - $router->post(GeoAnalysisViewAddAction::class, '/add', GeoAnalysisViewAddAction::class); |
|
146 | - $router->get(GeoAnalysisViewEditPage::class, '/{view_id}', GeoAnalysisViewEditPage::class); |
|
147 | - $router->post(GeoAnalysisViewEditAction::class, '/{view_id}', GeoAnalysisViewEditAction::class); |
|
148 | - //phpcs:disable Generic.Files.LineLength.TooLong |
|
149 | - $router->get(GeoAnalysisViewStatusAction::class, '/{view_id}/status/{enable}', GeoAnalysisViewStatusAction::class); |
|
150 | - $router->get(GeoAnalysisViewDeleteAction::class, '/{view_id}/delete', GeoAnalysisViewDeleteAction::class); |
|
151 | - //phpcs:enable |
|
152 | - }); |
|
153 | - |
|
154 | - $router->attach('', '/map-adapters/{tree}', static function (Map $router): void { |
|
155 | - $router->tokens(['adapter_id' => '\d+', 'view_id' => '\d+']); |
|
156 | - $router->extras([ |
|
157 | - 'middleware' => [ |
|
158 | - AuthManager::class, |
|
159 | - ], |
|
160 | - ]); |
|
161 | - |
|
162 | - $router->get(MapAdapterAddPage::class, '/add/{view_id}', MapAdapterAddPage::class); |
|
163 | - $router->post(MapAdapterAddAction::class, '/add/{view_id}', MapAdapterAddAction::class); |
|
164 | - $router->get(MapAdapterEditPage::class, '/{adapter_id}', MapAdapterEditPage::class); |
|
165 | - $router->post(MapAdapterEditAction::class, '/{adapter_id}', MapAdapterEditAction::class); |
|
166 | - //phpcs:disable Generic.Files.LineLength.TooLong |
|
167 | - $router->get(MapAdapterDeleteAction::class, '/{adapter_id}/delete', MapAdapterDeleteAction::class); |
|
168 | - $router->get(MapAdapterDeleteInvalidAction::class, '/delete-invalid/{view_id}', MapAdapterDeleteInvalidAction::class); |
|
169 | - $router->get(MapAdapterMapperConfig::class, '/mapper/config{/adapter_id}', MapAdapterMapperConfig::class); |
|
170 | - //phpcs:enable |
|
171 | - }); |
|
172 | - |
|
173 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
174 | - $router->get(MapFeaturePropertyData::class, '/map/feature-properties{/map_id}', MapFeaturePropertyData::class); |
|
175 | - }); |
|
176 | - |
|
177 | - $router->get(GeoAnalysisViewsList::class, '/list/{tree}', GeoAnalysisViewsList::class); |
|
178 | - |
|
179 | - $router->attach('', '/analysisview/{tree}/{view_id}', static function (Map $router): void { |
|
180 | - $router->tokens(['view_id' => '\d+']); |
|
181 | - $router->get(GeoAnalysisViewPage::class, '', GeoAnalysisViewPage::class); |
|
182 | - $router->get(GeoAnalysisViewTabs::class, '/tabs', GeoAnalysisViewTabs::class); |
|
183 | - }); |
|
184 | - }); |
|
185 | - }); |
|
186 | - } |
|
187 | - |
|
188 | - public function getConfigLink(): string |
|
189 | - { |
|
190 | - return route(AdminConfigPage::class); |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * {@inheritDoc} |
|
195 | - * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartUrl() |
|
196 | - * |
|
197 | - * @param array<bool|int|string|array<mixed>|null> $parameters |
|
198 | - */ |
|
199 | - public function chartUrl(Individual $individual, array $parameters = []): string |
|
200 | - { |
|
201 | - return route(GeoAnalysisViewsList::class, ['tree' => $individual->tree()->name()] + $parameters); |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * {@inheritDoc} |
|
206 | - * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartMenuClass() |
|
207 | - */ |
|
208 | - public function chartMenuClass(): string |
|
209 | - { |
|
210 | - return 'menu-maj-geodispersion'; |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * {@inheritDoc} |
|
215 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
216 | - */ |
|
217 | - public function headContent(): string |
|
218 | - { |
|
219 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * {@inheritDoc} |
|
224 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModulePlaceMapperProviderInterface::listPlaceMappers() |
|
225 | - */ |
|
226 | - public function listPlaceMappers(): array |
|
227 | - { |
|
228 | - return [ |
|
229 | - CoordinatesPlaceMapper::class, |
|
230 | - SimplePlaceMapper::class, |
|
231 | - SimpleTopFilteredPlaceMapper::class |
|
232 | - ]; |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * {@inheritDoc} |
|
237 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface::listGeoAnalyses() |
|
238 | - */ |
|
239 | - public function listGeoAnalyses(): array |
|
240 | - { |
|
241 | - return [ |
|
242 | - AllEventsByCenturyGeoAnalysis::class, |
|
243 | - AllEventsByTypeGeoAnalysis::class |
|
244 | - ]; |
|
245 | - } |
|
69 | + use ModuleMyArtJaubTrait { |
|
70 | + boot as traitBoot; |
|
71 | + } |
|
72 | + use ModuleChartTrait; |
|
73 | + use ModuleConfigTrait; |
|
74 | + use ModuleGlobalTrait; |
|
75 | + |
|
76 | + // How to update the database schema for this module |
|
77 | + private const SCHEMA_TARGET_VERSION = 3; |
|
78 | + private const SCHEMA_SETTING_NAME = 'MAJ_GEODISP_SCHEMA_VERSION'; |
|
79 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
80 | + |
|
81 | + /** |
|
82 | + * {@inheritDoc} |
|
83 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
84 | + */ |
|
85 | + public function title(): string |
|
86 | + { |
|
87 | + return /* I18N: Name of the “GeoDispersion” module */ I18N::translate('Geographical dispersion'); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * {@inheritDoc} |
|
92 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
93 | + */ |
|
94 | + public function description(): string |
|
95 | + { |
|
96 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
97 | + return /* I18N: Description of the “GeoDispersion” module */ I18N::translate('Perform and display geographical dispersion analyses.'); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * {@inheritDoc} |
|
102 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
103 | + */ |
|
104 | + public function boot(): void |
|
105 | + { |
|
106 | + $this->traitBoot(); |
|
107 | + app(MigrationService::class)->updateSchema( |
|
108 | + self::SCHEMA_MIGRATION_PREFIX, |
|
109 | + self::SCHEMA_SETTING_NAME, |
|
110 | + self::SCHEMA_TARGET_VERSION |
|
111 | + ); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * {@inheritDoc} |
|
116 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
117 | + */ |
|
118 | + public function customModuleVersion(): string |
|
119 | + { |
|
120 | + return '2.1.3-v.2'; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * {@inheritDoc} |
|
125 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
126 | + */ |
|
127 | + public function loadRoutes(Map $router): void |
|
128 | + { |
|
129 | + $router->attach('', '', static function (Map $router): void { |
|
130 | + |
|
131 | + $router->attach('', '/module-maj/geodispersion', static function (Map $router): void { |
|
132 | + $router->attach('', '/admin', static function (Map $router): void { |
|
133 | + $router->get(AdminConfigPage::class, '/config{/tree}', AdminConfigPage::class); |
|
134 | + |
|
135 | + $router->attach('', '/analysis-views/{tree}', static function (Map $router): void { |
|
136 | + $router->tokens(['view_id' => '\d+', 'enable' => '[01]']); |
|
137 | + $router->extras([ |
|
138 | + 'middleware' => [ |
|
139 | + AuthManager::class, |
|
140 | + ], |
|
141 | + ]); |
|
142 | + $router->get(GeoAnalysisViewListData::class, '', GeoAnalysisViewListData::class); |
|
143 | + |
|
144 | + $router->get(GeoAnalysisViewAddPage::class, '/add', GeoAnalysisViewAddPage::class); |
|
145 | + $router->post(GeoAnalysisViewAddAction::class, '/add', GeoAnalysisViewAddAction::class); |
|
146 | + $router->get(GeoAnalysisViewEditPage::class, '/{view_id}', GeoAnalysisViewEditPage::class); |
|
147 | + $router->post(GeoAnalysisViewEditAction::class, '/{view_id}', GeoAnalysisViewEditAction::class); |
|
148 | + //phpcs:disable Generic.Files.LineLength.TooLong |
|
149 | + $router->get(GeoAnalysisViewStatusAction::class, '/{view_id}/status/{enable}', GeoAnalysisViewStatusAction::class); |
|
150 | + $router->get(GeoAnalysisViewDeleteAction::class, '/{view_id}/delete', GeoAnalysisViewDeleteAction::class); |
|
151 | + //phpcs:enable |
|
152 | + }); |
|
153 | + |
|
154 | + $router->attach('', '/map-adapters/{tree}', static function (Map $router): void { |
|
155 | + $router->tokens(['adapter_id' => '\d+', 'view_id' => '\d+']); |
|
156 | + $router->extras([ |
|
157 | + 'middleware' => [ |
|
158 | + AuthManager::class, |
|
159 | + ], |
|
160 | + ]); |
|
161 | + |
|
162 | + $router->get(MapAdapterAddPage::class, '/add/{view_id}', MapAdapterAddPage::class); |
|
163 | + $router->post(MapAdapterAddAction::class, '/add/{view_id}', MapAdapterAddAction::class); |
|
164 | + $router->get(MapAdapterEditPage::class, '/{adapter_id}', MapAdapterEditPage::class); |
|
165 | + $router->post(MapAdapterEditAction::class, '/{adapter_id}', MapAdapterEditAction::class); |
|
166 | + //phpcs:disable Generic.Files.LineLength.TooLong |
|
167 | + $router->get(MapAdapterDeleteAction::class, '/{adapter_id}/delete', MapAdapterDeleteAction::class); |
|
168 | + $router->get(MapAdapterDeleteInvalidAction::class, '/delete-invalid/{view_id}', MapAdapterDeleteInvalidAction::class); |
|
169 | + $router->get(MapAdapterMapperConfig::class, '/mapper/config{/adapter_id}', MapAdapterMapperConfig::class); |
|
170 | + //phpcs:enable |
|
171 | + }); |
|
172 | + |
|
173 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
174 | + $router->get(MapFeaturePropertyData::class, '/map/feature-properties{/map_id}', MapFeaturePropertyData::class); |
|
175 | + }); |
|
176 | + |
|
177 | + $router->get(GeoAnalysisViewsList::class, '/list/{tree}', GeoAnalysisViewsList::class); |
|
178 | + |
|
179 | + $router->attach('', '/analysisview/{tree}/{view_id}', static function (Map $router): void { |
|
180 | + $router->tokens(['view_id' => '\d+']); |
|
181 | + $router->get(GeoAnalysisViewPage::class, '', GeoAnalysisViewPage::class); |
|
182 | + $router->get(GeoAnalysisViewTabs::class, '/tabs', GeoAnalysisViewTabs::class); |
|
183 | + }); |
|
184 | + }); |
|
185 | + }); |
|
186 | + } |
|
187 | + |
|
188 | + public function getConfigLink(): string |
|
189 | + { |
|
190 | + return route(AdminConfigPage::class); |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * {@inheritDoc} |
|
195 | + * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartUrl() |
|
196 | + * |
|
197 | + * @param array<bool|int|string|array<mixed>|null> $parameters |
|
198 | + */ |
|
199 | + public function chartUrl(Individual $individual, array $parameters = []): string |
|
200 | + { |
|
201 | + return route(GeoAnalysisViewsList::class, ['tree' => $individual->tree()->name()] + $parameters); |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * {@inheritDoc} |
|
206 | + * @see \Fisharebest\Webtrees\Module\ModuleChartInterface::chartMenuClass() |
|
207 | + */ |
|
208 | + public function chartMenuClass(): string |
|
209 | + { |
|
210 | + return 'menu-maj-geodispersion'; |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * {@inheritDoc} |
|
215 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
216 | + */ |
|
217 | + public function headContent(): string |
|
218 | + { |
|
219 | + return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * {@inheritDoc} |
|
224 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModulePlaceMapperProviderInterface::listPlaceMappers() |
|
225 | + */ |
|
226 | + public function listPlaceMappers(): array |
|
227 | + { |
|
228 | + return [ |
|
229 | + CoordinatesPlaceMapper::class, |
|
230 | + SimplePlaceMapper::class, |
|
231 | + SimpleTopFilteredPlaceMapper::class |
|
232 | + ]; |
|
233 | + } |
|
234 | + |
|
235 | + /** |
|
236 | + * {@inheritDoc} |
|
237 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\ModuleGeoAnalysisProviderInterface::listGeoAnalyses() |
|
238 | + */ |
|
239 | + public function listGeoAnalyses(): array |
|
240 | + { |
|
241 | + return [ |
|
242 | + AllEventsByCenturyGeoAnalysis::class, |
|
243 | + AllEventsByTypeGeoAnalysis::class |
|
244 | + ]; |
|
245 | + } |
|
246 | 246 | } |
@@ -26,64 +26,64 @@ |
||
26 | 26 | */ |
27 | 27 | class GeoAnalysisDataService |
28 | 28 | { |
29 | - /** |
|
30 | - * Yields indviduals and family records for a specified tree. |
|
31 | - * |
|
32 | - * @param Tree $tree |
|
33 | - * @return \Generator<\Fisharebest\Webtrees\GedcomRecord> |
|
34 | - */ |
|
35 | - public function individualsAndFamilies(Tree $tree): Generator |
|
36 | - { |
|
37 | - yield from DB::table('individuals') |
|
38 | - ->where('i_file', '=', $tree->id()) |
|
39 | - ->select(['individuals.*']) |
|
40 | - ->get() |
|
41 | - ->map(Registry::individualFactory()->mapper($tree)) |
|
42 | - ->filter(GedcomRecord::accessFilter()) |
|
43 | - ->all(); |
|
29 | + /** |
|
30 | + * Yields indviduals and family records for a specified tree. |
|
31 | + * |
|
32 | + * @param Tree $tree |
|
33 | + * @return \Generator<\Fisharebest\Webtrees\GedcomRecord> |
|
34 | + */ |
|
35 | + public function individualsAndFamilies(Tree $tree): Generator |
|
36 | + { |
|
37 | + yield from DB::table('individuals') |
|
38 | + ->where('i_file', '=', $tree->id()) |
|
39 | + ->select(['individuals.*']) |
|
40 | + ->get() |
|
41 | + ->map(Registry::individualFactory()->mapper($tree)) |
|
42 | + ->filter(GedcomRecord::accessFilter()) |
|
43 | + ->all(); |
|
44 | 44 | |
45 | - yield from DB::table('families') |
|
46 | - ->where('f_file', '=', $tree->id()) |
|
47 | - ->select(['families.*']) |
|
48 | - ->get() |
|
49 | - ->map(Registry::familyFactory()->mapper($tree)) |
|
50 | - ->filter(GedcomRecord::accessFilter()) |
|
51 | - ->all(); |
|
52 | - } |
|
45 | + yield from DB::table('families') |
|
46 | + ->where('f_file', '=', $tree->id()) |
|
47 | + ->select(['families.*']) |
|
48 | + ->get() |
|
49 | + ->map(Registry::familyFactory()->mapper($tree)) |
|
50 | + ->filter(GedcomRecord::accessFilter()) |
|
51 | + ->all(); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Returns an example of the place hierarchy, from a place within the GEDCOM file, looking for the deepest |
|
56 | - * hierarchy found. The part order is reversed compared to the normal GEDCOM structure (largest first). |
|
57 | - * |
|
58 | - * {@internal The places are taken only from the individuals and families records.} |
|
59 | - * |
|
60 | - * @param Tree $tree |
|
61 | - * @return array<int, string[]> |
|
62 | - */ |
|
63 | - public function placeHierarchyExample(Tree $tree): array |
|
64 | - { |
|
65 | - $query_individuals = DB::table('individuals') |
|
66 | - ->select(['i_gedcom AS g_gedcom']) |
|
67 | - ->where('i_file', '=', $tree->id()) |
|
68 | - ->where('i_gedcom', 'like', '%2 PLAC %'); |
|
54 | + /** |
|
55 | + * Returns an example of the place hierarchy, from a place within the GEDCOM file, looking for the deepest |
|
56 | + * hierarchy found. The part order is reversed compared to the normal GEDCOM structure (largest first). |
|
57 | + * |
|
58 | + * {@internal The places are taken only from the individuals and families records.} |
|
59 | + * |
|
60 | + * @param Tree $tree |
|
61 | + * @return array<int, string[]> |
|
62 | + */ |
|
63 | + public function placeHierarchyExample(Tree $tree): array |
|
64 | + { |
|
65 | + $query_individuals = DB::table('individuals') |
|
66 | + ->select(['i_gedcom AS g_gedcom']) |
|
67 | + ->where('i_file', '=', $tree->id()) |
|
68 | + ->where('i_gedcom', 'like', '%2 PLAC %'); |
|
69 | 69 | |
70 | - $query_families = DB::table('families') |
|
71 | - ->select(['f_gedcom AS g_gedcom']) |
|
72 | - ->where('f_file', '=', $tree->id()) |
|
73 | - ->where('f_gedcom', 'like', '%2 PLAC %'); |
|
70 | + $query_families = DB::table('families') |
|
71 | + ->select(['f_gedcom AS g_gedcom']) |
|
72 | + ->where('f_file', '=', $tree->id()) |
|
73 | + ->where('f_gedcom', 'like', '%2 PLAC %'); |
|
74 | 74 | |
75 | - return $query_individuals->unionAll($query_families) |
|
76 | - ->get()->pluck('g_gedcom') |
|
77 | - ->flatMap(static function (string $gedcom): array { |
|
78 | - preg_match_all('/\n2 PLAC (.+)/', $gedcom, $matches); |
|
79 | - return $matches[1] ?? []; |
|
80 | - }) |
|
81 | - ->sort(I18N::comparator())->reverse() |
|
82 | - ->mapWithKeys(static function (string $place): array { |
|
83 | - $place_array = array_reverse(array_filter(array_map('trim', explode(",", $place)))); |
|
84 | - return [ count($place_array) => $place_array ]; |
|
85 | - }) |
|
86 | - ->sortKeys() |
|
87 | - ->last() ?? []; |
|
88 | - } |
|
75 | + return $query_individuals->unionAll($query_families) |
|
76 | + ->get()->pluck('g_gedcom') |
|
77 | + ->flatMap(static function (string $gedcom): array { |
|
78 | + preg_match_all('/\n2 PLAC (.+)/', $gedcom, $matches); |
|
79 | + return $matches[1] ?? []; |
|
80 | + }) |
|
81 | + ->sort(I18N::comparator())->reverse() |
|
82 | + ->mapWithKeys(static function (string $place): array { |
|
83 | + $place_array = array_reverse(array_filter(array_map('trim', explode(",", $place)))); |
|
84 | + return [ count($place_array) => $place_array ]; |
|
85 | + }) |
|
86 | + ->sortKeys() |
|
87 | + ->last() ?? []; |
|
88 | + } |
|
89 | 89 | } |
@@ -34,93 +34,93 @@ |
||
34 | 34 | * Provide miscellaneous improvements to webtrees. |
35 | 35 | */ |
36 | 36 | class MiscExtensionsModule extends AbstractModule implements |
37 | - ModuleMyArtJaubInterface, |
|
38 | - ModuleConfigInterface, |
|
39 | - ModuleHookSubscriberInterface |
|
37 | + ModuleMyArtJaubInterface, |
|
38 | + ModuleConfigInterface, |
|
39 | + ModuleHookSubscriberInterface |
|
40 | 40 | { |
41 | - use ModuleMyArtJaubTrait { |
|
42 | - boot as traitBoot; |
|
43 | - } |
|
44 | - use ModuleConfigTrait; |
|
45 | - |
|
46 | - /** |
|
47 | - * {@inheritDoc} |
|
48 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
49 | - */ |
|
50 | - public function title(): string |
|
51 | - { |
|
52 | - return /* I18N: Name of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions'); |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * {@inheritDoc} |
|
57 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
58 | - */ |
|
59 | - public function description(): string |
|
60 | - { |
|
61 | - //phpcs:ignore Generic.Files.LineLength.TooLong |
|
62 | - return /* I18N: Description of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions for webtrees.'); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * {@inheritDoc} |
|
67 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
68 | - */ |
|
69 | - public function boot(): void |
|
70 | - { |
|
71 | - $this->traitBoot(); |
|
72 | - View::registerCustomView('::modules/privacy-policy/page', $this->name() . '::privacy-policy'); |
|
73 | - |
|
74 | - if ((int) $this->getPreference('MAJ_USE_LEGACY_XREF') === 1) { |
|
75 | - Registry::xrefFactory(new LegacyXrefFactory()); |
|
76 | - } |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * {@inheritDoc} |
|
81 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
82 | - */ |
|
83 | - public function loadRoutes(Map $router): void |
|
84 | - { |
|
85 | - $router->attach('', '', static function (Map $router): void { |
|
86 | - |
|
87 | - $router->attach('', '/module-maj/misc', static function (Map $router): void { |
|
88 | - |
|
89 | - $router->attach('', '/config/admin', static function (Map $router): void { |
|
90 | - |
|
91 | - $router->get(AdminConfigPage::class, '', AdminConfigPage::class); |
|
92 | - $router->post(AdminConfigAction::class, '', AdminConfigAction::class); |
|
93 | - }); |
|
94 | - }); |
|
95 | - }); |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * {@inheritDoc} |
|
100 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
101 | - */ |
|
102 | - public function customModuleVersion(): string |
|
103 | - { |
|
104 | - return '2.1.3-v.2'; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * {@inheritDoc} |
|
109 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
110 | - */ |
|
111 | - public function getConfigLink(): string |
|
112 | - { |
|
113 | - return route(AdminConfigPage::class); |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * {@inheritDoc} |
|
118 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks() |
|
119 | - */ |
|
120 | - public function listSubscribedHooks(): array |
|
121 | - { |
|
122 | - return [ |
|
123 | - app()->makeWith(TitlesCardHook::class, [ 'module' => $this ]) |
|
124 | - ]; |
|
125 | - } |
|
41 | + use ModuleMyArtJaubTrait { |
|
42 | + boot as traitBoot; |
|
43 | + } |
|
44 | + use ModuleConfigTrait; |
|
45 | + |
|
46 | + /** |
|
47 | + * {@inheritDoc} |
|
48 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
49 | + */ |
|
50 | + public function title(): string |
|
51 | + { |
|
52 | + return /* I18N: Name of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions'); |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * {@inheritDoc} |
|
57 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
58 | + */ |
|
59 | + public function description(): string |
|
60 | + { |
|
61 | + //phpcs:ignore Generic.Files.LineLength.TooLong |
|
62 | + return /* I18N: Description of the “MiscExtensions” module */ I18N::translate('Miscellaneous extensions for webtrees.'); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * {@inheritDoc} |
|
67 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
68 | + */ |
|
69 | + public function boot(): void |
|
70 | + { |
|
71 | + $this->traitBoot(); |
|
72 | + View::registerCustomView('::modules/privacy-policy/page', $this->name() . '::privacy-policy'); |
|
73 | + |
|
74 | + if ((int) $this->getPreference('MAJ_USE_LEGACY_XREF') === 1) { |
|
75 | + Registry::xrefFactory(new LegacyXrefFactory()); |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * {@inheritDoc} |
|
81 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
82 | + */ |
|
83 | + public function loadRoutes(Map $router): void |
|
84 | + { |
|
85 | + $router->attach('', '', static function (Map $router): void { |
|
86 | + |
|
87 | + $router->attach('', '/module-maj/misc', static function (Map $router): void { |
|
88 | + |
|
89 | + $router->attach('', '/config/admin', static function (Map $router): void { |
|
90 | + |
|
91 | + $router->get(AdminConfigPage::class, '', AdminConfigPage::class); |
|
92 | + $router->post(AdminConfigAction::class, '', AdminConfigAction::class); |
|
93 | + }); |
|
94 | + }); |
|
95 | + }); |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * {@inheritDoc} |
|
100 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
101 | + */ |
|
102 | + public function customModuleVersion(): string |
|
103 | + { |
|
104 | + return '2.1.3-v.2'; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * {@inheritDoc} |
|
109 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
110 | + */ |
|
111 | + public function getConfigLink(): string |
|
112 | + { |
|
113 | + return route(AdminConfigPage::class); |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * {@inheritDoc} |
|
118 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks() |
|
119 | + */ |
|
120 | + public function listSubscribedHooks(): array |
|
121 | + { |
|
122 | + return [ |
|
123 | + app()->makeWith(TitlesCardHook::class, [ 'module' => $this ]) |
|
124 | + ]; |
|
125 | + } |
|
126 | 126 | } |
@@ -23,67 +23,67 @@ |
||
23 | 23 | */ |
24 | 24 | class LegacyXrefFactory extends XrefFactory |
25 | 25 | { |
26 | - protected const TYPE_TO_PREFIX = [ |
|
27 | - 'INDI' => 'I', |
|
28 | - 'FAM' => 'F', |
|
29 | - 'OBJE' => 'M', |
|
30 | - 'NOTE' => 'N', |
|
31 | - 'SOUR' => 'S', |
|
32 | - 'REPO' => 'R', |
|
33 | - ]; |
|
26 | + protected const TYPE_TO_PREFIX = [ |
|
27 | + 'INDI' => 'I', |
|
28 | + 'FAM' => 'F', |
|
29 | + 'OBJE' => 'M', |
|
30 | + 'NOTE' => 'N', |
|
31 | + 'SOUR' => 'S', |
|
32 | + 'REPO' => 'R', |
|
33 | + ]; |
|
34 | 34 | |
35 | - /** |
|
36 | - * {@inheritDoc} |
|
37 | - * @see \Fisharebest\Webtrees\Factories\XrefFactory::make() |
|
38 | - */ |
|
39 | - public function make(string $record_type): string |
|
40 | - { |
|
41 | - $prefix = static::TYPE_TO_PREFIX[$record_type] ?? 'X'; |
|
35 | + /** |
|
36 | + * {@inheritDoc} |
|
37 | + * @see \Fisharebest\Webtrees\Factories\XrefFactory::make() |
|
38 | + */ |
|
39 | + public function make(string $record_type): string |
|
40 | + { |
|
41 | + $prefix = static::TYPE_TO_PREFIX[$record_type] ?? 'X'; |
|
42 | 42 | |
43 | - return $this->generate($prefix, ''); |
|
44 | - } |
|
43 | + return $this->generate($prefix, ''); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * {@inheritDoc} |
|
48 | - * @see \Fisharebest\Webtrees\Factories\XrefFactory::generate() |
|
49 | - */ |
|
50 | - protected function generate($prefix, $suffix): string |
|
51 | - { |
|
52 | - $tree = app(Tree::class); |
|
53 | - if (!$tree instanceof Tree) { |
|
54 | - return parent::generate($prefix, $suffix); |
|
55 | - } |
|
46 | + /** |
|
47 | + * {@inheritDoc} |
|
48 | + * @see \Fisharebest\Webtrees\Factories\XrefFactory::generate() |
|
49 | + */ |
|
50 | + protected function generate($prefix, $suffix): string |
|
51 | + { |
|
52 | + $tree = app(Tree::class); |
|
53 | + if (!$tree instanceof Tree) { |
|
54 | + return parent::generate($prefix, $suffix); |
|
55 | + } |
|
56 | 56 | |
57 | - $setting_name = 'MAJ_MISC_XREF_NEXT_' . $prefix; |
|
58 | - // Lock the row, so that only one new XREF may be generated at a time. |
|
59 | - DB::table('gedcom_setting') |
|
60 | - ->where('gedcom_id', '=', $tree->id()) |
|
61 | - ->where('setting_name', '=', $setting_name) |
|
62 | - ->lockForUpdate() |
|
63 | - ->get(); |
|
57 | + $setting_name = 'MAJ_MISC_XREF_NEXT_' . $prefix; |
|
58 | + // Lock the row, so that only one new XREF may be generated at a time. |
|
59 | + DB::table('gedcom_setting') |
|
60 | + ->where('gedcom_id', '=', $tree->id()) |
|
61 | + ->where('setting_name', '=', $setting_name) |
|
62 | + ->lockForUpdate() |
|
63 | + ->get(); |
|
64 | 64 | |
65 | - $increment = 1.0; |
|
66 | - do { |
|
67 | - $num = (int) $tree->getPreference($setting_name) + (int) $increment; |
|
65 | + $increment = 1.0; |
|
66 | + do { |
|
67 | + $num = (int) $tree->getPreference($setting_name) + (int) $increment; |
|
68 | 68 | |
69 | - // This exponential increment allows us to scan over large blocks of |
|
70 | - // existing data in a reasonable time. |
|
71 | - $increment *= 1.01; |
|
69 | + // This exponential increment allows us to scan over large blocks of |
|
70 | + // existing data in a reasonable time. |
|
71 | + $increment *= 1.01; |
|
72 | 72 | |
73 | - $xref = $prefix . $num . $suffix; |
|
73 | + $xref = $prefix . $num . $suffix; |
|
74 | 74 | |
75 | - // Records may already exist with this sequence number. |
|
76 | - $already_used = |
|
77 | - DB::table('individuals')->where('i_file', '=', $tree->id())->where('i_id', '=', $xref)->exists() || |
|
78 | - DB::table('families')->where('f_file', '=', $tree->id())->where('f_id', '=', $xref)->exists() || |
|
79 | - DB::table('sources')->where('s_file', '=', $tree->id())->where('s_id', '=', $xref)->exists() || |
|
80 | - DB::table('media')->where('m_file', '=', $tree->id())->where('m_id', '=', $xref)->exists() || |
|
81 | - DB::table('other')->where('o_file', '=', $tree->id())->where('o_id', '=', $xref)->exists() || |
|
82 | - DB::table('change')->where('gedcom_id', '=', $tree->id())->where('xref', '=', $xref)->exists(); |
|
83 | - } while ($already_used); |
|
75 | + // Records may already exist with this sequence number. |
|
76 | + $already_used = |
|
77 | + DB::table('individuals')->where('i_file', '=', $tree->id())->where('i_id', '=', $xref)->exists() || |
|
78 | + DB::table('families')->where('f_file', '=', $tree->id())->where('f_id', '=', $xref)->exists() || |
|
79 | + DB::table('sources')->where('s_file', '=', $tree->id())->where('s_id', '=', $xref)->exists() || |
|
80 | + DB::table('media')->where('m_file', '=', $tree->id())->where('m_id', '=', $xref)->exists() || |
|
81 | + DB::table('other')->where('o_file', '=', $tree->id())->where('o_id', '=', $xref)->exists() || |
|
82 | + DB::table('change')->where('gedcom_id', '=', $tree->id())->where('xref', '=', $xref)->exists(); |
|
83 | + } while ($already_used); |
|
84 | 84 | |
85 | - $tree->setPreference($setting_name, (string) $num); |
|
85 | + $tree->setPreference($setting_name, (string) $num); |
|
86 | 86 | |
87 | - return $xref; |
|
88 | - } |
|
87 | + return $xref; |
|
88 | + } |
|
89 | 89 | } |
@@ -29,54 +29,54 @@ |
||
29 | 29 | */ |
30 | 30 | class AdminConfigAction implements RequestHandlerInterface |
31 | 31 | { |
32 | - private ?MiscExtensionsModule $module; |
|
32 | + private ?MiscExtensionsModule $module; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Constructor for AdminConfigPage Request Handler |
|
36 | - * |
|
37 | - * @param ModuleService $module_service |
|
38 | - */ |
|
39 | - public function __construct(ModuleService $module_service) |
|
40 | - { |
|
41 | - $this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first(); |
|
42 | - } |
|
34 | + /** |
|
35 | + * Constructor for AdminConfigPage Request Handler |
|
36 | + * |
|
37 | + * @param ModuleService $module_service |
|
38 | + */ |
|
39 | + public function __construct(ModuleService $module_service) |
|
40 | + { |
|
41 | + $this->module = $module_service->findByInterface(MiscExtensionsModule::class)->first(); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * {@inheritDoc} |
|
46 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
47 | - */ |
|
48 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
49 | - { |
|
50 | - if ($this->module === null) { |
|
51 | - FlashMessages::addMessage( |
|
52 | - I18N::translate('The attached module could not be found.'), |
|
53 | - 'danger' |
|
54 | - ); |
|
55 | - return Registry::responseFactory()->redirect(AdminConfigPage::class); |
|
56 | - } |
|
44 | + /** |
|
45 | + * {@inheritDoc} |
|
46 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
47 | + */ |
|
48 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
49 | + { |
|
50 | + if ($this->module === null) { |
|
51 | + FlashMessages::addMessage( |
|
52 | + I18N::translate('The attached module could not be found.'), |
|
53 | + 'danger' |
|
54 | + ); |
|
55 | + return Registry::responseFactory()->redirect(AdminConfigPage::class); |
|
56 | + } |
|
57 | 57 | |
58 | - $this->module->setPreference( |
|
59 | - 'MAJ_TITLE_PREFIX', |
|
60 | - Validator::parsedBody($request)->string('MAJ_TITLE_PREFIX', '') |
|
61 | - ); |
|
62 | - $this->module->setPreference( |
|
63 | - 'MAJ_DISPLAY_CNIL', |
|
64 | - (string) Validator::parsedBody($request)->integer('MAJ_DISPLAY_CNIL', 0) |
|
65 | - ); |
|
66 | - $this->module->setPreference( |
|
67 | - 'MAJ_CNIL_REFERENCE', |
|
68 | - Validator::parsedBody($request)->string('MAJ_CNIL_REFERENCE', '') |
|
69 | - ); |
|
70 | - $this->module->setPreference( |
|
71 | - 'MAJ_USE_LEGACY_XREF', |
|
72 | - (string) Validator::parsedBody($request)->integer('MAJ_USE_LEGACY_XREF', 0) |
|
73 | - ); |
|
58 | + $this->module->setPreference( |
|
59 | + 'MAJ_TITLE_PREFIX', |
|
60 | + Validator::parsedBody($request)->string('MAJ_TITLE_PREFIX', '') |
|
61 | + ); |
|
62 | + $this->module->setPreference( |
|
63 | + 'MAJ_DISPLAY_CNIL', |
|
64 | + (string) Validator::parsedBody($request)->integer('MAJ_DISPLAY_CNIL', 0) |
|
65 | + ); |
|
66 | + $this->module->setPreference( |
|
67 | + 'MAJ_CNIL_REFERENCE', |
|
68 | + Validator::parsedBody($request)->string('MAJ_CNIL_REFERENCE', '') |
|
69 | + ); |
|
70 | + $this->module->setPreference( |
|
71 | + 'MAJ_USE_LEGACY_XREF', |
|
72 | + (string) Validator::parsedBody($request)->integer('MAJ_USE_LEGACY_XREF', 0) |
|
73 | + ); |
|
74 | 74 | |
75 | - FlashMessages::addMessage( |
|
76 | - I18N::translate('The preferences for the module “%s” have been updated.', $this->module->title()), |
|
77 | - 'success' |
|
78 | - ); |
|
75 | + FlashMessages::addMessage( |
|
76 | + I18N::translate('The preferences for the module “%s” have been updated.', $this->module->title()), |
|
77 | + 'success' |
|
78 | + ); |
|
79 | 79 | |
80 | - return Registry::responseFactory()->redirect(AdminConfigPage::class); |
|
81 | - } |
|
80 | + return Registry::responseFactory()->redirect(AdminConfigPage::class); |
|
81 | + } |
|
82 | 82 | } |
@@ -42,106 +42,106 @@ |
||
42 | 42 | * Provide entry points to extend core webtrees code. |
43 | 43 | */ |
44 | 44 | class HooksModule extends AbstractModule implements |
45 | - ModuleMyArtJaubInterface, |
|
46 | - ModuleConfigInterface, |
|
47 | - ModuleHookSubscriberInterface |
|
45 | + ModuleMyArtJaubInterface, |
|
46 | + ModuleConfigInterface, |
|
47 | + ModuleHookSubscriberInterface |
|
48 | 48 | { |
49 | - use ModuleMyArtJaubTrait { |
|
50 | - boot as traitBoot; |
|
51 | - } |
|
52 | - use ModuleConfigTrait; |
|
53 | - |
|
54 | - // How to update the database schema for this module |
|
55 | - private const SCHEMA_TARGET_VERSION = 2; |
|
56 | - private const SCHEMA_SETTING_NAME = 'MAJ_HOOKS_SCHEMA_VERSION'; |
|
57 | - private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
58 | - |
|
59 | - /** |
|
60 | - * {@inheritDoc} |
|
61 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
62 | - */ |
|
63 | - public function title(): string |
|
64 | - { |
|
65 | - return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks'); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * {@inheritDoc} |
|
70 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
71 | - */ |
|
72 | - public function description(): string |
|
73 | - { |
|
74 | - return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.'); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * {@inheritDoc} |
|
79 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
80 | - */ |
|
81 | - public function boot(): void |
|
82 | - { |
|
83 | - $this->traitBoot(); |
|
84 | - app()->bind(HookServiceInterface::class, HookService::class); |
|
85 | - app(MigrationService::class)->updateSchema( |
|
86 | - self::SCHEMA_MIGRATION_PREFIX, |
|
87 | - self::SCHEMA_SETTING_NAME, |
|
88 | - self::SCHEMA_TARGET_VERSION |
|
89 | - ); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * {@inheritDoc} |
|
94 | - * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
95 | - */ |
|
96 | - public function loadRoutes(Map $router): void |
|
97 | - { |
|
98 | - $router->attach('', '', static function (Map $router): void { |
|
99 | - |
|
100 | - $router->attach('', '/module-maj/hooks', static function (Map $router): void { |
|
101 | - |
|
102 | - $router->attach('', '/config/admin', static function (Map $router): void { |
|
103 | - |
|
104 | - $router->get(AdminConfigPage::class, '', AdminConfigPage::class); |
|
105 | - $router->get(ModulesHooksPage::class, '/{hook_name}', ModulesHooksPage::class); |
|
106 | - $router->post(ModulesHooksAction::class, '/{hook_name}', ModulesHooksAction::class); |
|
107 | - }); |
|
108 | - }); |
|
109 | - }); |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * {@inheritDoc} |
|
114 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
115 | - */ |
|
116 | - public function customModuleVersion(): string |
|
117 | - { |
|
118 | - return '2.1.6-v.1'; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * {@inheritDoc} |
|
123 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
124 | - */ |
|
125 | - public function getConfigLink(): string |
|
126 | - { |
|
127 | - return route(AdminConfigPage::class); |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * {@inheritDoc} |
|
132 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks() |
|
133 | - */ |
|
134 | - public function listSubscribedHooks(): array |
|
135 | - { |
|
136 | - return [ |
|
137 | - app()->makeWith(FactSourceTextExtenderCollector::class, ['module' => $this]), |
|
138 | - app()->makeWith(FamilyDatatablesExtenderCollector::class, ['module' => $this]), |
|
139 | - app()->makeWith(IndividualDatatablesExtenderCollector::class, ['module' => $this]), |
|
140 | - app()->makeWith(NameAccordionExtenderCollector::class, ['module' => $this]), |
|
141 | - app()->makeWith(RecordNameTextExtenderCollector::class, ['module' => $this]), |
|
142 | - app()->makeWith(SosaFamilyDatatablesExtenderCollector::class, ['module' => $this]), |
|
143 | - app()->makeWith(SosaIndividualDatatablesExtenderCollector::class, ['module' => $this]), |
|
144 | - app()->makeWith(SosaMissingDatatablesExtenderCollector::class, ['module' => $this]) |
|
145 | - ]; |
|
146 | - } |
|
49 | + use ModuleMyArtJaubTrait { |
|
50 | + boot as traitBoot; |
|
51 | + } |
|
52 | + use ModuleConfigTrait; |
|
53 | + |
|
54 | + // How to update the database schema for this module |
|
55 | + private const SCHEMA_TARGET_VERSION = 2; |
|
56 | + private const SCHEMA_SETTING_NAME = 'MAJ_HOOKS_SCHEMA_VERSION'; |
|
57 | + private const SCHEMA_MIGRATION_PREFIX = __NAMESPACE__ . '\Schema'; |
|
58 | + |
|
59 | + /** |
|
60 | + * {@inheritDoc} |
|
61 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
62 | + */ |
|
63 | + public function title(): string |
|
64 | + { |
|
65 | + return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks'); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * {@inheritDoc} |
|
70 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
71 | + */ |
|
72 | + public function description(): string |
|
73 | + { |
|
74 | + return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.'); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * {@inheritDoc} |
|
79 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
|
80 | + */ |
|
81 | + public function boot(): void |
|
82 | + { |
|
83 | + $this->traitBoot(); |
|
84 | + app()->bind(HookServiceInterface::class, HookService::class); |
|
85 | + app(MigrationService::class)->updateSchema( |
|
86 | + self::SCHEMA_MIGRATION_PREFIX, |
|
87 | + self::SCHEMA_SETTING_NAME, |
|
88 | + self::SCHEMA_TARGET_VERSION |
|
89 | + ); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * {@inheritDoc} |
|
94 | + * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes() |
|
95 | + */ |
|
96 | + public function loadRoutes(Map $router): void |
|
97 | + { |
|
98 | + $router->attach('', '', static function (Map $router): void { |
|
99 | + |
|
100 | + $router->attach('', '/module-maj/hooks', static function (Map $router): void { |
|
101 | + |
|
102 | + $router->attach('', '/config/admin', static function (Map $router): void { |
|
103 | + |
|
104 | + $router->get(AdminConfigPage::class, '', AdminConfigPage::class); |
|
105 | + $router->get(ModulesHooksPage::class, '/{hook_name}', ModulesHooksPage::class); |
|
106 | + $router->post(ModulesHooksAction::class, '/{hook_name}', ModulesHooksAction::class); |
|
107 | + }); |
|
108 | + }); |
|
109 | + }); |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * {@inheritDoc} |
|
114 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
115 | + */ |
|
116 | + public function customModuleVersion(): string |
|
117 | + { |
|
118 | + return '2.1.6-v.1'; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * {@inheritDoc} |
|
123 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
124 | + */ |
|
125 | + public function getConfigLink(): string |
|
126 | + { |
|
127 | + return route(AdminConfigPage::class); |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * {@inheritDoc} |
|
132 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks() |
|
133 | + */ |
|
134 | + public function listSubscribedHooks(): array |
|
135 | + { |
|
136 | + return [ |
|
137 | + app()->makeWith(FactSourceTextExtenderCollector::class, ['module' => $this]), |
|
138 | + app()->makeWith(FamilyDatatablesExtenderCollector::class, ['module' => $this]), |
|
139 | + app()->makeWith(IndividualDatatablesExtenderCollector::class, ['module' => $this]), |
|
140 | + app()->makeWith(NameAccordionExtenderCollector::class, ['module' => $this]), |
|
141 | + app()->makeWith(RecordNameTextExtenderCollector::class, ['module' => $this]), |
|
142 | + app()->makeWith(SosaFamilyDatatablesExtenderCollector::class, ['module' => $this]), |
|
143 | + app()->makeWith(SosaIndividualDatatablesExtenderCollector::class, ['module' => $this]), |
|
144 | + app()->makeWith(SosaMissingDatatablesExtenderCollector::class, ['module' => $this]) |
|
145 | + ]; |
|
146 | + } |
|
147 | 147 | } |
@@ -25,53 +25,53 @@ |
||
25 | 25 | */ |
26 | 26 | class IsSourcedStatusHook implements RecordNameTextExtenderInterface |
27 | 27 | { |
28 | - private ModuleInterface $module; |
|
29 | - private SourceStatusService $source_status_service; |
|
28 | + private ModuleInterface $module; |
|
29 | + private SourceStatusService $source_status_service; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Constructor for IsSourcedStatusHook |
|
33 | - * |
|
34 | - * @param ModuleInterface $module |
|
35 | - * @param SourceStatusService $source_status_service |
|
36 | - */ |
|
37 | - public function __construct(ModuleInterface $module, SourceStatusService $source_status_service) |
|
38 | - { |
|
39 | - $this->module = $module; |
|
40 | - $this->source_status_service = $source_status_service; |
|
41 | - } |
|
31 | + /** |
|
32 | + * Constructor for IsSourcedStatusHook |
|
33 | + * |
|
34 | + * @param ModuleInterface $module |
|
35 | + * @param SourceStatusService $source_status_service |
|
36 | + */ |
|
37 | + public function __construct(ModuleInterface $module, SourceStatusService $source_status_service) |
|
38 | + { |
|
39 | + $this->module = $module; |
|
40 | + $this->source_status_service = $source_status_service; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * {@inheritDoc} |
|
45 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
|
46 | - */ |
|
47 | - public function module(): ModuleInterface |
|
48 | - { |
|
49 | - return $this->module; |
|
50 | - } |
|
43 | + /** |
|
44 | + * {@inheritDoc} |
|
45 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
|
46 | + */ |
|
47 | + public function module(): ModuleInterface |
|
48 | + { |
|
49 | + return $this->module; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * {@inheritDoc} |
|
54 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend() |
|
55 | - */ |
|
56 | - public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
57 | - { |
|
58 | - return ''; |
|
59 | - } |
|
52 | + /** |
|
53 | + * {@inheritDoc} |
|
54 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend() |
|
55 | + */ |
|
56 | + public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
57 | + { |
|
58 | + return ''; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * {@inheritDoc} |
|
63 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend() |
|
64 | - */ |
|
65 | - public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
66 | - { |
|
67 | - if ($use_long && $record instanceof Individual) { |
|
68 | - return view($this->module()->name() . '::hooks/name-append', [ |
|
69 | - 'module_name' => $this->module()->name(), |
|
70 | - 'source_status_service' => $this->source_status_service, |
|
71 | - 'individual' => $record, |
|
72 | - 'size_style' => $size |
|
73 | - ]); |
|
74 | - } |
|
75 | - return ''; |
|
76 | - } |
|
61 | + /** |
|
62 | + * {@inheritDoc} |
|
63 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend() |
|
64 | + */ |
|
65 | + public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
66 | + { |
|
67 | + if ($use_long && $record instanceof Individual) { |
|
68 | + return view($this->module()->name() . '::hooks/name-append', [ |
|
69 | + 'module_name' => $this->module()->name(), |
|
70 | + 'source_status_service' => $this->source_status_service, |
|
71 | + 'individual' => $record, |
|
72 | + 'size_style' => $size |
|
73 | + ]); |
|
74 | + } |
|
75 | + return ''; |
|
76 | + } |
|
77 | 77 | } |
@@ -33,105 +33,105 @@ |
||
33 | 33 | * IsSourced Module |
34 | 34 | */ |
35 | 35 | class IsSourcedModule extends AbstractModule implements |
36 | - ModuleMyArtJaubInterface, |
|
37 | - ModuleGlobalInterface, |
|
38 | - ModuleSidebarInterface, |
|
39 | - ModuleHookSubscriberInterface |
|
36 | + ModuleMyArtJaubInterface, |
|
37 | + ModuleGlobalInterface, |
|
38 | + ModuleSidebarInterface, |
|
39 | + ModuleHookSubscriberInterface |
|
40 | 40 | { |
41 | - use ModuleMyArtJaubTrait; |
|
42 | - use ModuleGlobalTrait; |
|
43 | - use ModuleSidebarTrait; |
|
41 | + use ModuleMyArtJaubTrait; |
|
42 | + use ModuleGlobalTrait; |
|
43 | + use ModuleSidebarTrait; |
|
44 | 44 | |
45 | - /** |
|
46 | - * {@inheritDoc} |
|
47 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
48 | - */ |
|
49 | - public function title(): string |
|
50 | - { |
|
51 | - return I18N::translate('Sourced events'); |
|
52 | - } |
|
45 | + /** |
|
46 | + * {@inheritDoc} |
|
47 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::title() |
|
48 | + */ |
|
49 | + public function title(): string |
|
50 | + { |
|
51 | + return I18N::translate('Sourced events'); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * {@inheritDoc} |
|
56 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
57 | - */ |
|
58 | - public function description(): string |
|
59 | - { |
|
60 | - return I18N::translate('Indicate if events related to an record are sourced.'); |
|
61 | - } |
|
54 | + /** |
|
55 | + * {@inheritDoc} |
|
56 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::description() |
|
57 | + */ |
|
58 | + public function description(): string |
|
59 | + { |
|
60 | + return I18N::translate('Indicate if events related to an record are sourced.'); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * {@inheritDoc} |
|
65 | - * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
66 | - */ |
|
67 | - public function customModuleVersion(): string |
|
68 | - { |
|
69 | - return '2.1.6-v.1'; |
|
70 | - } |
|
63 | + /** |
|
64 | + * {@inheritDoc} |
|
65 | + * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleVersion() |
|
66 | + */ |
|
67 | + public function customModuleVersion(): string |
|
68 | + { |
|
69 | + return '2.1.6-v.1'; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * {@inheritDoc} |
|
74 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
75 | - */ |
|
76 | - public function headContent(): string |
|
77 | - { |
|
78 | - return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
79 | - } |
|
72 | + /** |
|
73 | + * {@inheritDoc} |
|
74 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::headContent() |
|
75 | + */ |
|
76 | + public function headContent(): string |
|
77 | + { |
|
78 | + return '<link rel="stylesheet" href="' . e($this->moduleCssUrl()) . '">'; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * {@inheritDoc} |
|
83 | - * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::bodyContent() |
|
84 | - */ |
|
85 | - public function bodyContent(): string |
|
86 | - { |
|
87 | - return '<script src="' . $this->assetUrl('js/issourced.min.js') . '"></script>'; |
|
88 | - } |
|
81 | + /** |
|
82 | + * {@inheritDoc} |
|
83 | + * @see \Fisharebest\Webtrees\Module\ModuleGlobalInterface::bodyContent() |
|
84 | + */ |
|
85 | + public function bodyContent(): string |
|
86 | + { |
|
87 | + return '<script src="' . $this->assetUrl('js/issourced.min.js') . '"></script>'; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * {@inheritDoc} |
|
92 | - * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::hasSidebarContent() |
|
93 | - */ |
|
94 | - public function hasSidebarContent(Individual $individual): bool |
|
95 | - { |
|
96 | - return true; |
|
97 | - } |
|
90 | + /** |
|
91 | + * {@inheritDoc} |
|
92 | + * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::hasSidebarContent() |
|
93 | + */ |
|
94 | + public function hasSidebarContent(Individual $individual): bool |
|
95 | + { |
|
96 | + return true; |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * {@inheritDoc} |
|
101 | - * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::getSidebarContent() |
|
102 | - */ |
|
103 | - public function getSidebarContent(Individual $individual): string |
|
104 | - { |
|
105 | - /** @var SourceStatusService $source_status_service */ |
|
106 | - $source_status_service = app(SourceStatusService::class); |
|
99 | + /** |
|
100 | + * {@inheritDoc} |
|
101 | + * @see \Fisharebest\Webtrees\Module\ModuleSidebarInterface::getSidebarContent() |
|
102 | + */ |
|
103 | + public function getSidebarContent(Individual $individual): string |
|
104 | + { |
|
105 | + /** @var SourceStatusService $source_status_service */ |
|
106 | + $source_status_service = app(SourceStatusService::class); |
|
107 | 107 | |
108 | - $spouse_families_status = $individual->spouseFamilies()->map( |
|
109 | - function (Family $sfamily) use ($source_status_service): array { |
|
110 | - return [ $sfamily, $source_status_service->sourceStatusForMarriage($sfamily)]; |
|
111 | - } |
|
112 | - )->filter(function (array $item): bool { |
|
113 | - return $item[1]->isSet(); |
|
114 | - }); |
|
108 | + $spouse_families_status = $individual->spouseFamilies()->map( |
|
109 | + function (Family $sfamily) use ($source_status_service): array { |
|
110 | + return [ $sfamily, $source_status_service->sourceStatusForMarriage($sfamily)]; |
|
111 | + } |
|
112 | + )->filter(function (array $item): bool { |
|
113 | + return $item[1]->isSet(); |
|
114 | + }); |
|
115 | 115 | |
116 | - return view($this->name() . '::sidebar/content', [ |
|
117 | - 'module_name' => $this->name(), |
|
118 | - 'individual' => $individual, |
|
119 | - 'source_status_individual' => $source_status_service->sourceStatusForRecord($individual), |
|
120 | - 'source_status_birth' => $source_status_service->sourceStatusForBirth($individual), |
|
121 | - 'source_status_marriages' => $spouse_families_status, |
|
122 | - 'source_status_death' => $source_status_service->sourceStatusForDeath($individual) |
|
123 | - ]); |
|
124 | - } |
|
116 | + return view($this->name() . '::sidebar/content', [ |
|
117 | + 'module_name' => $this->name(), |
|
118 | + 'individual' => $individual, |
|
119 | + 'source_status_individual' => $source_status_service->sourceStatusForRecord($individual), |
|
120 | + 'source_status_birth' => $source_status_service->sourceStatusForBirth($individual), |
|
121 | + 'source_status_marriages' => $spouse_families_status, |
|
122 | + 'source_status_death' => $source_status_service->sourceStatusForDeath($individual) |
|
123 | + ]); |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * {@inheritDoc} |
|
128 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks() |
|
129 | - */ |
|
130 | - public function listSubscribedHooks(): array |
|
131 | - { |
|
132 | - return [ |
|
133 | - app()->makeWith(IsSourcedStatusHook::class, [ 'module' => $this ]), |
|
134 | - app()->makeWith(IsSourcedStatusColumnsHook::class, [ 'module' => $this ]) |
|
135 | - ]; |
|
136 | - } |
|
126 | + /** |
|
127 | + * {@inheritDoc} |
|
128 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\ModuleHookSubscriberInterface::listSubscribedHooks() |
|
129 | + */ |
|
130 | + public function listSubscribedHooks(): array |
|
131 | + { |
|
132 | + return [ |
|
133 | + app()->makeWith(IsSourcedStatusHook::class, [ 'module' => $this ]), |
|
134 | + app()->makeWith(IsSourcedStatusColumnsHook::class, [ 'module' => $this ]) |
|
135 | + ]; |
|
136 | + } |
|
137 | 137 | } |