21 abstract public function init($params);
22 abstract static public function proxyAdds(array $list);
24 protected function relationLoad()
28 $relations = static::relationEntityList([
30 'SRC_ENTITY_TYPE_ID' => $this->getSrcEntityTypeId(),
31 'DST_ENTITY_TYPE_ID' => $this->getDstEntityTypeId()]
33 if(count($relations)>0)
36 foreach ($relations as $relation)
38 $item =
$collection->getItemByIndex($relation->getSourceEntityId());
40 ->setRelation($relation);
45 public function relationListDstEntity()
49 foreach ($this->getCollection() as $item)
51 if($item->getEntity()->hasRelation())
53 $result[] = $item->getEntity()->getRelation()->getDestinationEntityId();
58 public function relationDeleteByDstEntity($dstEntityList)
61 foreach($this->getCollection() as $item)
63 if($item->getEntity()->hasRelation())
65 if(!in_array($item->getEntity()->getRelation()->getDestinationEntityId(), $dstEntityList))
67 $item->getEntity()->getRelation()->setDestinationEntityId(0);
68 $item->getEntity()->getRelation()->save();
73 public function relationVoid()
75 $collection =
new Integration\Service\Internal\Container\Collection();
80 if($item->getEntity()->hasRelation() ==
false
81 || $item->getEntity()->getRelation()->getDestinationEntityId() == 0)
90 foreach($list as $index=>$dstEntityId)
93 if(is_null($item) ==
false)
95 $relation = new \Bitrix\Sale\Exchange\Integration\Relation\Relation(
105 $this->relationLoad();
112 $list = Integration\Entity\B24IntegrationRelationTable::getList([
'filter'=>$filter])
115 foreach ($list as $item)
117 $result[] = Integration\Relation\Relation::createFromArray([
119 'SRC_ENTITY_TYPE_ID'=>$item[
'SRC_ENTITY_TYPE_ID'],
120 'SRC_ENTITY_ID'=>$item[
'SRC_ENTITY_ID'],
121 'DST_ENTITY_TYPE_ID'=>$item[
'DST_ENTITY_TYPE_ID'],
122 'DST_ENTITY_ID'=>$item[
'DST_ENTITY_ID']
142 $client = static::factoryClient($typeName);
143 return count($indexes)>0 ?
144 static::relationEntityList([
145 'SRC_ENTITY_ID' => $indexes,
146 'SRC_ENTITY_TYPE_ID' => $client->getSrcEntityTypeId(),
147 'DST_ENTITY_TYPE_ID' => $client->getDstEntityTypeId()])
153 $typeId = BusinessValuePersonDomainType::resolveID($typeName);
155 if(BusinessValuePersonDomainType::isDefined($typeId))
157 if($typeName == BusinessValuePersonDomainType::TYPE_E_NAME)
161 elseif($typeName == BusinessValuePersonDomainType::TYPE_I_NAME)
167 throw new \Bitrix\Main\NotSupportedException(
"Client : '".$typeId.
"' is not supported in current context");
172 return array_keys($params);
177 if(count($contacts)>0)
179 foreach ($contacts as $contact)
181 $result[] = $contact[
'CONTACT_ID'];
189 if(count($indexes)>0)
191 foreach ($indexes as $index)
193 $result[] = [
'CONTACT_ID'=>$index];
202 foreach (
$fields as $index=>$item)
204 $result[$index] = [
'fields'=>$item];
211 $res = static::proxyAdds($params);
212 if(count($res[
'result'])>0)
216 if(count($res[
'result_error'])>0)
218 foreach($res[
'result_error'] as $index=>$error)
221 $item->setError(
new Error($error[
'error_description']));
229 ->addsFromParams($this
235 return $this->collection;