1 | <?php |
||
19 | class MapsFactory { |
||
20 | |||
21 | private $settings; |
||
22 | private $mediaWikiServices; |
||
23 | |||
24 | 26 | private function __construct( array $settings, MediaWikiServices $mediaWikiServices ) { |
|
25 | 26 | $this->settings = $settings; |
|
26 | 26 | $this->mediaWikiServices = $mediaWikiServices; |
|
27 | 26 | } |
|
28 | |||
29 | 26 | public static function newDefault() { |
|
32 | |||
33 | 19 | public function newLocationParser(): LocationParser { |
|
36 | |||
37 | 26 | public function newGeocoder(): Geocoder { |
|
50 | |||
51 | 26 | private function newCoreGeocoder(): Geocoder { |
|
52 | 26 | switch ( $this->settings['egMapsDefaultGeoService'] ) { |
|
53 | 26 | case 'geonames': |
|
54 | if ( $this->settings['egMapsGeoNamesUser'] === '' ) { |
||
55 | return $this->newGoogleGeocoder(); |
||
56 | } |
||
57 | |||
58 | return new GeoNamesGeocoder( |
||
59 | $this->newFileFetcher(), |
||
60 | $this->settings['egMapsGeoNamesUser'] |
||
61 | ); |
||
62 | 26 | case 'google': |
|
63 | return $this->newGoogleGeocoder(); |
||
64 | 26 | case 'nominatim': |
|
65 | 26 | return new NominatimGeocoder( |
|
66 | 26 | $this->newFileFetcher() |
|
67 | ); |
||
68 | default: |
||
69 | return new NullGeocoder(); |
||
70 | } |
||
71 | } |
||
72 | |||
73 | private function newGoogleGeocoder(): Geocoder { |
||
74 | return new GoogleGeocoder( |
||
75 | $this->newFileFetcher(), |
||
76 | $this->settings['egMapsGMaps3ApiKey'], |
||
77 | $this->settings['egMapsGMaps3ApiVersion'] |
||
78 | ); |
||
79 | } |
||
80 | |||
81 | public function getFileFetcher(): FileFetcher { |
||
82 | return $this->newFileFetcher(); |
||
83 | } |
||
84 | |||
85 | 26 | private function newFileFetcher(): FileFetcher { |
|
88 | |||
89 | 26 | private function getMediaWikiCache(): \BagOStuff { |
|
90 | 26 | return wfGetCache( CACHE_ANYTHING ); |
|
91 | } |
||
92 | |||
93 | public function getPageContentFetcher(): PageContentFetcher { |
||
99 | |||
100 | } |
||
101 |