forked from romansklenar/nette-datagrid
/
IDataSource.php
90 lines (73 loc) · 1.87 KB
/
IDataSource.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace DataGrid\DataSources;
/**
* An interface which provides main data logic for DataGrid
* @author Michael Moravec
* @author Štěpán Svoboda
*/
interface IDataSource extends \Countable, \IteratorAggregate
{
/**#@+ ordering types */
const ASCENDING = 'ASC';
const DESCENDING = 'DESC';
/**#@-*/
/**#@+ filter operations */
const EQUAL = '=';
const NOT_EQUAL = '!=';
const GREATER = '>';
const GREATER_OR_EQUAL = '>=';
const LESS = '<';
const LESS_OR_EQUAL = '<=';
const LIKE = 'LIKE';
const NOT_LIKE = 'NOT LIKE';
const IS_NULL = 'IS NULL';
const IS_NOT_NULL = 'IS NOT NULL';
/**#@-*/
/**#@+ filter chain types */
const CHAIN_AND = 'AND';
const CHAIN_OR = 'OR';
/**#@-*/
/**
* Get list of columns available in datasource
* @return array
*/
function getColumns();
/**
* Does datasource have column of given name?
*
* @return boolean
*/
function hasColumn($name);
/**
* Return distinct values for a selectbox filter
* @param string Column name
* @return array
*/
function getFilterItems($column);
/**
* Add filtering onto specified column
* @param string column name
* @param string filter
* @param string|array operation mode
* @param string chain type (if third argument is array)
* @throws \InvalidArgumentException
* @return IDataSource
*/
function filter($column, $operation = IDataSource::EQUAL, $value = NULL, $chainType = NULL);
/**
* Adds ordering to specified column
* @param string column name
* @param string one of ordering types
* @throws \InvalidArgumentException
* @return IDataSource
*/
function sort($column, $order = IDataSource::ASCENDING);
/**
* Reduce the result starting from $start to have $count rows
* @param int the number of results to obtain
* @param int the offset
* @throws \OutOfRangeException
* @return IDataSource
*/
function reduce($count, $start = 0);
}