Completed
Pull Request — 3.1 (#218)
by Jason
07:57
created
tests/Extension/LocationExtension.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@
 block discarded – undo
11 11
  */
12 12
 class LocationExtension extends DataExtension implements TestOnly
13 13
 {
14
-    /**
15
-     * @param $url
16
-     * @return string
17
-     */
18
-    public function updateWebsiteURL(&$url)
19
-    {
20
-        $url = 'foo';
21
-    }
14
+	/**
15
+	 * @param $url
16
+	 * @return string
17
+	 */
18
+	public function updateWebsiteURL(&$url)
19
+	{
20
+		$url = 'foo';
21
+	}
22 22
 }
Please login to merge, or discard this patch.
tests/Model/ExtendedLocation.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@
 block discarded – undo
12 12
  */
13 13
 class ExtendedLocation extends Location implements TestOnly
14 14
 {
15
-    /**
16
-     * @var array
17
-     */
18
-    private static $extensions = [
19
-        LocationExtension::class,
20
-    ];
15
+	/**
16
+	 * @var array
17
+	 */
18
+	private static $extensions = [
19
+		LocationExtension::class,
20
+	];
21 21
 }
Please login to merge, or discard this patch.
src/pages/LocatorController.php 2 patches
Indentation   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -18,131 +18,131 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class LocatorController extends \PageController
20 20
 {
21
-    /**
22
-     * @var array
23
-     */
24
-    private static $allowed_actions = [
25
-        'xml',
26
-        'json',
27
-    ];
28
-
29
-    /**
30
-     * @var array
31
-     */
32
-    private static $base_filter = [];
33
-
34
-    /**
35
-     * @var array
36
-     */
37
-    private static $base_exclude = [
38
-        'Lat' => 0,
39
-        'Lng' => 0,
40
-    ];
41
-
42
-    /**
43
-     * @var array
44
-     */
45
-    private static $base_filter_any = [];
46
-
47
-    /**
48
-     * @var bool
49
-     */
50
-    private static $bootstrapify = true;
51
-
52
-    /**
53
-     * ID of map container
54
-     *
55
-     * @var string
56
-     */
57
-    private static $map_container = 'map';
58
-
59
-    /**
60
-     * class of location list container
61
-     *
62
-     * @var string
63
-     */
64
-    private static $list_container = 'loc-list';
65
-
66
-    /**
67
-     * GET variable which, if isset, will trigger storeLocator init and return XML
68
-     *
69
-     * @var string
70
-     */
71
-    private static $query_trigger = 'action_doFilterLocations';
72
-
73
-    /**
74
-     * @var DataList|ArrayList
75
-     */
76
-    protected $locations;
77
-
78
-    /**
79
-     * Set Requirements based on input from CMS
80
-     */
81
-    public function init()
82
-    {
83
-        parent::init();
84
-        // google maps api key
85
-        $key = Config::inst()->get(GoogleGeocoder::class, 'map_api_key');
86
-        Requirements::javascript('https://maps.google.com/maps/api/js?key=' . $key);
87
-
88
-        // prevent init of map if no query
89
-        $request = Controller::curr()->getRequest();
90
-
91
-        if ($this->getTrigger($request)) {
92
-            $locations = $this->getLocations();
93
-
94
-            if ($locations) {
95
-                $featuredInList = ($locations->filter('Featured', true)->count() > 0);
96
-                $defaultCoords = $this->getAddressSearchCoords() ?
97
-                    $this->getAddressSearchCoords() :
98
-                    new ArrayData([
99
-                        "Lat" => 0,
100
-                        "Lng" => 0,
101
-                    ]);
102
-
103
-                $featured = $featuredInList
104
-                    ? 'featuredLocations: true'
105
-                    : 'featuredLocations: false';
106
-
107
-                // map config based on user input in Settings tab
108
-                $limit = Config::inst()->get(LocatorController::class, 'limit');
109
-                if ($limit < 1) {
110
-                    $limit = -1;
111
-                }
112
-                $load = 'fullMapStart: true, storeLimit: ' . $limit . ', maxDistance: true,';
113
-
114
-                $listTemplatePath = $this->getListTemplate();
115
-                $infowindowTemplatePath = $this->getInfoWindowTemplate();
116
-
117
-                $kilometer = ($this->data()->Unit == 'km') ? "lengthUnit: 'km'" : "lengthUnit: 'm'";
118
-
119
-                // pass GET variables to xml action
120
-                $vars = $this->request->getVars();
121
-                unset($vars['url']);
122
-                $url = '';
123
-                if (count($vars)) {
124
-                    $url .= '?' . http_build_query($vars);
125
-                }
126
-                $link = Controller::join_links($this->Link(), 'xml.xml', $url);
127
-
128
-                // containers
129
-                $map_id = Config::inst()->get(LocatorController::class, 'map_container');
130
-                $list_class = Config::inst()->get(LocatorController::class, 'list_container');
131
-
132
-                $mapStyle = '';
133
-                if ($stylePath = $this->getMapStyleJSONPath()) {
134
-                    if ($style = file_get_contents($stylePath)) {
135
-                        $mapStyle = "styles: {$style},";
136
-                    }
137
-                };
138
-
139
-                $markerImage = '';
140
-                if ($imagePath = $this->getMarkerIcon()) {
141
-                    $markerImage = "markerImg: '{$imagePath}',";
142
-                }
143
-
144
-                // init map
145
-                Requirements::customScript("
21
+	/**
22
+	 * @var array
23
+	 */
24
+	private static $allowed_actions = [
25
+		'xml',
26
+		'json',
27
+	];
28
+
29
+	/**
30
+	 * @var array
31
+	 */
32
+	private static $base_filter = [];
33
+
34
+	/**
35
+	 * @var array
36
+	 */
37
+	private static $base_exclude = [
38
+		'Lat' => 0,
39
+		'Lng' => 0,
40
+	];
41
+
42
+	/**
43
+	 * @var array
44
+	 */
45
+	private static $base_filter_any = [];
46
+
47
+	/**
48
+	 * @var bool
49
+	 */
50
+	private static $bootstrapify = true;
51
+
52
+	/**
53
+	 * ID of map container
54
+	 *
55
+	 * @var string
56
+	 */
57
+	private static $map_container = 'map';
58
+
59
+	/**
60
+	 * class of location list container
61
+	 *
62
+	 * @var string
63
+	 */
64
+	private static $list_container = 'loc-list';
65
+
66
+	/**
67
+	 * GET variable which, if isset, will trigger storeLocator init and return XML
68
+	 *
69
+	 * @var string
70
+	 */
71
+	private static $query_trigger = 'action_doFilterLocations';
72
+
73
+	/**
74
+	 * @var DataList|ArrayList
75
+	 */
76
+	protected $locations;
77
+
78
+	/**
79
+	 * Set Requirements based on input from CMS
80
+	 */
81
+	public function init()
82
+	{
83
+		parent::init();
84
+		// google maps api key
85
+		$key = Config::inst()->get(GoogleGeocoder::class, 'map_api_key');
86
+		Requirements::javascript('https://maps.google.com/maps/api/js?key=' . $key);
87
+
88
+		// prevent init of map if no query
89
+		$request = Controller::curr()->getRequest();
90
+
91
+		if ($this->getTrigger($request)) {
92
+			$locations = $this->getLocations();
93
+
94
+			if ($locations) {
95
+				$featuredInList = ($locations->filter('Featured', true)->count() > 0);
96
+				$defaultCoords = $this->getAddressSearchCoords() ?
97
+					$this->getAddressSearchCoords() :
98
+					new ArrayData([
99
+						"Lat" => 0,
100
+						"Lng" => 0,
101
+					]);
102
+
103
+				$featured = $featuredInList
104
+					? 'featuredLocations: true'
105
+					: 'featuredLocations: false';
106
+
107
+				// map config based on user input in Settings tab
108
+				$limit = Config::inst()->get(LocatorController::class, 'limit');
109
+				if ($limit < 1) {
110
+					$limit = -1;
111
+				}
112
+				$load = 'fullMapStart: true, storeLimit: ' . $limit . ', maxDistance: true,';
113
+
114
+				$listTemplatePath = $this->getListTemplate();
115
+				$infowindowTemplatePath = $this->getInfoWindowTemplate();
116
+
117
+				$kilometer = ($this->data()->Unit == 'km') ? "lengthUnit: 'km'" : "lengthUnit: 'm'";
118
+
119
+				// pass GET variables to xml action
120
+				$vars = $this->request->getVars();
121
+				unset($vars['url']);
122
+				$url = '';
123
+				if (count($vars)) {
124
+					$url .= '?' . http_build_query($vars);
125
+				}
126
+				$link = Controller::join_links($this->Link(), 'xml.xml', $url);
127
+
128
+				// containers
129
+				$map_id = Config::inst()->get(LocatorController::class, 'map_container');
130
+				$list_class = Config::inst()->get(LocatorController::class, 'list_container');
131
+
132
+				$mapStyle = '';
133
+				if ($stylePath = $this->getMapStyleJSONPath()) {
134
+					if ($style = file_get_contents($stylePath)) {
135
+						$mapStyle = "styles: {$style},";
136
+					}
137
+				};
138
+
139
+				$markerImage = '';
140
+				if ($imagePath = $this->getMarkerIcon()) {
141
+					$markerImage = "markerImg: '{$imagePath}',";
142
+				}
143
+
144
+				// init map
145
+				Requirements::customScript("
146 146
                 $(function(){
147 147
                     $('#map-container').storeLocator({
148 148
                         {$load}
@@ -171,195 +171,195 @@  discard block
 block discarded – undo
171 171
                     });
172 172
                 });
173 173
             ", 'jquery-locator');
174
-            }
175
-        }
176
-    }
177
-
178
-    /**
179
-     * @param HTTPRequest $request
180
-     *
181
-     * @return bool
182
-     */
183
-    public function getTrigger(HTTPRequest $request = null)
184
-    {
185
-        if ($request === null) {
186
-            $request = $this->getRequest();
187
-        }
188
-        $trigger = $request->getVar(Config::inst()->get(LocatorController::class, 'query_trigger'));
189
-
190
-        return isset($trigger);
191
-    }
192
-
193
-    /**
194
-     * @return ArrayList|DataList
195
-     */
196
-    public function getLocations()
197
-    {
198
-        if (!$this->locations) {
199
-            $this->setLocations($this->request);
200
-        }
201
-
202
-        return $this->locations;
203
-    }
204
-
205
-    /**
206
-     * @param HTTPRequest|null $request
207
-     *
208
-     * @return $this
209
-     */
210
-    public function setLocations(HTTPRequest $request = null)
211
-    {
212
-
213
-        if ($request === null) {
214
-            $request = $this->request;
215
-        }
216
-        $filter = $this->config()->get('base_filter');
217
-
218
-        $categoryVar = $this->data()->config()->get('category_var');
219
-        if ($request->getVar($categoryVar)) {
220
-            $filter['Categories.ID'] = $request->getVar($categoryVar);
221
-        } else {
222
-            if ($this->getPageCategories()->exists()) {
223
-                foreach ($this->getPageCategories() as $category) {
224
-                    $filter['Categories.ID'][] = $category->ID;
225
-                }
226
-            }
227
-        }
228
-
229
-        $this->extend('updateLocatorFilter', $filter, $request);
230
-
231
-        $filterAny = $this->config()->get('base_filter_any');
232
-        $this->extend('updateLocatorFilterAny', $filterAny, $request);
233
-
234
-        $exclude = $this->config()->get('base_exclude');
235
-        $this->extend('updateLocatorExclude', $exclude, $request);
236
-
237
-        $class = $this->data()->ClassName;
238
-        $locations = $class::get_locations($filter, $filterAny, $exclude);
239
-        $locations = DataToArrayListHelper::to_array_list($locations);
240
-
241
-        //allow for adjusting list post possible distance calculation
242
-        $this->extend('updateLocationList', $locations);
243
-
244
-        if ($locations->canSortBy('Distance')) {
245
-            $locations = $locations->sort('Distance');
246
-        }
247
-
248
-        if ($this->getShowRadius()) {
249
-            $radiusVar = $this->data()->config()->get('radius_var');
250
-
251
-            if ($radius = (int)$request->getVar($radiusVar)) {
252
-                $locations = $locations->filterByCallback(function ($location) use (&$radius) {
253
-                    return $location->Distance <= $radius;
254
-                });
255
-            }
256
-        }
257
-
258
-        //allow for returning list to be set as
259
-        $this->extend('updateListType', $locations);
260
-
261
-        $limit = $this->getLimit();
262
-        if ($limit > 0) {
263
-            $locations = $locations->limit($limit);
264
-        }
265
-
266
-        $this->locations = $locations;
267
-
268
-        return $this;
269
-    }
270
-
271
-    /**
272
-     * @return ArrayData|boolean
273
-     */
274
-    public function getAddressSearchCoords()
275
-    {
276
-        $addressVar = Config::inst()->get(DistanceDataExtension::class, 'address_var');
277
-        if (!$this->request->getVar($addressVar)) {
278
-            return false;
279
-        }
280
-        if (class_exists(GoogleGeocoder::class)) {
281
-            $geocoder = new GoogleGeocoder($this->request->getVar($addressVar));
282
-            $response = $geocoder->getResult();
283
-            $lat = $response->getLatitude();
284
-            $lng = $response->getLongitude();
285
-
286
-            return new ArrayData([
287
-                "Lat" => $lat,
288
-                "Lng" => $lng,
289
-            ]);
290
-        }
291
-    }
292
-
293
-    /**
294
-     * @param HTTPRequest $request
295
-     *
296
-     * @return \SilverStripe\View\ViewableData_Customised
297
-     */
298
-    public function index(HTTPRequest $request)
299
-    {
300
-        if ($this->getTrigger($request)) {
301
-            $locations = $this->getLocations();
302
-        } else {
303
-            $locations = ArrayList::create();
304
-        }
305
-
306
-        return $this->customise(array(
307
-            'Locations' => $locations,
308
-        ));
309
-    }
310
-
311
-    /**
312
-     * Renders locations in xml format
313
-     *
314
-     * @return \SilverStripe\ORM\FieldType\DBHTMLText
315
-     */
316
-    public function xml()
317
-    {
318
-        $this->getResponse()->addHeader("Content-Type", "application/xml");
319
-        $data = new ArrayData(array(
320
-            "Locations" => $this->getLocations(),
321
-            "AddressCoords" => $this->getAddressSearchCoords(),
322
-        ));
323
-
324
-        return $data->renderWith('Dynamic/Locator/Data/XML');
325
-    }
326
-
327
-    /**
328
-     * Renders locations in json format
329
-     *
330
-     * @return \SilverStripe\ORM\FieldType\DBHTMLText
331
-     */
332
-    public function json()
333
-    {
334
-        $this->getResponse()->addHeader("Content-Type", "application/json");
335
-        $data = new ArrayData(array(
336
-            "Locations" => $this->getLocations(),
337
-            "AddressCoords" => $this->getAddressSearchCoords(),
338
-        ));
339
-
340
-        return $data->renderWith('Dynamic/Locator/Data/JSON');
341
-    }
342
-
343
-    /**
344
-     * LocationSearch form.
345
-     *
346
-     * Search form for locations, updates map and results list via AJAX
347
-     *
348
-     * @return \SilverStripe\Forms\Form
349
-     */
350
-    public function LocationSearch()
351
-    {
352
-
353
-        $form = LocatorForm::create($this, 'LocationSearch');
354
-        if (class_exists(BootstrapForm::class) && $this->config()->get('bootstrapify')) {
355
-            $form->Fields()->bootstrapify();
356
-            $form->Actions()->bootstrapify();
357
-        }
358
-
359
-        return $form
360
-            ->setFormMethod('GET')
361
-            ->setFormAction($this->Link())
362
-            ->disableSecurityToken()
363
-            ->loadDataFrom($this->request->getVars());
364
-    }
174
+			}
175
+		}
176
+	}
177
+
178
+	/**
179
+	 * @param HTTPRequest $request
180
+	 *
181
+	 * @return bool
182
+	 */
183
+	public function getTrigger(HTTPRequest $request = null)
184
+	{
185
+		if ($request === null) {
186
+			$request = $this->getRequest();
187
+		}
188
+		$trigger = $request->getVar(Config::inst()->get(LocatorController::class, 'query_trigger'));
189
+
190
+		return isset($trigger);
191
+	}
192
+
193
+	/**
194
+	 * @return ArrayList|DataList
195
+	 */
196
+	public function getLocations()
197
+	{
198
+		if (!$this->locations) {
199
+			$this->setLocations($this->request);
200
+		}
201
+
202
+		return $this->locations;
203
+	}
204
+
205
+	/**
206
+	 * @param HTTPRequest|null $request
207
+	 *
208
+	 * @return $this
209
+	 */
210
+	public function setLocations(HTTPRequest $request = null)
211
+	{
212
+
213
+		if ($request === null) {
214
+			$request = $this->request;
215
+		}
216
+		$filter = $this->config()->get('base_filter');
217
+
218
+		$categoryVar = $this->data()->config()->get('category_var');
219
+		if ($request->getVar($categoryVar)) {
220
+			$filter['Categories.ID'] = $request->getVar($categoryVar);
221
+		} else {
222
+			if ($this->getPageCategories()->exists()) {
223
+				foreach ($this->getPageCategories() as $category) {
224
+					$filter['Categories.ID'][] = $category->ID;
225
+				}
226
+			}
227
+		}
228
+
229
+		$this->extend('updateLocatorFilter', $filter, $request);
230
+
231
+		$filterAny = $this->config()->get('base_filter_any');
232
+		$this->extend('updateLocatorFilterAny', $filterAny, $request);
233
+
234
+		$exclude = $this->config()->get('base_exclude');
235
+		$this->extend('updateLocatorExclude', $exclude, $request);
236
+
237
+		$class = $this->data()->ClassName;
238
+		$locations = $class::get_locations($filter, $filterAny, $exclude);
239
+		$locations = DataToArrayListHelper::to_array_list($locations);
240
+
241
+		//allow for adjusting list post possible distance calculation
242
+		$this->extend('updateLocationList', $locations);
243
+
244
+		if ($locations->canSortBy('Distance')) {
245
+			$locations = $locations->sort('Distance');
246
+		}
247
+
248
+		if ($this->getShowRadius()) {
249
+			$radiusVar = $this->data()->config()->get('radius_var');
250
+
251
+			if ($radius = (int)$request->getVar($radiusVar)) {
252
+				$locations = $locations->filterByCallback(function ($location) use (&$radius) {
253
+					return $location->Distance <= $radius;
254
+				});
255
+			}
256
+		}
257
+
258
+		//allow for returning list to be set as
259
+		$this->extend('updateListType', $locations);
260
+
261
+		$limit = $this->getLimit();
262
+		if ($limit > 0) {
263
+			$locations = $locations->limit($limit);
264
+		}
265
+
266
+		$this->locations = $locations;
267
+
268
+		return $this;
269
+	}
270
+
271
+	/**
272
+	 * @return ArrayData|boolean
273
+	 */
274
+	public function getAddressSearchCoords()
275
+	{
276
+		$addressVar = Config::inst()->get(DistanceDataExtension::class, 'address_var');
277
+		if (!$this->request->getVar($addressVar)) {
278
+			return false;
279
+		}
280
+		if (class_exists(GoogleGeocoder::class)) {
281
+			$geocoder = new GoogleGeocoder($this->request->getVar($addressVar));
282
+			$response = $geocoder->getResult();
283
+			$lat = $response->getLatitude();
284
+			$lng = $response->getLongitude();
285
+
286
+			return new ArrayData([
287
+				"Lat" => $lat,
288
+				"Lng" => $lng,
289
+			]);
290
+		}
291
+	}
292
+
293
+	/**
294
+	 * @param HTTPRequest $request
295
+	 *
296
+	 * @return \SilverStripe\View\ViewableData_Customised
297
+	 */
298
+	public function index(HTTPRequest $request)
299
+	{
300
+		if ($this->getTrigger($request)) {
301
+			$locations = $this->getLocations();
302
+		} else {
303
+			$locations = ArrayList::create();
304
+		}
305
+
306
+		return $this->customise(array(
307
+			'Locations' => $locations,
308
+		));
309
+	}
310
+
311
+	/**
312
+	 * Renders locations in xml format
313
+	 *
314
+	 * @return \SilverStripe\ORM\FieldType\DBHTMLText
315
+	 */
316
+	public function xml()
317
+	{
318
+		$this->getResponse()->addHeader("Content-Type", "application/xml");
319
+		$data = new ArrayData(array(
320
+			"Locations" => $this->getLocations(),
321
+			"AddressCoords" => $this->getAddressSearchCoords(),
322
+		));
323
+
324
+		return $data->renderWith('Dynamic/Locator/Data/XML');
325
+	}
326
+
327
+	/**
328
+	 * Renders locations in json format
329
+	 *
330
+	 * @return \SilverStripe\ORM\FieldType\DBHTMLText
331
+	 */
332
+	public function json()
333
+	{
334
+		$this->getResponse()->addHeader("Content-Type", "application/json");
335
+		$data = new ArrayData(array(
336
+			"Locations" => $this->getLocations(),
337
+			"AddressCoords" => $this->getAddressSearchCoords(),
338
+		));
339
+
340
+		return $data->renderWith('Dynamic/Locator/Data/JSON');
341
+	}
342
+
343
+	/**
344
+	 * LocationSearch form.
345
+	 *
346
+	 * Search form for locations, updates map and results list via AJAX
347
+	 *
348
+	 * @return \SilverStripe\Forms\Form
349
+	 */
350
+	public function LocationSearch()
351
+	{
352
+
353
+		$form = LocatorForm::create($this, 'LocationSearch');
354
+		if (class_exists(BootstrapForm::class) && $this->config()->get('bootstrapify')) {
355
+			$form->Fields()->bootstrapify();
356
+			$form->Actions()->bootstrapify();
357
+		}
358
+
359
+		return $form
360
+			->setFormMethod('GET')
361
+			->setFormAction($this->Link())
362
+			->disableSecurityToken()
363
+			->loadDataFrom($this->request->getVars());
364
+	}
365 365
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         parent::init();
84 84
         // google maps api key
85 85
         $key = Config::inst()->get(GoogleGeocoder::class, 'map_api_key');
86
-        Requirements::javascript('https://maps.google.com/maps/api/js?key=' . $key);
86
+        Requirements::javascript('https://maps.google.com/maps/api/js?key='.$key);
87 87
 
88 88
         // prevent init of map if no query
89 89
         $request = Controller::curr()->getRequest();
@@ -94,8 +94,7 @@  discard block
 block discarded – undo
94 94
             if ($locations) {
95 95
                 $featuredInList = ($locations->filter('Featured', true)->count() > 0);
96 96
                 $defaultCoords = $this->getAddressSearchCoords() ?
97
-                    $this->getAddressSearchCoords() :
98
-                    new ArrayData([
97
+                    $this->getAddressSearchCoords() : new ArrayData([
99 98
                         "Lat" => 0,
100 99
                         "Lng" => 0,
101 100
                     ]);
@@ -109,7 +108,7 @@  discard block
 block discarded – undo
109 108
                 if ($limit < 1) {
110 109
                     $limit = -1;
111 110
                 }
112
-                $load = 'fullMapStart: true, storeLimit: ' . $limit . ', maxDistance: true,';
111
+                $load = 'fullMapStart: true, storeLimit: '.$limit.', maxDistance: true,';
113 112
 
114 113
                 $listTemplatePath = $this->getListTemplate();
115 114
                 $infowindowTemplatePath = $this->getInfoWindowTemplate();
@@ -121,7 +120,7 @@  discard block
 block discarded – undo
121 120
                 unset($vars['url']);
122 121
                 $url = '';
123 122
                 if (count($vars)) {
124
-                    $url .= '?' . http_build_query($vars);
123
+                    $url .= '?'.http_build_query($vars);
125 124
                 }
126 125
                 $link = Controller::join_links($this->Link(), 'xml.xml', $url);
127 126
 
@@ -248,8 +247,8 @@  discard block
 block discarded – undo
248 247
         if ($this->getShowRadius()) {
249 248
             $radiusVar = $this->data()->config()->get('radius_var');
250 249
 
251
-            if ($radius = (int)$request->getVar($radiusVar)) {
252
-                $locations = $locations->filterByCallback(function ($location) use (&$radius) {
250
+            if ($radius = (int) $request->getVar($radiusVar)) {
251
+                $locations = $locations->filterByCallback(function($location) use (&$radius) {
253 252
                     return $location->Distance <= $radius;
254 253
                 });
255 254
             }
Please login to merge, or discard this patch.
tests/pages/LocatorControllerTest.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -17,78 +17,78 @@
 block discarded – undo
17 17
 class LocatorControllerTest extends FunctionalTest
18 18
 {
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    protected static $fixture_file = '../fixtures.yml';
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected static $fixture_file = '../fixtures.yml';
24 24
 
25
-    /**
26
-     * @var bool
27
-     */
28
-    protected static $use_draft_site = true;
25
+	/**
26
+	 * @var bool
27
+	 */
28
+	protected static $use_draft_site = true;
29 29
 
30
-    /**
31
-     *
32
-     */
33
-    public function testIndex()
34
-    {
35
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
36
-        $controller = LocatorController::create($locator);
37
-        $this->assertInstanceOf(ViewableData::class, $controller->index($controller->getRequest()));
38
-    }
30
+	/**
31
+	 *
32
+	 */
33
+	public function testIndex()
34
+	{
35
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
36
+		$controller = LocatorController::create($locator);
37
+		$this->assertInstanceOf(ViewableData::class, $controller->index($controller->getRequest()));
38
+	}
39 39
 
40
-    /**
41
-     *
42
-     */
43
-    public function testXml()
44
-    {
45
-        /** @var Locator $locator */
46
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
47
-        $page = $this->get($locator->Link('xml'));
40
+	/**
41
+	 *
42
+	 */
43
+	public function testXml()
44
+	{
45
+		/** @var Locator $locator */
46
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
47
+		$page = $this->get($locator->Link('xml'));
48 48
 
49
-        $this->assertEquals(200, $page->getStatusCode());
50
-        $this->assertEquals('application/xml', $page->getHeader('content-type'));
49
+		$this->assertEquals(200, $page->getStatusCode());
50
+		$this->assertEquals('application/xml', $page->getHeader('content-type'));
51 51
 
52
-        $dom = new \DOMDocument();
53
-        // true if it loads, false if it doesn't
54
-        $valid = $dom->loadXML($page->getBody());
55
-        $this->assertTrue($valid);
56
-    }
52
+		$dom = new \DOMDocument();
53
+		// true if it loads, false if it doesn't
54
+		$valid = $dom->loadXML($page->getBody());
55
+		$this->assertTrue($valid);
56
+	}
57 57
 
58
-    /**
59
-     *
60
-     */
61
-    public function testJson()
62
-    {
63
-        /** @var Locator $locator */
64
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
65
-        $page = $this->get($locator->Link('json'));
58
+	/**
59
+	 *
60
+	 */
61
+	public function testJson()
62
+	{
63
+		/** @var Locator $locator */
64
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
65
+		$page = $this->get($locator->Link('json'));
66 66
 
67
-        $this->assertEquals(200, $page->getStatusCode());
68
-        $this->assertEquals('application/json', $page->getHeader('content-type'));
67
+		$this->assertEquals(200, $page->getStatusCode());
68
+		$this->assertEquals('application/json', $page->getHeader('content-type'));
69 69
 
70
-        $json = json_decode($page->getBody());
71
-        // if it is null its not valid
72
-        $this->assertNotNull($json);
73
-    }
70
+		$json = json_decode($page->getBody());
71
+		// if it is null its not valid
72
+		$this->assertNotNull($json);
73
+	}
74 74
 
75
-    /**
76
-     *
77
-     */
78
-    public function testLocationSearch()
79
-    {
80
-        $locator = $this->objFromFixture(Locator::class, 'locator1');
81
-        $object = LocatorController::create($locator);
82
-        $form = $object->LocationSearch();
83
-        $this->assertInstanceOf(Form::class, $form);
75
+	/**
76
+	 *
77
+	 */
78
+	public function testLocationSearch()
79
+	{
80
+		$locator = $this->objFromFixture(Locator::class, 'locator1');
81
+		$object = LocatorController::create($locator);
82
+		$form = $object->LocationSearch();
83
+		$this->assertInstanceOf(Form::class, $form);
84 84
 
85
-        $category = $this->objFromFixture(LocationCategory::class, 'service');
86
-        $category2 = $this->objFromFixture(LocationCategory::class, 'manufacturing');
87
-        $locator->Categories()->add($category);
88
-        $locator->Categories()->add($category2);
85
+		$category = $this->objFromFixture(LocationCategory::class, 'service');
86
+		$category2 = $this->objFromFixture(LocationCategory::class, 'manufacturing');
87
+		$locator->Categories()->add($category);
88
+		$locator->Categories()->add($category2);
89 89
 
90
-        $form = $object->LocationSearch();
91
-        $fields = $form->Fields();
92
-        $this->assertInstanceOf(FieldList::class, $fields);
93
-    }
90
+		$form = $object->LocationSearch();
91
+		$fields = $form->Fields();
92
+		$this->assertInstanceOf(FieldList::class, $fields);
93
+	}
94 94
 }
Please login to merge, or discard this patch.