1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* _ __ __ _____ _____ ___ ____ _____ |
5
|
|
|
* | | / // // ___//_ _// || __||_ _| |
6
|
|
|
* | |/ // /(__ ) / / / /| || | | | |
7
|
|
|
* |___//_//____/ /_/ /_/ |_||_| |_| |
8
|
|
|
* @link https://vistart.me/ |
9
|
|
|
* @copyright Copyright (c) 2016 - 2017 vistart |
10
|
|
|
* @license https://vistart.me/license/ |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace rhosocial\base\models\queries; |
14
|
|
|
|
15
|
|
|
use MongoDB\BSON\Binary; |
16
|
|
|
use rhosocial\base\models\traits\BlameableQueryTrait; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Description of BaseMongoBlameableQuery |
20
|
|
|
* |
21
|
|
|
* @version 1.0 |
22
|
|
|
* @author vistart <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class BaseMongoBlameableQuery extends BaseMongoEntityQuery |
25
|
|
|
{ |
26
|
|
|
use BlameableQueryTrait; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Specify creator(s). |
30
|
|
|
* @param string|array $guid |
31
|
|
|
* @return $this |
32
|
|
|
*/ |
33
|
3 |
|
public function createdBy($guid) |
34
|
|
|
{ |
35
|
3 |
|
$model = $this->noInitModel; |
36
|
3 |
|
if (!is_string($model->createdByAttribute)) { |
37
|
|
|
return $this; |
38
|
|
|
} |
39
|
3 |
|
if ($guid instanceof BaseUserModel) { |
|
|
|
|
40
|
|
|
$guid = $guid->getGUID(); |
41
|
|
|
} |
42
|
3 |
|
return $this->andWhere([$model->createdByAttribute => new Binary($guid, Binary::TYPE_UUID)]); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Specify last updater(s). |
47
|
|
|
* @param string|array $guid |
48
|
|
|
* @return $this |
49
|
|
|
*/ |
50
|
3 |
|
public function updatedBy($guid) |
51
|
|
|
{ |
52
|
3 |
|
$model = $this->noInitModel; |
53
|
3 |
|
if (!is_string($model->updatedByAttribute)) { |
54
|
|
|
return $this; |
55
|
|
|
} |
56
|
3 |
|
if ($guid instanceof BaseUserModel) { |
|
|
|
|
57
|
|
|
$guid = $guid->getGUID(); |
58
|
|
|
} |
59
|
3 |
|
return $this->andWhere([$model->updatedByAttribute => new Binary($guid, Binary::TYPE_UUID)]); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Attach current identity to createdBy condition. |
64
|
|
|
* @param BaseUserModel $identity |
65
|
|
|
* @return $this |
66
|
|
|
*/ |
67
|
3 |
|
public function byIdentity($identity = null) |
68
|
|
|
{ |
69
|
3 |
|
if (!$identity) { |
70
|
|
|
$identity = Yii::$app->user->identity; |
71
|
|
|
} |
72
|
3 |
|
if (method_exists($identity, 'canGetProperty') && !$identity->canGetProperty('guid')) { |
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
3 |
|
return $this->createdBy($identity->getGUID()); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.