Refactor filter widget to use an approach much like ReportContainer

This commit is contained in:
Samuel Georges 2015-02-28 12:50:02 +11:00
parent 85c47c4e01
commit 6e54fea23f
1 changed files with 28 additions and 11 deletions

View File

@ -15,6 +15,25 @@ use ApplicationException;
*/
class Filter extends WidgetBase
{
//
// Configurable properties
//
/**
* @var array Scope definition configuration.
*/
public $scopes;
/**
* @var string The context of this filter, scopes that do not belong
* to this context will not be shown.
*/
protected $context = null;
//
// Object properties
//
/**
* {@inheritDoc}
*/
@ -35,12 +54,6 @@ class Filter extends WidgetBase
*/
protected $scopeModels = [];
/**
* @var string The context of this filter, scopes that do not belong
* to this context will not be shown.
*/
protected $activeContext = null;
/**
* @var array List of CSS classes to apply to the filter container element
*/
@ -51,7 +64,10 @@ class Filter extends WidgetBase
*/
public function init()
{
$this->activeContext = $this->getConfig('context');
$this->fillFromConfig([
'scopes',
'context',
]);
}
/**
@ -241,11 +257,11 @@ class Filter extends WidgetBase
/*
* All scopes
*/
if (!isset($this->config->scopes) || !is_array($this->config->scopes)) {
$this->config->scopes = [];
if (!isset($this->scopes) || !is_array($this->scopes)) {
$this->scopes = [];
}
$this->addScopes($this->config->scopes);
$this->addScopes($this->scopes);
/*
* Extensibility
@ -442,10 +458,11 @@ class Filter extends WidgetBase
/**
* Returns the active context for displaying the filter.
* @return string
*/
public function getContext()
{
return $this->activeContext;
return $this->context;
}
//