1 | <?php |
||
22 | class LocationParser implements ValueParser { |
||
23 | |||
24 | private $geocoder; |
||
25 | private $useAddressAsTitle; |
||
26 | |||
27 | /** |
||
28 | * @deprecated Use newInstance instead |
||
29 | */ |
||
30 | 11 | public function __construct( $enableLegacyCrud = true ) { |
|
31 | 11 | if ( $enableLegacyCrud ) { |
|
32 | $this->geocoder = MapsFactory::newDefault()->newGeocoder(); |
||
33 | $this->useAddressAsTitle = false; |
||
34 | } |
||
35 | 11 | } |
|
36 | |||
37 | /** |
||
38 | * @param Geocoder $geocoder |
||
39 | * @param bool $useAddressAsTitle |
||
40 | * @return self |
||
41 | */ |
||
42 | 11 | public static function newInstance( Geocoder $geocoder, $useAddressAsTitle = false ) { |
|
48 | |||
49 | /** |
||
50 | * @see StringValueParser::stringParse |
||
51 | * |
||
52 | * @since 3.0 |
||
53 | * |
||
54 | * @param string $value |
||
55 | * |
||
56 | * @return Location |
||
57 | * @throws ParseException |
||
58 | */ |
||
59 | 11 | public function parse( $value ) { |
|
94 | |||
95 | 9 | private function setTitleOrLink( Location $location, $titleOrLink ) { |
|
103 | |||
104 | 9 | private function isLink( $value ) { |
|
107 | |||
108 | 3 | private function setLink( Location $location, $link ) { |
|
112 | |||
113 | 3 | private function getExpandedLink( $link ) { |
|
126 | |||
127 | /** |
||
128 | * @param string $location |
||
129 | * |
||
130 | * @return LatLongValue |
||
131 | * @throws ParseException |
||
132 | */ |
||
133 | 11 | private function stringToLatLongValue( $location ) { |
|
149 | |||
150 | /** |
||
151 | * @param string $coordsOrAddress |
||
152 | * |
||
153 | * @return boolean |
||
154 | */ |
||
155 | 2 | private function isAddress( $coordsOrAddress ) { |
|
167 | |||
168 | } |
||
169 |