1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
CrmType.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Chat\EntityLink;
4
5use Bitrix\Im\V2\Chat\EntityLink;
6use Bitrix\Main\Loader;
7
8class CrmType extends EntityLink
9{
10 protected const HAS_URL = true;
11 protected const DYNAMIC_TYPE = 'DYNAMIC';
12
13 protected string $crmType = '';
14 protected int $crmId = 0;
15
16 protected function __construct(string $entityId)
17 {
18 parent::__construct();
19 if (Loader::includeModule('crm'))
20 {
21 $this->extractCrmData($entityId);
22 }
23 $this->type = $this->crmType;
24 }
25
26 protected function getUrl(): string
27 {
28 if(
29 $this->crmType === ''
30 || $this->crmId === 0
31 || !Loader::includeModule('crm')
32 || $this->getContext()->getUser()->isExtranet()
33 )
34 {
35 return '';
36 }
37
38 return \Bitrix\Im\Integration\Crm\Common::getLink($this->crmType, $this->crmId);
39 }
40
41 protected function getRestType(): string
42 {
43 if ($this->isExpectedType($this->type))
44 {
45 return $this->type;
46 }
47
48 return self::DYNAMIC_TYPE;
49 }
50
51 protected function extractCrmData(string $rawCrmData): void
52 {
53 $separatedEntityId = explode('|', $rawCrmData);
54 $this->crmType = $separatedEntityId[0] ?? '';
55 $this->crmId = (int)($separatedEntityId[1] ?? 0);
56 }
57
58 private function getExpectedType(): array
59 {
60 if (!Loader::includeModule('crm'))
61 {
62 return [];
63 }
64
65 return [
66 \CCrmOwnerType::LeadName => \CCrmOwnerType::LeadName,
67 \CCrmOwnerType::DealName => \CCrmOwnerType::DealName,
68 \CCrmOwnerType::ContactName => \CCrmOwnerType::ContactName,
69 \CCrmOwnerType::CompanyName => \CCrmOwnerType::CompanyName,
70 ];
71 }
72
73 private function isExpectedType(string $type): bool
74 {
75 return isset($this->getExpectedType()[$type]);
76 }
77}
$type
Определения options.php:106
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804