Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
base.php
1
<?php
2
namespace
Bitrix\Sale\Exchange\Integration\Service\Scenarios
;
3
4
5
use
Bitrix\Sale\Exchange\Integration\Entity\B24IntegrationRelationTable
;
6
use
Bitrix\Sale\Exchange\Integration\Relation
;
7
use
Bitrix\Sale\Exchange\Integration\Exception
;
8
use
Bitrix\Sale\Exchange\Integration\Service\Batchable
;
9
use
Bitrix\Sale\Exchange\Integration\CRM
;
10
11
class
Base
12
{
13
static
public
function
dealAddsRelation
(array $params)
14
{
15
$deal =
new
Batchable\Deal
();
16
17
foreach
($params as $index=>$param)
18
{
19
if
(CRM\
EntityType::isDefined
($param[
'OWNER_TYPE_ID'
]))
20
{
21
if
($param[
'OWNER_TYPE_ID'
] == $deal->getDstEntityTypeId())
22
{
23
static::addRelation(
24
$deal->getSrcEntityTypeId(), $index,
25
$deal->getDstEntityTypeId(), $param[
'OWNER_ID'
]);
26
}
27
else
28
{
29
throw
new
Exception\ScenariosException
(
'OwnerTypeId is not Deal'
);
30
}
31
}
32
else
33
{
34
throw
new
Exception\ScenariosException
(
'OwnerTypeId UNDEFINED'
);
35
}
36
}
37
}
38
39
static
protected
function
loadRelation
($id, $srcEntityTypeId, $dstEntityTypeId)
40
{
41
$result =
null
;
42
$item = B24IntegrationRelationTable::getRow([
'filter'
=>[
43
'SRC_ENTITY_ID'
=> $id,
44
'SRC_ENTITY_TYPE_ID'
=> $srcEntityTypeId,
45
'DST_ENTITY_TYPE_ID'
=> $dstEntityTypeId]]);
46
47
if
(is_null($item) ==
false
)
48
{
49
$result = Relation\Relation::createFromArray([
50
51
'SRC_ENTITY_TYPE_ID'
=>$item[
'SRC_ENTITY_TYPE_ID'
],
52
'SRC_ENTITY_ID'
=>$item[
'SRC_ENTITY_ID'
],
53
'DST_ENTITY_TYPE_ID'
=>$item[
'DST_ENTITY_TYPE_ID'
],
54
'DST_ENTITY_ID'
=>$item[
'DST_ENTITY_ID'
]
55
]);
56
}
57
return
$result;
58
}
59
60
static
protected
function
addRelation
($sourceEntityTypeId, $sourceEntityId, $destinationEntityTypeId, $destinationEntityId)
61
{
62
$relation =
new
Relation\Relation
(
63
$sourceEntityTypeId,
64
$sourceEntityId,
65
$destinationEntityTypeId,
66
$destinationEntityId);
67
68
$relation->save();
69
}
70
//deleteRelation()
71
}
Bitrix\Main\ORM\Fields\Relations\Relation
Definition
relation.php:26
Bitrix\Sale\Exchange\EntityType\isDefined
static isDefined($typeID)
Definition
entitytype.php:46
Bitrix\Sale\Exchange\Integration\App\Base
Definition
base.php:8
Bitrix\Sale\Exchange\Integration\Entity\B24IntegrationRelationTable
Definition
b24integrationrelationtable.php:23
Bitrix\Sale\Exchange\Integration\Exception\ScenariosException
Definition
scenariosexception.php:8
Bitrix\Sale\Exchange\Integration\Service\Batchable\Deal
Definition
deal.php:10
Bitrix\Sale\Exchange\Integration\Service\Scenarios\Base\dealAddsRelation
static dealAddsRelation(array $params)
Definition
base.php:13
Bitrix\Sale\Exchange\Integration\Service\Scenarios\Base\addRelation
static addRelation($sourceEntityTypeId, $sourceEntityId, $destinationEntityTypeId, $destinationEntityId)
Definition
base.php:60
Bitrix\Sale\Exchange\Integration\Service\Scenarios\Base\loadRelation
static loadRelation($id, $srcEntityTypeId, $dstEntityTypeId)
Definition
base.php:39
Bitrix\Sale\Exchange\Integration\CRM
Definition
entitytype.php:2
Bitrix\Sale\Exchange\Integration\Exception
Definition
batchableexception.php:4
Bitrix\Sale\Exchange\Integration\Relation
Definition
relation.php:2
Bitrix\Sale\Exchange\Integration\Service\Batchable
Definition
activity.php:2
Bitrix\Sale\Exchange\Integration\Service\Scenarios
Definition
activityadd.php:2
modules
sale
lib
exchange
integration
service
scenarios
base.php
Создано системой
1.10.0