1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the jquery-querybuilder-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2019 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\JQuery\QueryBuilderBundle\Model; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\JQuery\QueryBuilderBundle\API\QueryBuilderConditionInterface; |
15
|
|
|
use WBW\Bundle\JQuery\QueryBuilderBundle\API\QueryBuilderInputInterface; |
16
|
|
|
use WBW\Bundle\JQuery\QueryBuilderBundle\API\QueryBuilderOperatorInterface; |
17
|
|
|
use WBW\Bundle\JQuery\QueryBuilderBundle\API\QueryBuilderTypeInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* QueryBuilder enumerator. |
21
|
|
|
* |
22
|
|
|
* @author webeweb <https://github.com/webeweb/> |
23
|
|
|
* @package WBW\Bundle\JQuery\QueryBuilderBundle\Model |
24
|
|
|
*/ |
25
|
|
|
class QueryBuilderEnumerator { |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Enumerates the conditions. |
29
|
|
|
* |
30
|
|
|
* @return string[] Returns the conditions enumeration. |
31
|
|
|
*/ |
32
|
|
|
public static function enumConditions(): array { |
33
|
|
|
return [ |
34
|
|
|
QueryBuilderConditionInterface::CONDITION_AND, |
35
|
|
|
QueryBuilderConditionInterface::CONDITION_OR, |
36
|
|
|
]; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Enumerates the inputs. |
41
|
|
|
* |
42
|
|
|
* @return string[] Returns the inputs enumeration. |
43
|
|
|
*/ |
44
|
|
|
public static function enumInputs(): array { |
45
|
|
|
return [ |
46
|
|
|
QueryBuilderInputInterface::INPUT_CHECKBOX, |
47
|
|
|
QueryBuilderInputInterface::INPUT_NUMBER, |
48
|
|
|
QueryBuilderInputInterface::INPUT_RADIO, |
49
|
|
|
QueryBuilderInputInterface::INPUT_SELECT, |
50
|
|
|
QueryBuilderInputInterface::INPUT_TEXT, |
51
|
|
|
QueryBuilderInputInterface::INPUT_TEXTAREA, |
52
|
|
|
]; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Enumerates the operators. |
57
|
|
|
* |
58
|
|
|
* @return array Returns the operators enumeration. |
59
|
|
|
*/ |
60
|
|
|
public static function enumOperators(): array { |
61
|
|
|
return [ |
62
|
|
|
QueryBuilderOperatorInterface::OPERATOR_BEGINS_WITH => "LIKE", |
63
|
|
|
QueryBuilderOperatorInterface::OPERATOR_BETWEEN => "BETWEEN", |
64
|
|
|
QueryBuilderOperatorInterface::OPERATOR_CONTAINS => "LIKE", |
65
|
|
|
QueryBuilderOperatorInterface::OPERATOR_ENDS_WITH => "LIKE", |
66
|
|
|
QueryBuilderOperatorInterface::OPERATOR_EQUAL => "=", |
67
|
|
|
QueryBuilderOperatorInterface::OPERATOR_GREATER => ">", |
68
|
|
|
QueryBuilderOperatorInterface::OPERATOR_GREATER_OR_EQUAL => ">=", |
69
|
|
|
QueryBuilderOperatorInterface::OPERATOR_IN => "IN", |
70
|
|
|
QueryBuilderOperatorInterface::OPERATOR_IS_EMPTY => "IS NULL", |
71
|
|
|
QueryBuilderOperatorInterface::OPERATOR_IS_NOT_EMPTY => "IS NOT NULL", |
72
|
|
|
QueryBuilderOperatorInterface::OPERATOR_IS_NOT_NULL => "IS NOT NULL", |
73
|
|
|
QueryBuilderOperatorInterface::OPERATOR_IS_NULL => "IS NULL", |
74
|
|
|
QueryBuilderOperatorInterface::OPERATOR_LESS => "<", |
75
|
|
|
QueryBuilderOperatorInterface::OPERATOR_LESS_OR_EQUAL => "<=", |
76
|
|
|
QueryBuilderOperatorInterface::OPERATOR_NOT_BEGINS_WITH => "NOT LIKE", |
77
|
|
|
QueryBuilderOperatorInterface::OPERATOR_NOT_BETWEEN => "NOT BETWEEN", |
78
|
|
|
QueryBuilderOperatorInterface::OPERATOR_NOT_CONTAINS => "NOT LIKE", |
79
|
|
|
QueryBuilderOperatorInterface::OPERATOR_NOT_ENDS_WITH => "NOT LIKE", |
80
|
|
|
QueryBuilderOperatorInterface::OPERATOR_NOT_EQUAL => "<>", |
81
|
|
|
QueryBuilderOperatorInterface::OPERATOR_NOT_IN => "NOT IN", |
82
|
|
|
]; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Enumerates the types. |
87
|
|
|
* |
88
|
|
|
* @return string[] Returns the types enumeration. |
89
|
|
|
*/ |
90
|
|
|
public static function enumTypes(): array { |
91
|
|
|
return [ |
92
|
|
|
QueryBuilderTypeInterface::TYPE_BOOLEAN, |
93
|
|
|
QueryBuilderTypeInterface::TYPE_DATE, |
94
|
|
|
QueryBuilderTypeInterface::TYPE_DATETIME, |
95
|
|
|
QueryBuilderTypeInterface::TYPE_DOUBLE, |
96
|
|
|
QueryBuilderTypeInterface::TYPE_INTEGER, |
97
|
|
|
QueryBuilderTypeInterface::TYPE_STRING, |
98
|
|
|
QueryBuilderTypeInterface::TYPE_TIME, |
99
|
|
|
]; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|