Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
entity.php
1<?php
2
3
5
6
9
10class Entity
11{
12 protected $params;
13 protected $typeName;
14
15 public function __construct($typeName, $params=[])
16 {
17 $this->typeName = $typeName;
18 $this->params = $params;
19 }
20
21 protected function getAdditionalFilterFileds()
22 {
23 return [];
24 }
25
26 protected function getExternalNameField()
27 {
28 return 'XML_ID';
29 }
30
31 protected function getFields()
32 {
33 return ['ID', $this->getExternalNameField()];
34 }
35
36 public function getParams()
37 {
38 return $this->params;
39 }
40
41 public function getFieldsByExternalId($xmlId)
42 {
43 if($xmlId === "")
44 {
45 return null;
46 }
47
48 $entity = $this->getEntityTable();
49
50 if($r = $entity::getList([
51 'select' => $this->getFields(),
52 'filter' => array_merge(
53 [
54 $this->getExternalNameField() => $xmlId
55 ],
57 ),
58 'order' => ['ID' => 'ASC']
59 ])->fetch()
60 )
61 {
62 return $r['ID'];
63 }
64
65 return null;
66 }
67
68 public function getRegistryType()
69 {
71 }
72
73 protected function getEntityTable()
74 {
75 $instance = Registry::getInstance($this->getRegistryType());
76 return $instance->get($this->typeName);
77 }
78}
static getInstance($type)
Definition registry.php:183