@@ -9,8 +9,7 @@ discard block |
||
9 | 9 | * Maps Geocoding API. |
10 | 10 | * @author <@willmorgan> |
11 | 11 | */ |
12 | -class GoogleMapField extends FormField |
|
13 | -{ |
|
12 | +class GoogleMapField extends FormField { |
|
14 | 13 | |
15 | 14 | protected $data; |
16 | 15 | |
@@ -40,8 +39,7 @@ discard block |
||
40 | 39 | * @param string $title The title of the field |
41 | 40 | * @param array $options Various settings for the field |
42 | 41 | */ |
43 | - public function __construct(DataObject $data, $title, $options = array()) |
|
44 | - { |
|
42 | + public function __construct(DataObject $data, $title, $options = array()) { |
|
45 | 43 | $this->data = $data; |
46 | 44 | |
47 | 45 | // Set up fieldnames |
@@ -53,8 +51,7 @@ discard block |
||
53 | 51 | } |
54 | 52 | |
55 | 53 | // Auto generate a name |
56 | - public function getName() |
|
57 | - { |
|
54 | + public function getName() { |
|
58 | 55 | $fieldNames = $this->getOption('field_names'); |
59 | 56 | return sprintf( |
60 | 57 | '%s_%s_%s', |
@@ -68,8 +65,7 @@ discard block |
||
68 | 65 | * Merge options preserving the first level of array keys |
69 | 66 | * @param array $options |
70 | 67 | */ |
71 | - public function setupOptions(array $options) |
|
72 | - { |
|
68 | + public function setupOptions(array $options) { |
|
73 | 69 | $this->options = static::config()->default_options; |
74 | 70 | foreach ($this->options as $name => &$value) { |
75 | 71 | if (isset($options[$name])) { |
@@ -86,8 +82,7 @@ discard block |
||
86 | 82 | * Set up child hidden fields, and optionally the search box. |
87 | 83 | * @return FieldList the children |
88 | 84 | */ |
89 | - public function setupChildren() |
|
90 | - { |
|
85 | + public function setupChildren() { |
|
91 | 86 | $name = $this->getName(); |
92 | 87 | |
93 | 88 | // Create the latitude/longitude hidden fields |
@@ -131,8 +126,7 @@ discard block |
||
131 | 126 | * @see https://developers.google.com/maps/documentation/javascript/reference |
132 | 127 | * {@inheritdoc} |
133 | 128 | */ |
134 | - public function Field($properties = array()) |
|
135 | - { |
|
129 | + public function Field($properties = array()) { |
|
136 | 130 | $jsOptions = array( |
137 | 131 | 'coords' => array( |
138 | 132 | $this->recordFieldData('Latitude'), |
@@ -154,8 +148,7 @@ discard block |
||
154 | 148 | * Set up and include any frontend requirements |
155 | 149 | * @return void |
156 | 150 | */ |
157 | - protected function requireDependencies() |
|
158 | - { |
|
151 | + protected function requireDependencies() { |
|
159 | 152 | $gmapsParams = array( |
160 | 153 | 'callback' => 'googlemapfieldInit', |
161 | 154 | ); |
@@ -170,8 +163,7 @@ discard block |
||
170 | 163 | /** |
171 | 164 | * {@inheritdoc} |
172 | 165 | */ |
173 | - public function setValue($record) |
|
174 | - { |
|
166 | + public function setValue($record) { |
|
175 | 167 | $this->latField->setValue( |
176 | 168 | $record['Latitude'] |
177 | 169 | ); |
@@ -188,8 +180,7 @@ discard block |
||
188 | 180 | * Take the latitude/longitude fields and save them to the DataObject. |
189 | 181 | * {@inheritdoc} |
190 | 182 | */ |
191 | - public function saveInto(DataObjectInterface $record) |
|
192 | - { |
|
183 | + public function saveInto(DataObjectInterface $record) { |
|
193 | 184 | $record->setCastedField($this->childFieldName('Latitude'), $this->latField->dataValue()); |
194 | 185 | $record->setCastedField($this->childFieldName('Longitude'), $this->lngField->dataValue()); |
195 | 186 | $record->setCastedField($this->childFieldName('Zoom'), $this->zoomField->dataValue()); |
@@ -199,25 +190,21 @@ discard block |
||
199 | 190 | /** |
200 | 191 | * @return FieldList The Latitude/Longitude fields |
201 | 192 | */ |
202 | - public function getChildFields() |
|
203 | - { |
|
193 | + public function getChildFields() { |
|
204 | 194 | return $this->children; |
205 | 195 | } |
206 | 196 | |
207 | - protected function childFieldName($name) |
|
208 | - { |
|
197 | + protected function childFieldName($name) { |
|
209 | 198 | $fieldNames = $this->getOption('field_names'); |
210 | 199 | return $fieldNames[$name]; |
211 | 200 | } |
212 | 201 | |
213 | - protected function recordFieldData($name) |
|
214 | - { |
|
202 | + protected function recordFieldData($name) { |
|
215 | 203 | $fieldName = $this->childFieldName($name); |
216 | 204 | return $this->data->$fieldName ?: $this->getDefaultValue($name); |
217 | 205 | } |
218 | 206 | |
219 | - public function getDefaultValue($name) |
|
220 | - { |
|
207 | + public function getDefaultValue($name) { |
|
221 | 208 | $fieldValues = $this->getOption('default_field_values'); |
222 | 209 | return isset($fieldValues[$name]) ? $fieldValues[$name] : null; |
223 | 210 | } |
@@ -225,8 +212,7 @@ discard block |
||
225 | 212 | /** |
226 | 213 | * @return string The VALUE of the Latitude field |
227 | 214 | */ |
228 | - public function getLatData() |
|
229 | - { |
|
215 | + public function getLatData() { |
|
230 | 216 | $fieldNames = $this->getOption('field_names'); |
231 | 217 | return $this->data->$fieldNames['Latitude']; |
232 | 218 | } |
@@ -234,8 +220,7 @@ discard block |
||
234 | 220 | /** |
235 | 221 | * @return string The VALUE of the Longitude field |
236 | 222 | */ |
237 | - public function getLngData() |
|
238 | - { |
|
223 | + public function getLngData() { |
|
239 | 224 | $fieldNames = $this->getOption('field_names'); |
240 | 225 | return $this->data->$fieldNames['Longitude']; |
241 | 226 | } |
@@ -245,8 +230,7 @@ discard block |
||
245 | 230 | * @param string $name The name of the option |
246 | 231 | * @return mixed |
247 | 232 | */ |
248 | - public function getOption($name) |
|
249 | - { |
|
233 | + public function getOption($name) { |
|
250 | 234 | // Quicker execution path for "."-free names |
251 | 235 | if (strpos($name, '.') === false) { |
252 | 236 | if (isset($this->options[$name])) { |
@@ -274,8 +258,7 @@ discard block |
||
274 | 258 | * @param mixed $val The value of said option |
275 | 259 | * @return $this |
276 | 260 | */ |
277 | - public function setOption($name, $val) |
|
278 | - { |
|
261 | + public function setOption($name, $val) { |
|
279 | 262 | // Quicker execution path for "."-free names |
280 | 263 | if (strpos($name, '.') === false) { |
281 | 264 | $this->options[$name] = $val; |