1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
5
|
|
|
* |
6
|
|
|
* @package MyArtJaub\Webtrees |
7
|
|
|
* @subpackage GeoDispersion |
8
|
|
|
* @author Jonathan Jaubart <[email protected]> |
9
|
|
|
* @copyright Copyright (c) 2021-2022, Jonathan Jaubart |
10
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
declare(strict_types=1); |
14
|
|
|
|
15
|
|
|
namespace MyArtJaub\Webtrees\Common\GeoDispersion\Config; |
16
|
|
|
|
17
|
|
|
use MyArtJaub\Webtrees\Contracts\GeoDispersion\MapViewConfigInterface; |
18
|
|
|
use MyArtJaub\Webtrees\Contracts\GeoDispersion\PlaceMapperConfigInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Generic implementation of the MapViewConfigInterface |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
class MapViewConfig implements MapViewConfigInterface |
25
|
|
|
{ |
26
|
|
|
private string $map_mapping_property; |
27
|
|
|
private PlaceMapperConfigInterface $mapper_config; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Constructor for MapViewConfig |
31
|
|
|
* |
32
|
|
|
* @param string $map_mapping_property |
33
|
|
|
* @param PlaceMapperConfigInterface $mapper_config |
34
|
|
|
*/ |
35
|
|
|
public function __construct( |
36
|
|
|
string $map_mapping_property, |
37
|
|
|
PlaceMapperConfigInterface $mapper_config = null |
38
|
|
|
) { |
39
|
|
|
$this->map_mapping_property = $map_mapping_property; |
40
|
|
|
$this->mapper_config = $mapper_config ?? new NullPlaceMapperConfig(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritDoc} |
45
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\MapViewConfigInterface::mapMappingProperty() |
46
|
|
|
*/ |
47
|
|
|
public function mapMappingProperty(): string |
48
|
|
|
{ |
49
|
|
|
return $this->map_mapping_property; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritDoc} |
54
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\MapViewConfigInterface::mapperConfig() |
55
|
|
|
*/ |
56
|
|
|
public function mapperConfig(): PlaceMapperConfigInterface |
57
|
|
|
{ |
58
|
|
|
return $this->mapper_config; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* {@inheritDoc} |
63
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\GeoDispersion\MapViewConfigInterface::with() |
64
|
|
|
* @return static |
65
|
|
|
*/ |
66
|
|
|
public function with(string $mapping_property, PlaceMapperConfigInterface $mapper_config): self |
67
|
|
|
{ |
68
|
|
|
$new = clone $this; |
69
|
|
|
$new->map_mapping_property = $mapping_property; |
70
|
|
|
$new->mapper_config = $mapper_config; |
71
|
|
|
return $new; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|