@@ -26,55 +26,55 @@ |
||
26 | 26 | */ |
27 | 27 | class AllEventsByTypeGeoAnalysis implements GeoAnalysisInterface |
28 | 28 | { |
29 | - private GeoAnalysisDataService $geoanalysis_data_service; |
|
29 | + private GeoAnalysisDataService $geoanalysis_data_service; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Constructor for AllEventsByTypeGeoAnalysis |
|
33 | - * |
|
34 | - * @param GeoAnalysisDataService $geoanalysis_data_service |
|
35 | - */ |
|
36 | - public function __construct(GeoAnalysisDataService $geoanalysis_data_service) |
|
37 | - { |
|
38 | - $this->geoanalysis_data_service = $geoanalysis_data_service; |
|
39 | - } |
|
31 | + /** |
|
32 | + * Constructor for AllEventsByTypeGeoAnalysis |
|
33 | + * |
|
34 | + * @param GeoAnalysisDataService $geoanalysis_data_service |
|
35 | + */ |
|
36 | + public function __construct(GeoAnalysisDataService $geoanalysis_data_service) |
|
37 | + { |
|
38 | + $this->geoanalysis_data_service = $geoanalysis_data_service; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * {@inheritDoc} |
|
43 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::title() |
|
44 | - */ |
|
45 | - public function title(): string |
|
46 | - { |
|
47 | - return I18N::translate('All events places by event type'); |
|
48 | - } |
|
41 | + /** |
|
42 | + * {@inheritDoc} |
|
43 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::title() |
|
44 | + */ |
|
45 | + public function title(): string |
|
46 | + { |
|
47 | + return I18N::translate('All events places by event type'); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * {@inheritDoc} |
|
52 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::itemsDescription() |
|
53 | - */ |
|
54 | - public function itemsDescription(): callable |
|
55 | - { |
|
56 | - return fn(int $count): string => I18N::plural('event', 'events', $count); |
|
57 | - } |
|
50 | + /** |
|
51 | + * {@inheritDoc} |
|
52 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::itemsDescription() |
|
53 | + */ |
|
54 | + public function itemsDescription(): callable |
|
55 | + { |
|
56 | + return fn(int $count): string => I18N::plural('event', 'events', $count); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * {@inheritDoc} |
|
61 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::results() |
|
62 | - */ |
|
63 | - public function results(Tree $tree, int $depth): GeoAnalysisResults |
|
64 | - { |
|
65 | - $results = new GeoAnalysisResults(); |
|
59 | + /** |
|
60 | + * {@inheritDoc} |
|
61 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::results() |
|
62 | + */ |
|
63 | + public function results(Tree $tree, int $depth): GeoAnalysisResults |
|
64 | + { |
|
65 | + $results = new GeoAnalysisResults(); |
|
66 | 66 | |
67 | - foreach ($this->geoanalysis_data_service->individualsAndFamilies($tree) as $record) { |
|
68 | - foreach ($record->facts([]) as $fact) { |
|
69 | - $place = new GeoAnalysisPlace($tree, $fact->place(), $depth); |
|
70 | - if ($place->isUnknown()) { |
|
71 | - continue; |
|
72 | - } |
|
73 | - $results->addPlace($place); |
|
74 | - $results->addPlaceInCategory($fact->label(), 0, $place); |
|
75 | - } |
|
76 | - } |
|
67 | + foreach ($this->geoanalysis_data_service->individualsAndFamilies($tree) as $record) { |
|
68 | + foreach ($record->facts([]) as $fact) { |
|
69 | + $place = new GeoAnalysisPlace($tree, $fact->place(), $depth); |
|
70 | + if ($place->isUnknown()) { |
|
71 | + continue; |
|
72 | + } |
|
73 | + $results->addPlace($place); |
|
74 | + $results->addPlaceInCategory($fact->label(), 0, $place); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - return $results; |
|
79 | - } |
|
78 | + return $results; |
|
79 | + } |
|
80 | 80 | } |
@@ -28,66 +28,66 @@ |
||
28 | 28 | */ |
29 | 29 | class AllEventsByCenturyGeoAnalysis implements GeoAnalysisInterface |
30 | 30 | { |
31 | - private GeoAnalysisDataService $geoanalysis_data_service; |
|
32 | - private CenturyService $century_service; |
|
31 | + private GeoAnalysisDataService $geoanalysis_data_service; |
|
32 | + private CenturyService $century_service; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Constructor for AllEventsByCenturyGeoAnalysis |
|
36 | - * |
|
37 | - * @param GeoAnalysisDataService $geoanalysis_data_service |
|
38 | - * @param CenturyService $century_service |
|
39 | - */ |
|
40 | - public function __construct(GeoAnalysisDataService $geoanalysis_data_service, CenturyService $century_service) |
|
41 | - { |
|
42 | - $this->geoanalysis_data_service = $geoanalysis_data_service; |
|
43 | - $this->century_service = $century_service; |
|
44 | - } |
|
34 | + /** |
|
35 | + * Constructor for AllEventsByCenturyGeoAnalysis |
|
36 | + * |
|
37 | + * @param GeoAnalysisDataService $geoanalysis_data_service |
|
38 | + * @param CenturyService $century_service |
|
39 | + */ |
|
40 | + public function __construct(GeoAnalysisDataService $geoanalysis_data_service, CenturyService $century_service) |
|
41 | + { |
|
42 | + $this->geoanalysis_data_service = $geoanalysis_data_service; |
|
43 | + $this->century_service = $century_service; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * {@inheritDoc} |
|
48 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::title() |
|
49 | - */ |
|
50 | - public function title(): string |
|
51 | - { |
|
52 | - return I18N::translate('All events places by century'); |
|
53 | - } |
|
46 | + /** |
|
47 | + * {@inheritDoc} |
|
48 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::title() |
|
49 | + */ |
|
50 | + public function title(): string |
|
51 | + { |
|
52 | + return I18N::translate('All events places by century'); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * {@inheritDoc} |
|
57 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::itemsDescription() |
|
58 | - */ |
|
59 | - public function itemsDescription(): callable |
|
60 | - { |
|
61 | - return fn(int $count): string => I18N::plural('event', 'events', $count); |
|
62 | - } |
|
55 | + /** |
|
56 | + * {@inheritDoc} |
|
57 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::itemsDescription() |
|
58 | + */ |
|
59 | + public function itemsDescription(): callable |
|
60 | + { |
|
61 | + return fn(int $count): string => I18N::plural('event', 'events', $count); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * {@inheritDoc} |
|
66 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::results() |
|
67 | - */ |
|
68 | - public function results(Tree $tree, int $depth): GeoAnalysisResults |
|
69 | - { |
|
70 | - $results = new GeoAnalysisResults(); |
|
64 | + /** |
|
65 | + * {@inheritDoc} |
|
66 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\GeoAnalysisInterface::results() |
|
67 | + */ |
|
68 | + public function results(Tree $tree, int $depth): GeoAnalysisResults |
|
69 | + { |
|
70 | + $results = new GeoAnalysisResults(); |
|
71 | 71 | |
72 | - foreach ($this->geoanalysis_data_service->individualsAndFamilies($tree) as $record) { |
|
73 | - foreach ($record->facts([]) as $fact) { |
|
74 | - $place = new GeoAnalysisPlace($tree, $fact->place(), $depth); |
|
75 | - if ($place->isUnknown()) { |
|
76 | - continue; |
|
77 | - } |
|
78 | - $results->addPlace($place); |
|
79 | - $date = $fact->date(); |
|
80 | - if ($date->isOK()) { |
|
81 | - $century = intdiv($date->gregorianYear(), 100); |
|
82 | - $results->addPlaceInCategory( |
|
83 | - I18N::translate('%s century', $this->century_service->centuryName($century)), |
|
84 | - $century, |
|
85 | - $place |
|
86 | - ); |
|
87 | - } |
|
88 | - } |
|
89 | - } |
|
72 | + foreach ($this->geoanalysis_data_service->individualsAndFamilies($tree) as $record) { |
|
73 | + foreach ($record->facts([]) as $fact) { |
|
74 | + $place = new GeoAnalysisPlace($tree, $fact->place(), $depth); |
|
75 | + if ($place->isUnknown()) { |
|
76 | + continue; |
|
77 | + } |
|
78 | + $results->addPlace($place); |
|
79 | + $date = $fact->date(); |
|
80 | + if ($date->isOK()) { |
|
81 | + $century = intdiv($date->gregorianYear(), 100); |
|
82 | + $results->addPlaceInCategory( |
|
83 | + I18N::translate('%s century', $this->century_service->centuryName($century)), |
|
84 | + $century, |
|
85 | + $place |
|
86 | + ); |
|
87 | + } |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - return $results; |
|
92 | - } |
|
91 | + return $results; |
|
92 | + } |
|
93 | 93 | } |
@@ -24,23 +24,23 @@ |
||
24 | 24 | */ |
25 | 25 | class SimplePlaceMapper implements PlaceMapperInterface |
26 | 26 | { |
27 | - use PlaceMapperTrait; |
|
27 | + use PlaceMapperTrait; |
|
28 | 28 | |
29 | - /** |
|
30 | - * {@inheritDoc} |
|
31 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::title() |
|
32 | - */ |
|
33 | - public function title(): string |
|
34 | - { |
|
35 | - return I18N::translate('Mapping on place name'); |
|
36 | - } |
|
29 | + /** |
|
30 | + * {@inheritDoc} |
|
31 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::title() |
|
32 | + */ |
|
33 | + public function title(): string |
|
34 | + { |
|
35 | + return I18N::translate('Mapping on place name'); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * {@inheritDoc} |
|
40 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::map() |
|
41 | - */ |
|
42 | - public function map(Place $place, string $feature_property): ?string |
|
43 | - { |
|
44 | - return $place->firstParts(1)->first(); |
|
45 | - } |
|
38 | + /** |
|
39 | + * {@inheritDoc} |
|
40 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::map() |
|
41 | + */ |
|
42 | + public function map(Place $place, string $feature_property): ?string |
|
43 | + { |
|
44 | + return $place->firstParts(1)->first(); |
|
45 | + } |
|
46 | 46 | } |
@@ -28,114 +28,114 @@ |
||
28 | 28 | */ |
29 | 29 | class FilteredTopPlaceMapperConfig extends GenericPlaceMapperConfig |
30 | 30 | { |
31 | - private TreeService $tree_service; |
|
31 | + private TreeService $tree_service; |
|
32 | 32 | |
33 | - /** |
|
34 | - * FilteredTopPlaceMapperConfig |
|
35 | - * |
|
36 | - * @param TreeService $tree_service |
|
37 | - */ |
|
38 | - public function __construct(TreeService $tree_service) |
|
39 | - { |
|
40 | - $this->tree_service = $tree_service; |
|
41 | - } |
|
33 | + /** |
|
34 | + * FilteredTopPlaceMapperConfig |
|
35 | + * |
|
36 | + * @param TreeService $tree_service |
|
37 | + */ |
|
38 | + public function __construct(TreeService $tree_service) |
|
39 | + { |
|
40 | + $this->tree_service = $tree_service; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * Get the configured Top Places to filter on |
|
45 | - * |
|
46 | - * @return Collection<Place> |
|
47 | - */ |
|
48 | - public function topPlaces(): Collection |
|
49 | - { |
|
50 | - return collect($this->get('topPlaces', [])) |
|
51 | - ->filter( |
|
52 | - /** @psalm-suppress MissingClosureParamType */ |
|
53 | - fn($item): bool => $item instanceof Place |
|
54 | - ); |
|
55 | - } |
|
43 | + /** |
|
44 | + * Get the configured Top Places to filter on |
|
45 | + * |
|
46 | + * @return Collection<Place> |
|
47 | + */ |
|
48 | + public function topPlaces(): Collection |
|
49 | + { |
|
50 | + return collect($this->get('topPlaces', [])) |
|
51 | + ->filter( |
|
52 | + /** @psalm-suppress MissingClosureParamType */ |
|
53 | + fn($item): bool => $item instanceof Place |
|
54 | + ); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * {@inheritDoc} |
|
59 | - * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::jsonSerializeConfig() |
|
60 | - */ |
|
61 | - public function jsonSerializeConfig() |
|
62 | - { |
|
63 | - return [ |
|
64 | - 'topPlaces' => $this->topPlaces() |
|
65 | - ->map(fn(Place $place): array => [ $place->tree()->id(), $place->gedcomName() ]) |
|
66 | - ->toArray() |
|
67 | - ]; |
|
68 | - } |
|
57 | + /** |
|
58 | + * {@inheritDoc} |
|
59 | + * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::jsonSerializeConfig() |
|
60 | + */ |
|
61 | + public function jsonSerializeConfig() |
|
62 | + { |
|
63 | + return [ |
|
64 | + 'topPlaces' => $this->topPlaces() |
|
65 | + ->map(fn(Place $place): array => [ $place->tree()->id(), $place->gedcomName() ]) |
|
66 | + ->toArray() |
|
67 | + ]; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * {@inheritDoc} |
|
72 | - * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::jsonDeserialize() |
|
73 | - * |
|
74 | - * @param mixed $config |
|
75 | - * @return $this |
|
76 | - */ |
|
77 | - public function jsonDeserialize($config): self |
|
78 | - { |
|
79 | - if (is_string($config)) { |
|
80 | - return $this->jsonDeserialize(json_decode($config)); |
|
81 | - } |
|
82 | - if (is_array($config)) { |
|
83 | - $this->setConfig([ |
|
84 | - 'topPlaces' => collect($config['topPlaces'] ?? []) |
|
85 | - ->filter( |
|
86 | - /** @psalm-suppress MissingClosureParamType */ |
|
87 | - fn($item): bool => is_array($item) && count($item) == 2 |
|
88 | - )->map(function (array $item): ?Place { |
|
89 | - try { |
|
90 | - return new Place($item[1], $this->tree_service->find($item[0])); |
|
91 | - } catch (RuntimeException $ex) { |
|
92 | - return null; |
|
93 | - } |
|
94 | - }) |
|
95 | - ->filter() |
|
96 | - ->toArray() |
|
97 | - ]); |
|
98 | - } |
|
99 | - return $this; |
|
100 | - } |
|
70 | + /** |
|
71 | + * {@inheritDoc} |
|
72 | + * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::jsonDeserialize() |
|
73 | + * |
|
74 | + * @param mixed $config |
|
75 | + * @return $this |
|
76 | + */ |
|
77 | + public function jsonDeserialize($config): self |
|
78 | + { |
|
79 | + if (is_string($config)) { |
|
80 | + return $this->jsonDeserialize(json_decode($config)); |
|
81 | + } |
|
82 | + if (is_array($config)) { |
|
83 | + $this->setConfig([ |
|
84 | + 'topPlaces' => collect($config['topPlaces'] ?? []) |
|
85 | + ->filter( |
|
86 | + /** @psalm-suppress MissingClosureParamType */ |
|
87 | + fn($item): bool => is_array($item) && count($item) == 2 |
|
88 | + )->map(function (array $item): ?Place { |
|
89 | + try { |
|
90 | + return new Place($item[1], $this->tree_service->find($item[0])); |
|
91 | + } catch (RuntimeException $ex) { |
|
92 | + return null; |
|
93 | + } |
|
94 | + }) |
|
95 | + ->filter() |
|
96 | + ->toArray() |
|
97 | + ]); |
|
98 | + } |
|
99 | + return $this; |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * {@inheritDoc} |
|
104 | - * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::configContent() |
|
105 | - */ |
|
106 | - public function configContent(ModuleInterface $module, Tree $tree): string |
|
107 | - { |
|
108 | - return view($module->name() . '::mappers/filtered-top-config', [ |
|
109 | - 'tree' => $tree, |
|
110 | - 'top_places' => $this->topPlaces() |
|
111 | - ]); |
|
112 | - } |
|
102 | + /** |
|
103 | + * {@inheritDoc} |
|
104 | + * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::configContent() |
|
105 | + */ |
|
106 | + public function configContent(ModuleInterface $module, Tree $tree): string |
|
107 | + { |
|
108 | + return view($module->name() . '::mappers/filtered-top-config', [ |
|
109 | + 'tree' => $tree, |
|
110 | + 'top_places' => $this->topPlaces() |
|
111 | + ]); |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * {@inheritDoc} |
|
116 | - * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::withConfigUpdate() |
|
117 | - * @return $this |
|
118 | - */ |
|
119 | - public function withConfigUpdate(ServerRequestInterface $request): self |
|
120 | - { |
|
121 | - $tree = $request->getAttribute('tree'); |
|
122 | - if (!($tree instanceof Tree)) { |
|
123 | - return $this; |
|
124 | - } |
|
114 | + /** |
|
115 | + * {@inheritDoc} |
|
116 | + * @see \MyArtJaub\Webtrees\Common\GeoDispersion\Config\GenericPlaceMapperConfig::withConfigUpdate() |
|
117 | + * @return $this |
|
118 | + */ |
|
119 | + public function withConfigUpdate(ServerRequestInterface $request): self |
|
120 | + { |
|
121 | + $tree = $request->getAttribute('tree'); |
|
122 | + if (!($tree instanceof Tree)) { |
|
123 | + return $this; |
|
124 | + } |
|
125 | 125 | |
126 | - $params = (array) $request->getParsedBody(); |
|
126 | + $params = (array) $request->getParsedBody(); |
|
127 | 127 | |
128 | - $top_places = $params['mapper_filt_top_places'] ?? []; |
|
129 | - if (is_array($top_places)) { |
|
130 | - $config = ['topPlaces' => []]; |
|
131 | - foreach ($top_places as $top_place_id) { |
|
132 | - $place = Place::find((int) $top_place_id, $tree); |
|
133 | - if (mb_strlen($place->gedcomName()) > 0) { |
|
134 | - $config['topPlaces'][] = $place; |
|
135 | - } |
|
136 | - } |
|
137 | - $this->setConfig($config); |
|
138 | - } |
|
139 | - return $this; |
|
140 | - } |
|
128 | + $top_places = $params['mapper_filt_top_places'] ?? []; |
|
129 | + if (is_array($top_places)) { |
|
130 | + $config = ['topPlaces' => []]; |
|
131 | + foreach ($top_places as $top_place_id) { |
|
132 | + $place = Place::find((int) $top_place_id, $tree); |
|
133 | + if (mb_strlen($place->gedcomName()) > 0) { |
|
134 | + $config['topPlaces'][] = $place; |
|
135 | + } |
|
136 | + } |
|
137 | + $this->setConfig($config); |
|
138 | + } |
|
139 | + return $this; |
|
140 | + } |
|
141 | 141 | } |
@@ -28,51 +28,51 @@ |
||
28 | 28 | */ |
29 | 29 | class SimpleTopFilteredPlaceMapper extends SimplePlaceMapper implements PlaceMapperInterface |
30 | 30 | { |
31 | - use TopFilteredPlaceMapperTrait; |
|
31 | + use TopFilteredPlaceMapperTrait; |
|
32 | 32 | |
33 | - /** |
|
34 | - * {@inheritDoc} |
|
35 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\PlaceMappers\SimplePlaceMapper::title() |
|
36 | - */ |
|
37 | - public function title(): string |
|
38 | - { |
|
39 | - return I18N::translate('Mapping on place name with filter'); |
|
40 | - } |
|
33 | + /** |
|
34 | + * {@inheritDoc} |
|
35 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\PlaceMappers\SimplePlaceMapper::title() |
|
36 | + */ |
|
37 | + public function title(): string |
|
38 | + { |
|
39 | + return I18N::translate('Mapping on place name with filter'); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * {@inheritDoc} |
|
44 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::boot() |
|
45 | - */ |
|
46 | - public function boot(): void |
|
47 | - { |
|
48 | - parent::boot(); |
|
49 | - $top_places = $this->config()->get('topPlaces'); |
|
50 | - if (is_array($top_places)) { |
|
51 | - $this->setTopPlaces($top_places); |
|
52 | - } |
|
53 | - } |
|
42 | + /** |
|
43 | + * {@inheritDoc} |
|
44 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::boot() |
|
45 | + */ |
|
46 | + public function boot(): void |
|
47 | + { |
|
48 | + parent::boot(); |
|
49 | + $top_places = $this->config()->get('topPlaces'); |
|
50 | + if (is_array($top_places)) { |
|
51 | + $this->setTopPlaces($top_places); |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * {@inheritDoc} |
|
57 | - * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::config() |
|
58 | - */ |
|
59 | - public function config(): PlaceMapperConfigInterface |
|
60 | - { |
|
61 | - if (!(parent::config() instanceof FilteredTopPlaceMapperConfig)) { |
|
62 | - $this->setConfig(app(FilteredTopPlaceMapperConfig::class)); |
|
63 | - } |
|
64 | - return parent::config(); |
|
65 | - } |
|
55 | + /** |
|
56 | + * {@inheritDoc} |
|
57 | + * @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperInterface::config() |
|
58 | + */ |
|
59 | + public function config(): PlaceMapperConfigInterface |
|
60 | + { |
|
61 | + if (!(parent::config() instanceof FilteredTopPlaceMapperConfig)) { |
|
62 | + $this->setConfig(app(FilteredTopPlaceMapperConfig::class)); |
|
63 | + } |
|
64 | + return parent::config(); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * {@inheritDoc} |
|
69 | - * @see \MyArtJaub\Webtrees\Module\GeoDispersion\PlaceMappers\SimplePlaceMapper::map() |
|
70 | - */ |
|
71 | - public function map(Place $place, string $feature_property): ?string |
|
72 | - { |
|
73 | - if (!$this->belongsToTopLevels($place)) { |
|
74 | - return null; |
|
75 | - } |
|
76 | - return parent::map($place, $feature_property); |
|
77 | - } |
|
67 | + /** |
|
68 | + * {@inheritDoc} |
|
69 | + * @see \MyArtJaub\Webtrees\Module\GeoDispersion\PlaceMappers\SimplePlaceMapper::map() |
|
70 | + */ |
|
71 | + public function map(Place $place, string $feature_property): ?string |
|
72 | + { |
|
73 | + if (!$this->belongsToTopLevels($place)) { |
|
74 | + return null; |
|
75 | + } |
|
76 | + return parent::map($place, $feature_property); |
|
77 | + } |
|
78 | 78 | } |
@@ -22,81 +22,81 @@ |
||
22 | 22 | */ |
23 | 23 | class MapFeatureAnalysisData |
24 | 24 | { |
25 | - private string $id; |
|
26 | - private int $count; |
|
27 | - private bool $in_map; |
|
28 | - /** |
|
29 | - * @var Collection<GeoAnalysisPlace> $places |
|
30 | - */ |
|
31 | - private Collection $places; |
|
25 | + private string $id; |
|
26 | + private int $count; |
|
27 | + private bool $in_map; |
|
28 | + /** |
|
29 | + * @var Collection<GeoAnalysisPlace> $places |
|
30 | + */ |
|
31 | + private Collection $places; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Constructor for MapFeatureAnalysisData |
|
35 | - * |
|
36 | - * @param string $id |
|
37 | - */ |
|
38 | - public function __construct(string $id) |
|
39 | - { |
|
40 | - $this->id = $id; |
|
41 | - $this->count = 0; |
|
42 | - $this->places = new Collection(); |
|
43 | - $this->in_map = false; |
|
44 | - } |
|
33 | + /** |
|
34 | + * Constructor for MapFeatureAnalysisData |
|
35 | + * |
|
36 | + * @param string $id |
|
37 | + */ |
|
38 | + public function __construct(string $id) |
|
39 | + { |
|
40 | + $this->id = $id; |
|
41 | + $this->count = 0; |
|
42 | + $this->places = new Collection(); |
|
43 | + $this->in_map = false; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Get the list of places mapped to the feature |
|
48 | - * |
|
49 | - * @return Collection<GeoAnalysisPlace> |
|
50 | - */ |
|
51 | - public function places(): Collection |
|
52 | - { |
|
53 | - return $this->places; |
|
54 | - } |
|
46 | + /** |
|
47 | + * Get the list of places mapped to the feature |
|
48 | + * |
|
49 | + * @return Collection<GeoAnalysisPlace> |
|
50 | + */ |
|
51 | + public function places(): Collection |
|
52 | + { |
|
53 | + return $this->places; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Get the count of analysis items occurring in the feature |
|
58 | - * |
|
59 | - * @return int |
|
60 | - */ |
|
61 | - public function count(): int |
|
62 | - { |
|
63 | - return $this->count; |
|
64 | - } |
|
56 | + /** |
|
57 | + * Get the count of analysis items occurring in the feature |
|
58 | + * |
|
59 | + * @return int |
|
60 | + */ |
|
61 | + public function count(): int |
|
62 | + { |
|
63 | + return $this->count; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Check whether the feature exist in the target map |
|
68 | - * |
|
69 | - * @return bool |
|
70 | - */ |
|
71 | - public function existsInMap(): bool |
|
72 | - { |
|
73 | - return $this->in_map; |
|
74 | - } |
|
66 | + /** |
|
67 | + * Check whether the feature exist in the target map |
|
68 | + * |
|
69 | + * @return bool |
|
70 | + */ |
|
71 | + public function existsInMap(): bool |
|
72 | + { |
|
73 | + return $this->in_map; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Confirm that the feature exist in the target map |
|
78 | - * |
|
79 | - * @return $this |
|
80 | - */ |
|
81 | - public function tagAsExisting(): self |
|
82 | - { |
|
83 | - $this->in_map = true; |
|
84 | - return $this; |
|
85 | - } |
|
76 | + /** |
|
77 | + * Confirm that the feature exist in the target map |
|
78 | + * |
|
79 | + * @return $this |
|
80 | + */ |
|
81 | + public function tagAsExisting(): self |
|
82 | + { |
|
83 | + $this->in_map = true; |
|
84 | + return $this; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Add a GeoAnalysisPlace to the feature |
|
89 | - * |
|
90 | - * @param GeoAnalysisPlace $place |
|
91 | - * @param int $count |
|
92 | - * @return $this |
|
93 | - */ |
|
94 | - public function add(GeoAnalysisPlace $place, int $count): self |
|
95 | - { |
|
96 | - if (!$place->isExcluded()) { |
|
97 | - $this->places->add($place); |
|
98 | - $this->count += $count; |
|
99 | - } |
|
100 | - return $this; |
|
101 | - } |
|
87 | + /** |
|
88 | + * Add a GeoAnalysisPlace to the feature |
|
89 | + * |
|
90 | + * @param GeoAnalysisPlace $place |
|
91 | + * @param int $count |
|
92 | + * @return $this |
|
93 | + */ |
|
94 | + public function add(GeoAnalysisPlace $place, int $count): self |
|
95 | + { |
|
96 | + if (!$place->isExcluded()) { |
|
97 | + $this->places->add($place); |
|
98 | + $this->count += $count; |
|
99 | + } |
|
100 | + return $this; |
|
101 | + } |
|
102 | 102 | } |
@@ -24,57 +24,57 @@ |
||
24 | 24 | */ |
25 | 25 | class MapAdapterResult |
26 | 26 | { |
27 | - private GeoAnalysisResult $result; |
|
27 | + private GeoAnalysisResult $result; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @var \Brick\Geo\IO\GeoJSON\Feature[] $features |
|
31 | - */ |
|
32 | - private array $features; |
|
29 | + /** |
|
30 | + * @var \Brick\Geo\IO\GeoJSON\Feature[] $features |
|
31 | + */ |
|
32 | + private array $features; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Constructor for MapAdapterResult |
|
36 | - * |
|
37 | - * @param GeoAnalysisResult $result |
|
38 | - * @param \Brick\Geo\IO\GeoJSON\Feature[] $features |
|
39 | - */ |
|
40 | - final public function __construct(GeoAnalysisResult $result, array $features) |
|
41 | - { |
|
42 | - $this->result = $result; |
|
43 | - $this->features = $features; |
|
44 | - } |
|
34 | + /** |
|
35 | + * Constructor for MapAdapterResult |
|
36 | + * |
|
37 | + * @param GeoAnalysisResult $result |
|
38 | + * @param \Brick\Geo\IO\GeoJSON\Feature[] $features |
|
39 | + */ |
|
40 | + final public function __construct(GeoAnalysisResult $result, array $features) |
|
41 | + { |
|
42 | + $this->result = $result; |
|
43 | + $this->features = $features; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Get the GeoAnalysisResult after mapping of the places |
|
48 | - * |
|
49 | - * @return GeoAnalysisResult |
|
50 | - */ |
|
51 | - public function geoAnalysisResult(): GeoAnalysisResult |
|
52 | - { |
|
53 | - return $this->result; |
|
54 | - } |
|
46 | + /** |
|
47 | + * Get the GeoAnalysisResult after mapping of the places |
|
48 | + * |
|
49 | + * @return GeoAnalysisResult |
|
50 | + */ |
|
51 | + public function geoAnalysisResult(): GeoAnalysisResult |
|
52 | + { |
|
53 | + return $this->result; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Get the list of features to display on the map |
|
58 | - * |
|
59 | - * @return \Brick\Geo\IO\GeoJSON\Feature[] |
|
60 | - */ |
|
61 | - public function features(): array |
|
62 | - { |
|
63 | - return $this->features; |
|
64 | - } |
|
56 | + /** |
|
57 | + * Get the list of features to display on the map |
|
58 | + * |
|
59 | + * @return \Brick\Geo\IO\GeoJSON\Feature[] |
|
60 | + */ |
|
61 | + public function features(): array |
|
62 | + { |
|
63 | + return $this->features; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Merge the current MapAdapter with another. |
|
68 | - * The current object is modified, not the second one. |
|
69 | - * |
|
70 | - * @param MapAdapterResult $other |
|
71 | - * @return static |
|
72 | - */ |
|
73 | - public function merge(MapAdapterResult $other): self |
|
74 | - { |
|
75 | - return new static( |
|
76 | - $this->result->merge($other->result), |
|
77 | - array_merge($this->features, $other->features) |
|
78 | - ); |
|
79 | - } |
|
66 | + /** |
|
67 | + * Merge the current MapAdapter with another. |
|
68 | + * The current object is modified, not the second one. |
|
69 | + * |
|
70 | + * @param MapAdapterResult $other |
|
71 | + * @return static |
|
72 | + */ |
|
73 | + public function merge(MapAdapterResult $other): self |
|
74 | + { |
|
75 | + return new static( |
|
76 | + $this->result->merge($other->result), |
|
77 | + array_merge($this->features, $other->features) |
|
78 | + ); |
|
79 | + } |
|
80 | 80 | } |
@@ -27,57 +27,57 @@ |
||
27 | 27 | */ |
28 | 28 | class SourceCertificateIconHook implements FactSourceTextExtenderInterface |
29 | 29 | { |
30 | - private CertificatesModule $module; |
|
31 | - private UrlObfuscatorService $url_obfuscator_service; |
|
30 | + private CertificatesModule $module; |
|
31 | + private UrlObfuscatorService $url_obfuscator_service; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Constructor for SourceCertificateIconHook |
|
35 | - * |
|
36 | - * @param CertificatesModule $module |
|
37 | - * @param UrlObfuscatorService $url_obfuscator_service |
|
38 | - */ |
|
39 | - public function __construct(CertificatesModule $module, UrlObfuscatorService $url_obfuscator_service) |
|
40 | - { |
|
41 | - $this->module = $module; |
|
42 | - $this->url_obfuscator_service = $url_obfuscator_service; |
|
43 | - } |
|
33 | + /** |
|
34 | + * Constructor for SourceCertificateIconHook |
|
35 | + * |
|
36 | + * @param CertificatesModule $module |
|
37 | + * @param UrlObfuscatorService $url_obfuscator_service |
|
38 | + */ |
|
39 | + public function __construct(CertificatesModule $module, UrlObfuscatorService $url_obfuscator_service) |
|
40 | + { |
|
41 | + $this->module = $module; |
|
42 | + $this->url_obfuscator_service = $url_obfuscator_service; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * {@inheritDoc} |
|
47 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
|
48 | - */ |
|
49 | - public function module(): ModuleInterface |
|
50 | - { |
|
51 | - return $this->module; |
|
52 | - } |
|
45 | + /** |
|
46 | + * {@inheritDoc} |
|
47 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
|
48 | + */ |
|
49 | + public function module(): ModuleInterface |
|
50 | + { |
|
51 | + return $this->module; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * {@inheritDoc} |
|
56 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourcePrepend() |
|
57 | - */ |
|
58 | - public function factSourcePrepend(Tree $tree, string $source_record, int $level): string |
|
59 | - { |
|
60 | - $permission_level = $tree->getPreference('MAJ_CERTIF_SHOW_CERT'); |
|
61 | - if ( |
|
62 | - is_numeric($permission_level) && Auth::accessLevel($tree) <= (int) $permission_level && |
|
63 | - preg_match('/^' . $level . ' _ACT (.*)$/m', $source_record, $match) === 1 |
|
64 | - ) { |
|
65 | - return view($this->module->name() . '::components/certificate-icon', [ |
|
66 | - 'module_name' => $this->module->name(), |
|
67 | - 'certificate' => new Certificate($tree, $match[1]), |
|
68 | - 'url_obfuscator_service' => $this->url_obfuscator_service, |
|
69 | - 'js_script_url' => $this->module->assetUrl('js/certificates.min.js') |
|
70 | - ]); |
|
71 | - } |
|
72 | - return ''; |
|
73 | - } |
|
54 | + /** |
|
55 | + * {@inheritDoc} |
|
56 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourcePrepend() |
|
57 | + */ |
|
58 | + public function factSourcePrepend(Tree $tree, string $source_record, int $level): string |
|
59 | + { |
|
60 | + $permission_level = $tree->getPreference('MAJ_CERTIF_SHOW_CERT'); |
|
61 | + if ( |
|
62 | + is_numeric($permission_level) && Auth::accessLevel($tree) <= (int) $permission_level && |
|
63 | + preg_match('/^' . $level . ' _ACT (.*)$/m', $source_record, $match) === 1 |
|
64 | + ) { |
|
65 | + return view($this->module->name() . '::components/certificate-icon', [ |
|
66 | + 'module_name' => $this->module->name(), |
|
67 | + 'certificate' => new Certificate($tree, $match[1]), |
|
68 | + 'url_obfuscator_service' => $this->url_obfuscator_service, |
|
69 | + 'js_script_url' => $this->module->assetUrl('js/certificates.min.js') |
|
70 | + ]); |
|
71 | + } |
|
72 | + return ''; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * {@inheritDoc} |
|
77 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourceAppend() |
|
78 | - */ |
|
79 | - public function factSourceAppend(Tree $tree, string $source_record, int $level): string |
|
80 | - { |
|
81 | - return ''; |
|
82 | - } |
|
75 | + /** |
|
76 | + * {@inheritDoc} |
|
77 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\FactSourceTextExtenderInterface::factSourceAppend() |
|
78 | + */ |
|
79 | + public function factSourceAppend(Tree $tree, string $source_record, int $level): string |
|
80 | + { |
|
81 | + return ''; |
|
82 | + } |
|
83 | 83 | } |
@@ -24,60 +24,60 @@ |
||
24 | 24 | */ |
25 | 25 | class CertificateTagEditorHook implements CustomSimpleTagEditorInterface |
26 | 26 | { |
27 | - private ModuleInterface $module; |
|
27 | + private ModuleInterface $module; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Constructor for CertificateTagEditorHook |
|
31 | - * |
|
32 | - * @param ModuleInterface $module |
|
33 | - */ |
|
34 | - public function __construct(ModuleInterface $module) |
|
35 | - { |
|
36 | - $this->module = $module; |
|
37 | - } |
|
29 | + /** |
|
30 | + * Constructor for CertificateTagEditorHook |
|
31 | + * |
|
32 | + * @param ModuleInterface $module |
|
33 | + */ |
|
34 | + public function __construct(ModuleInterface $module) |
|
35 | + { |
|
36 | + $this->module = $module; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * {@inheritDoc} |
|
41 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
|
42 | - */ |
|
43 | - public function module(): ModuleInterface |
|
44 | - { |
|
45 | - return $this->module; |
|
46 | - } |
|
39 | + /** |
|
40 | + * {@inheritDoc} |
|
41 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
|
42 | + */ |
|
43 | + public function module(): ModuleInterface |
|
44 | + { |
|
45 | + return $this->module; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * {@inheritDoc} |
|
50 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\CustomSimpleTagEditorInterface::addExpectedTags() |
|
51 | - */ |
|
52 | - public function addExpectedTags(array $expected_tags): array |
|
53 | - { |
|
54 | - return array_merge_recursive($expected_tags, [ |
|
55 | - 'SOUR' => [ '_ACT' ] |
|
56 | - ]); |
|
57 | - } |
|
48 | + /** |
|
49 | + * {@inheritDoc} |
|
50 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\CustomSimpleTagEditorInterface::addExpectedTags() |
|
51 | + */ |
|
52 | + public function addExpectedTags(array $expected_tags): array |
|
53 | + { |
|
54 | + return array_merge_recursive($expected_tags, [ |
|
55 | + 'SOUR' => [ '_ACT' ] |
|
56 | + ]); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * {@inheritDoc} |
|
61 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\CustomSimpleTagEditorInterface::getLabel() |
|
62 | - */ |
|
63 | - public function getLabel(string $tag): string |
|
64 | - { |
|
65 | - if (substr($tag, -4) === '_ACT') { |
|
66 | - return Registry::elementFactory()->make(substr('INDI:SOUR:_ACT', 0, -strlen($tag)) . $tag)->label(); |
|
67 | - } |
|
68 | - return ''; |
|
69 | - } |
|
59 | + /** |
|
60 | + * {@inheritDoc} |
|
61 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\CustomSimpleTagEditorInterface::getLabel() |
|
62 | + */ |
|
63 | + public function getLabel(string $tag): string |
|
64 | + { |
|
65 | + if (substr($tag, -4) === '_ACT') { |
|
66 | + return Registry::elementFactory()->make(substr('INDI:SOUR:_ACT', 0, -strlen($tag)) . $tag)->label(); |
|
67 | + } |
|
68 | + return ''; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * {@inheritDoc} |
|
73 | - * @see \MyArtJaub\Webtrees\Contracts\Hooks\CustomSimpleTagEditorInterface::editForm() |
|
74 | - */ |
|
75 | - public function editForm(string $tag, string $id, string $name, string $value, Tree $tree): string |
|
76 | - { |
|
77 | - if (substr($tag, -4) === '_ACT') { |
|
78 | - return Registry::elementFactory()->make(substr('INDI:SOUR:_ACT', 0, -strlen($tag)) . $tag) |
|
79 | - ->edit($id, $name, $value, $tree); |
|
80 | - } |
|
81 | - return ''; |
|
82 | - } |
|
71 | + /** |
|
72 | + * {@inheritDoc} |
|
73 | + * @see \MyArtJaub\Webtrees\Contracts\Hooks\CustomSimpleTagEditorInterface::editForm() |
|
74 | + */ |
|
75 | + public function editForm(string $tag, string $id, string $name, string $value, Tree $tree): string |
|
76 | + { |
|
77 | + if (substr($tag, -4) === '_ACT') { |
|
78 | + return Registry::elementFactory()->make(substr('INDI:SOUR:_ACT', 0, -strlen($tag)) . $tag) |
|
79 | + ->edit($id, $name, $value, $tree); |
|
80 | + } |
|
81 | + return ''; |
|
82 | + } |
|
83 | 83 | } |