Monitoring/DataView: Add static method fromParams to create a view from a parameters array
refs #4823
This commit is contained in:
parent
d479ab3536
commit
ca6c51aef7
|
@ -99,6 +99,33 @@ abstract class DataView
|
|||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create view from params
|
||||
*
|
||||
* @param array $params
|
||||
* @param array $columns
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function fromParams(array $params, array $columns = null)
|
||||
{
|
||||
$view = new static(Backend::createBackend($params['backend']), $columns);
|
||||
$view->filter($params);
|
||||
$order = isset($params['order']) ? $params['order'] : null;
|
||||
if ($order !== null) {
|
||||
if (strtolower($order) === 'desc') {
|
||||
$order = self::SORT_DESC;
|
||||
} else {
|
||||
$order = self::SORT_ASC;
|
||||
}
|
||||
}
|
||||
$view->sort(
|
||||
isset($params['sort']) ? $params['sort'] : null,
|
||||
$order
|
||||
);
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter rows that match all of the given filters. If a filter is not valid, it's silently ignored
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue