1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Created by Gorlum 10.02.2017 0:07 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Core; |
8
|
|
|
|
9
|
|
|
use \Common\ContainerPlus; |
|
|
|
|
10
|
|
|
use Core\GlobalContainer; |
11
|
|
|
use TextEntity; |
12
|
|
|
use TextModel; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class Core\Repository |
16
|
|
|
* |
17
|
|
|
* Holds current entity objects |
18
|
|
|
* |
19
|
|
|
* @deprecated |
20
|
|
|
*/ |
21
|
|
|
class Repository { |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* "Not an Object" marker |
25
|
|
|
*/ |
26
|
|
|
const NaO = '\\NaO'; |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var ContainerPlus $_repository |
31
|
|
|
*/ |
32
|
|
|
protected $_repository; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var ContainerPlus $_oldRepo |
36
|
|
|
*/ |
37
|
|
|
protected $_oldRepo; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var GlobalContainer $gc |
41
|
|
|
*/ |
42
|
|
|
protected $gc; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Core\Repository constructor. |
46
|
|
|
* |
47
|
|
|
* @param GlobalContainer $gc |
48
|
|
|
*/ |
49
|
|
|
public function __construct(GlobalContainer $gc) { |
50
|
|
|
$this->gc = $gc; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param TextModel $model |
55
|
|
|
* @param int|string $id |
56
|
|
|
* |
57
|
|
|
* @return TextEntity |
58
|
|
|
* @deprecated |
59
|
|
|
*/ |
60
|
|
|
public function getById($model, $id) { |
61
|
|
|
|
62
|
|
|
// TODO - is_object() |
63
|
|
|
|
64
|
|
|
// Index is fully qualified class name plus ID like Namespace\ClassName\$id |
65
|
|
|
$entityIndex = get_class($model) . '\\' . $id; |
66
|
|
|
if (!isset($this->_oldRepo[$entityIndex])) { |
67
|
|
|
$entity = $model->loadById($id); |
68
|
|
|
if ($entity && !$entity->isEmpty()) { |
69
|
|
|
$this->_oldRepo[$entityIndex] = $entity; |
70
|
|
|
} |
71
|
|
|
} else { |
72
|
|
|
$entity = $this->_oldRepo[$entityIndex]; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
return $entity; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Returns collection name for supplied object |
80
|
|
|
* |
81
|
|
|
* @param $object |
82
|
|
|
* |
83
|
|
|
* @return string |
84
|
|
|
*/ |
85
|
|
|
protected function getCollectionName($object) { |
86
|
|
|
return is_object($object) ? get_class($object) : self::NaO; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function get($entityClass, $id) { |
90
|
|
|
$entityIndex = get_class($entityClass) . '\\' . $id; |
91
|
|
|
if(!isset($this->_repository[$entityIndex])) { |
92
|
|
|
|
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
return $this->_repository[$entityIndex]; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
protected function getPool($entityClass) { |
|
|
|
|
99
|
|
|
|
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function registerFactory($factory) { |
|
|
|
|
103
|
|
|
|
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
} |
107
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths