Improve flexibility of scope type properties

Improves the flexibility of scope type properties by removing conditional logic specific to the date and daterange scope types and laying the groundwork for scopes to define their own custom properties that can be loaded from the scope configuration defined by the developer.
This commit is contained in:
Luke Towers 2017-08-05 12:38:20 -06:00 committed by GitHub
parent d7334315a8
commit 962aa32a60
1 changed files with 21 additions and 5 deletions

View File

@ -463,17 +463,33 @@ class Filter extends WidgetBase
}
/*
* Ensure dates options are set
* Ensure scope type options are set
*/
if (!isset($config['minDate'])) {
$scopeObj->minDate = '2000-01-01';
$scopeObj->maxDate = '2099-12-31';
$scopeProperties = [];
switch ($scopeObj->type) {
case 'date':
case 'daterange':
$scopeProperties = [
'minDate' => '2000-01-01',
'maxDate' => '2099-12-31',
'yearRange' => 10,
];
break;
}
foreach ($scopeProperties as $property => $value) {
if (isset($config[$property])) {
$value = $config[$property];
}
$scopeObj->{$property} = $value;
}
$this->allScopes[$name] = $scopeObj;
}
}
/**
* Programatically remove a scope, used for extensibility.
* @param string $scopeName Scope name