Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
base.php
1<?php
3
4
10
11class 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}
static addRelation($sourceEntityTypeId, $sourceEntityId, $destinationEntityTypeId, $destinationEntityId)
Definition base.php:60
static loadRelation($id, $srcEntityTypeId, $dstEntityTypeId)
Definition base.php:39