1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) Flipbox Digital Limited |
5
|
|
|
* @license https://flipboxfactory.com/software/patron/license |
6
|
|
|
* @link https://www.flipboxfactory.com/patron/domains/ |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace flipbox\patron\queries; |
10
|
|
|
|
11
|
|
|
use craft\helpers\Db; |
12
|
|
|
use flipbox\patron\records\Provider; |
13
|
|
|
use yii\db\Expression; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @author Flipbox Factory <[email protected]> |
17
|
|
|
* @since 1.0.0 |
18
|
|
|
*/ |
19
|
|
|
trait ProviderClientAttributesTrait |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var string|string[]|null The client Id(s). Prefix IDs with "not " to exclude them. |
23
|
|
|
*/ |
24
|
|
|
public $clientId; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string|string[]|null The client secret(s). Prefix IDs with "not " to exclude them. |
28
|
|
|
*/ |
29
|
|
|
public $clientSecret; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Adds an additional WHERE condition to the existing one. |
33
|
|
|
* The new condition and the existing one will be joined using the `AND` operator. |
34
|
|
|
* @param string|array|Expression $condition the new WHERE condition. Please refer to [[where()]] |
35
|
|
|
* on how to specify this parameter. |
36
|
|
|
* @param array $params the parameters (name => value) to be bound to the query. |
37
|
|
|
* @return $this the query object itself |
38
|
|
|
* @see where() |
39
|
|
|
* @see orWhere() |
40
|
|
|
*/ |
41
|
|
|
abstract public function andWhere($condition, $params = []); |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param $clientId |
45
|
|
|
* @return $this |
46
|
|
|
*/ |
47
|
|
|
public function clientId($clientId) |
48
|
|
|
{ |
49
|
|
|
$this->clientId = $clientId; |
50
|
|
|
return $this; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param $clientSecret |
55
|
|
|
* @return $this |
56
|
|
|
*/ |
57
|
|
|
public function clientSecret($clientSecret) |
58
|
|
|
{ |
59
|
|
|
$this->clientSecret = $clientSecret; |
60
|
|
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Apply params |
65
|
|
|
*/ |
66
|
|
|
protected function applyClientConditions() |
67
|
|
|
{ |
68
|
|
|
$attributes = ['clientId', 'clientSecret']; |
69
|
|
|
|
70
|
|
|
foreach ($attributes as $attribute) { |
71
|
|
|
if (($value = $this->{$attribute}) !== null) { |
72
|
|
|
$this->andWhere( |
73
|
|
|
Db::parseParam(Provider::tableAlias() . '.' . $attribute, $value) |
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|