Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
base.php
1<?php
3
9
10abstract class Base
11{
12 protected $fields;
13
14 public function __construct(array $values = null)
15 {
16 $this->fields = new Fields($values);
17 }
18
19 public function getId()
20 {
21 return $this->fields->get('ID');
22 }
23 public function setId($value)
24 {
25 $this->fields->set('ID', $value);
26 return $this;
27 }
28
29 public function getFieldsValues()
30 {
31 return $this->fields->getValues();
32 }
33
34 abstract public function getType();
35 abstract static protected function resolveFields(array $list);
36 abstract static public function createFromArray(array $fields);
37
38 public function load(Order $order)
39 {
42 $orderClass = $registry->getOrderClassName();
43 $list = $orderClass::getList([
44 'select'=>[
45 'ID',
46 'PROPERTY.CODE',
47 'PROPERTY.VALUE',
48 'USER.ID',
49 'USER.NAME',
50 'USER.LAST_NAME',
51 'USER.EMAIL',
52 'USER.PERSONAL_PHONE',
53 'PERSON_TYPE_ID'
54 ],
55 'filter'=>['ID'=>$order->getId()]
56 ])->fetchAll();
57
58 if(count($list)>0)
59 {
60 $fields = static::resolveFields($list);
61 return static::createFromArray($fields);
62 }
63 else
64 {
65 throw new Exception\UserException('Client not loaded');
66 }
67 }
68
69 static public function resolveNamePersonDomain($personTypeId)
70 {
71 static $list = null;
72
73 if ($list == null)
74 {
75 $list = static::businessValuePersonDomainList();
76 }
77
78 if (isset($list[$personTypeId]))
79 {
80 return $list[$personTypeId];
81 }
82 else
83 {
84 throw new Exception\UserException("Person personTypeId: '".$personTypeId."' is not supported in current context");
85 }
86 }
87 static protected function businessValuePersonDomainList()
88 {
89 $bzList = [];
90 foreach (BusinessValuePersonDomainTable::getList()->fetchAll() as $bz)
91 {
92 $bzList[$bz['PERSON_TYPE_ID']] = $bz['DOMAIN'];
93 }
94
95 return $bzList;
96 }
97}
static getInstance($type)
Definition registry.php:183