1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) Flipbox Digital Limited |
5
|
|
|
* @license https://github.com/flipboxfactory/craft-integration/blob/master/LICENSE |
6
|
|
|
* @link https://github.com/flipboxfactory/craft-integration/ |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace flipbox\craft\integration\queries; |
10
|
|
|
|
11
|
|
|
use craft\helpers\Db; |
12
|
|
|
use yii\db\Expression; |
13
|
|
|
|
14
|
|
|
trait ObjectAttributeTrait |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var string|string[]|null |
18
|
|
|
*/ |
19
|
|
|
public $object; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Adds an additional WHERE condition to the existing one. |
23
|
|
|
* The new condition and the existing one will be joined using the `AND` operator. |
24
|
|
|
* @param string|array|Expression $condition the new WHERE condition. Please refer to [[where()]] |
25
|
|
|
* on how to specify this parameter. |
26
|
|
|
* @param array $params the parameters (name => value) to be bound to the query. |
27
|
|
|
* @return $this the query object itself |
28
|
|
|
* @see where() |
29
|
|
|
* @see orWhere() |
30
|
|
|
*/ |
31
|
|
|
abstract public function andWhere($condition, $params = []); |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param string|string[]|null $value |
35
|
|
|
* @return static |
36
|
|
|
*/ |
37
|
|
|
public function setObjectId($value) |
38
|
|
|
{ |
39
|
|
|
return $this->setObject($value); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param string|string[]|null $value |
44
|
|
|
* @return static |
45
|
|
|
*/ |
46
|
|
|
public function objectId($value) |
47
|
|
|
{ |
48
|
|
|
return $this->setObject($value); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string|string[]|null $value |
53
|
|
|
* @return static |
54
|
|
|
*/ |
55
|
|
|
public function setObject($value) |
56
|
|
|
{ |
57
|
|
|
$this->object = $value; |
58
|
|
|
return $this; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param string|string[]|null $value |
63
|
|
|
* @return static |
64
|
|
|
*/ |
65
|
|
|
public function object($value) |
66
|
|
|
{ |
67
|
|
|
return $this->setObject($value); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Apply query specific conditions |
72
|
|
|
*/ |
73
|
|
|
protected function applyObjectConditions() |
74
|
|
|
{ |
75
|
|
|
if ($this->object !== null) { |
76
|
|
|
$this->andWhere(Db::parseParam('objectId', $this->object)); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|