From 99c5024329c7f52052fbff69fed22b7db0b23a4b Mon Sep 17 00:00:00 2001 From: Nic Horstmeier Date: Wed, 12 Oct 2016 15:59:46 -0500 Subject: [PATCH] ENHANCEMENT allow for setting location query class at runtime --- code/pages/Locator.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/code/pages/Locator.php b/code/pages/Locator.php index bb424e4..4b50751 100644 --- a/code/pages/Locator.php +++ b/code/pages/Locator.php @@ -47,6 +47,11 @@ class Locator extends Page */ private static $description = 'Find locations on a map'; + /** + * @var string + */ + private static $location_class = 'Location'; + /** * @return FieldList */ @@ -98,7 +103,8 @@ public static function get_locations( $callback = null ) { - $locations = Location::get()->filter($filter)->exclude($exclude); + $locationClass = Config::inst()->get('Locator', 'location_class'); + $locations = $locationClass::get()->filter($filter)->exclude($exclude); if (!empty($filterAny)) { $locations = $locations->filterAny($filterAny); @@ -196,7 +202,7 @@ class Locator_Controller extends Page_Controller /** * @var DataList|ArrayList */ - private $locations; + protected $locations; /** * Set Requirements based on input from CMS