|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: VITALYIEGOROV |
|
5
|
|
|
* Date: 08.12.15 |
|
6
|
|
|
* Time: 23:11 |
|
7
|
|
|
*/ |
|
8
|
|
|
namespace samsoncms\api\query; |
|
9
|
|
|
|
|
10
|
|
|
use samsoncms\api\Material; |
|
11
|
|
|
use samsonframework\orm\ArgumentInterface; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Material with additional fields query. |
|
15
|
|
|
* |
|
16
|
|
|
* @package samsoncms\api |
|
17
|
|
|
*/ |
|
18
|
|
|
class Generic extends Record |
|
19
|
|
|
{ |
|
20
|
|
|
/** @var string Table class name */ |
|
21
|
|
|
protected static $identifier = Material::class; |
|
22
|
|
|
|
|
23
|
|
|
/** @var string Table primary field name */ |
|
24
|
|
|
protected static $primaryFieldName = Material::F_PRIMARY; |
|
25
|
|
|
|
|
26
|
|
|
/** @var array Collection of all supported entity fields */ |
|
27
|
|
|
protected static $fieldIDs = array( |
|
28
|
|
|
Material::F_PRIMARY=> Material::F_PRIMARY, |
|
29
|
|
|
Material::F_PRIORITY => Material::F_PRIORITY, |
|
30
|
|
|
Material::F_IDENTIFIER => Material::F_IDENTIFIER, |
|
31
|
|
|
Material::F_DELETION => Material::F_DELETION, |
|
32
|
|
|
Material::F_PUBLISHED => Material::F_PUBLISHED, |
|
33
|
|
|
Material::F_PARENT => Material::F_PARENT, |
|
34
|
|
|
Material::F_CREATED => Material::F_CREATED, |
|
35
|
|
|
); |
|
36
|
|
|
|
|
37
|
|
|
/** @var array Collection of all supported entity fields */ |
|
38
|
|
|
protected static $fieldNames = array( |
|
39
|
|
|
Material::F_PRIMARY => Material::F_PRIMARY, |
|
40
|
|
|
Material::F_PRIORITY => Material::F_PRIORITY, |
|
41
|
|
|
Material::F_IDENTIFIER => Material::F_IDENTIFIER, |
|
42
|
|
|
Material::F_DELETION => Material::F_DELETION, |
|
43
|
|
|
Material::F_PUBLISHED => Material::F_PUBLISHED, |
|
44
|
|
|
Material::F_PARENT => Material::F_PARENT, |
|
45
|
|
|
Material::F_CREATED => Material::F_CREATED, |
|
46
|
|
|
); |
|
47
|
|
|
|
|
48
|
|
|
/** @var string Entity navigation identifiers */ |
|
49
|
|
|
protected static $navigationIDs = array(); |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Add primary field query condition. |
|
53
|
|
|
* |
|
54
|
|
|
* @param string $value Field value |
|
55
|
|
|
* @return $this Chaining |
|
56
|
|
|
* @see Material::where() |
|
57
|
|
|
*/ |
|
58
|
|
|
public function primary($value) |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->where(Material::F_PRIMARY, $value); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Add identifier field query condition. |
|
65
|
|
|
* |
|
66
|
|
|
* @param string $value Field value |
|
67
|
|
|
* @return $this Chaining |
|
68
|
|
|
* @see Material::where() |
|
69
|
|
|
*/ |
|
70
|
|
|
public function identifier($value) |
|
71
|
|
|
{ |
|
72
|
|
|
return $this->where(Material::F_IDENTIFIER, $value); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Add active flag condition. |
|
77
|
|
|
* |
|
78
|
|
|
* @param bool $value Field value |
|
79
|
|
|
* @return $this Chaining |
|
80
|
|
|
* @see Material::where() |
|
81
|
|
|
*/ |
|
82
|
|
|
public function active($value) |
|
83
|
|
|
{ |
|
84
|
|
|
return $this->where(Material::F_DELETION, $value); |
|
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Add entity published field query condition. |
|
89
|
|
|
* |
|
90
|
|
|
* @param string $value Field value |
|
91
|
|
|
* @return $this Chaining |
|
92
|
|
|
* @see Material::where() |
|
93
|
|
|
*/ |
|
94
|
|
|
public function published($value) |
|
95
|
|
|
{ |
|
96
|
|
|
return $this->where(Material::F_PUBLISHED, $value); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Add entity creation field query condition. |
|
101
|
|
|
* |
|
102
|
|
|
* @param string $value Field value |
|
103
|
|
|
* @param string $relation @see ArgumentInterface types |
|
104
|
|
|
* @return $this Chaining |
|
105
|
|
|
* @see Material::where() |
|
106
|
|
|
*/ |
|
107
|
|
|
public function created($value, $relation = ArgumentInterface::EQUAL) |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->where(Material::F_CREATED, $this->convertToDateTime($value), $relation); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Add entity modification field query condition. |
|
114
|
|
|
* |
|
115
|
|
|
* @param string $value Field value |
|
116
|
|
|
* @param string $relation @see ArgumentInterface types |
|
117
|
|
|
* @return $this Chaining |
|
118
|
|
|
* @see Material::where() |
|
119
|
|
|
*/ |
|
120
|
|
|
public function modified($value, $relation = ArgumentInterface::EQUAL) |
|
121
|
|
|
{ |
|
122
|
|
|
return $this->where(Material::F_MODIFIED, $this->convertToDateTime($value), $relation); |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: