icingaweb2/library/Icinga/Protocol/File/Query.php

66 lines
1.3 KiB
PHP
Raw Normal View History

2014-03-19 16:57:11 +01:00
<?php
2014-04-02 12:18:47 +02:00
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
2014-03-19 16:57:11 +01:00
namespace Icinga\Protocol\File;
use Icinga\Data\BaseQuery;
class Query extends BaseQuery
{
private $sortDir;
private $filters = array();
2014-04-01 16:29:09 +02:00
/**
* Nothing to do here
*/
2014-03-19 16:57:11 +01:00
public function applyFilter()
2014-04-01 16:29:09 +02:00
{}
2014-03-19 16:57:11 +01:00
2014-04-01 16:29:09 +02:00
/**
* Sort query result chronological
*
* @param string $dir Sort direction, 'ASC' or 'DESC' (default)
*
* @return Query
*/
2014-03-19 16:57:11 +01:00
public function order($dir)
{
$this->sortDir = ($dir === null || strtoupper(trim($dir)) === 'DESC') ? self::SORT_DESC : self::SORT_ASC;
return $this;
}
2014-04-01 16:29:09 +02:00
/**
* Return true if sorting descending, false otherwise
*
* @return bool
*/
2014-03-19 16:57:11 +01:00
public function sortDesc()
{
return $this->sortDir === self::SORT_DESC;
}
2014-04-01 16:29:09 +02:00
/**
* Add an mandatory filter expression to be applied on this query
*
* @param string $expression the filter expression to be applied
*
* @return Query
*/
public function andWhere($expression)
2014-03-19 16:57:11 +01:00
{
$this->filters[] = $expression;
return $this;
}
2014-04-01 16:29:09 +02:00
/**
* Get filters currently applied on this query
*
* @return array
*/
2014-03-19 16:57:11 +01:00
public function getFilters()
{
return $this->filters;
}
}