1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Alex19pov31\LinkedData\Loaders; |
4
|
|
|
|
5
|
|
|
use Alex19pov31\LinkedData\LoaderInterface; |
6
|
|
|
use Alex19pov31\LinkedData\Storage; |
7
|
|
|
use Bitrix\Main\ORM\Data\DataManager; |
|
|
|
|
8
|
|
|
|
9
|
|
|
class DataEntityLoader implements LoaderInterface |
10
|
|
|
{ |
11
|
|
|
use TraitBitrixLoader; |
12
|
|
|
|
13
|
|
|
private $dataManager; |
14
|
|
|
|
15
|
|
|
public function __construct(DataManager $dataManager, $nameRepository = null, $storage = null) |
16
|
|
|
{ |
17
|
|
|
$this->dataManager = $dataManager; |
18
|
|
|
$this->nameRepository = $nameRepository; |
19
|
|
|
$tableName = $this->getDataManager()::getTableName(); |
20
|
|
|
|
21
|
|
|
$storageClass = !is_null($storage) ? $storage : Storage::class; |
22
|
|
|
$storageClass::getRepository($this->repositoryName($tableName)) |
23
|
|
|
->setLoaderData($this); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Название репозитория |
28
|
|
|
* |
29
|
|
|
* @return string |
30
|
|
|
*/ |
31
|
|
|
public static function getRepositoryName(string $tableName): string |
32
|
|
|
{ |
33
|
|
|
return 'table_' . $tableName; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Класс для получения данных |
38
|
|
|
* |
39
|
|
|
* @return DataManager |
40
|
|
|
*/ |
41
|
|
|
private function getDataManager(): DataManager |
42
|
|
|
{ |
43
|
|
|
return $this->dataManager; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getData(): array |
47
|
|
|
{ |
48
|
|
|
$data = []; |
49
|
|
|
$res = $this->getDataManager()::getList([ |
50
|
|
|
'select' => $this->select, |
51
|
|
|
'filter' => $this->filter, |
52
|
|
|
'sort' => $this->sort, |
53
|
|
|
]); |
54
|
|
|
|
55
|
|
|
while ($item = $res->fetch()) { |
56
|
|
|
if (empty($item[$this->getKey()])) { |
57
|
|
|
$data[] = $item; |
58
|
|
|
continue; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$key = $item[$this->getKey()]; |
62
|
|
|
$data[$key] = $item; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
return $data; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getItem($key) |
69
|
|
|
{ |
70
|
|
|
$item = $this->getDataManager()::getList([ |
71
|
|
|
'filter' => [$this->getKey() => $key], |
72
|
|
|
])->fetch(); |
73
|
|
|
|
74
|
|
|
return !empty($item) ? (array) $item : []; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
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