Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
base.php
1
<?php
2
namespace
Bitrix\Sale\Exchange\Integration\Service\User\Entity
;
3
4
use
Bitrix\Sale\Exchange\Integration\Exception
;
5
use
Bitrix\Sale\Internals\BusinessValuePersonDomainTable
;
6
use
Bitrix\Sale\Internals\Fields
;
7
use
Bitrix\Sale\Order
;
8
use
Bitrix\Sale\Registry
;
9
10
abstract
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
{
40
$registry =
Registry::getInstance
(
Registry::REGISTRY_TYPE_ORDER
);
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
}
Bitrix\Sale\Exchange\Integration\Exception\UserException
Definition
userexception.php:8
Bitrix\Sale\Exchange\Integration\Service\User\Entity\Base
Definition
base.php:11
Bitrix\Sale\Exchange\Integration\Service\User\Entity\Base\businessValuePersonDomainList
static businessValuePersonDomainList()
Definition
base.php:87
Bitrix\Sale\Exchange\Integration\Service\User\Entity\Base\getId
getId()
Definition
base.php:19
Bitrix\Sale\Exchange\Integration\Service\User\Entity\Base\createFromArray
static createFromArray(array $fields)
Bitrix\Sale\Exchange\Integration\Service\User\Entity\Base\resolveFields
static resolveFields(array $list)
Bitrix\Sale\Exchange\Integration\Service\User\Entity\Base\__construct
__construct(array $values=null)
Definition
base.php:14
Bitrix\Sale\Exchange\Integration\Service\User\Entity\Base\getType
getType()
Bitrix\Sale\Exchange\Integration\Service\User\Entity\Base\getFieldsValues
getFieldsValues()
Definition
base.php:29
Bitrix\Sale\Exchange\Integration\Service\User\Entity\Base\resolveNamePersonDomain
static resolveNamePersonDomain($personTypeId)
Definition
base.php:69
Bitrix\Sale\Exchange\Integration\Service\User\Entity\Base\setId
setId($value)
Definition
base.php:23
Bitrix\Sale\Exchange\Integration\Service\User\Entity\Base\$fields
$fields
Definition
base.php:12
Bitrix\Sale\Helpers\Order
Definition
order.php:10
Bitrix\Sale\Internals\BusinessValuePersonDomainTable
Definition
businessvalue_persondomain.php:24
Bitrix\Sale\Internals\Fields
Definition
fields.php:6
Bitrix\Sale\Order
Definition
order.php:20
Bitrix\Sale\Registry
Definition
registry.php:13
Bitrix\Sale\Registry\getInstance
static getInstance($type)
Definition
registry.php:183
Bitrix\Sale\Registry\REGISTRY_TYPE_ORDER
const REGISTRY_TYPE_ORDER
Definition
registry.php:16
Bitrix\Sale\Exchange\Integration\Exception
Definition
batchableexception.php:4
Bitrix\Sale\Exchange\Integration\Service\User\Entity
Definition
base.php:2
modules
sale
lib
exchange
integration
service
user
entity
base.php
Создано системой
1.10.0