1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
TaskItem.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Link\Task;
4
5use Bitrix\Im\Model\LinkTaskTable;
6use Bitrix\Im\Model\EO_LinkTask;
7use Bitrix\Im\V2\Link\BaseLinkItem;
8use Bitrix\Im\V2\Rest\RestEntity;
9use Bitrix\Main\Type\DateTime;
10
12{
13 protected static array $cache = [];
14
18 public function __construct($source = null)
19 {
20 $this->initByDefault();
21
22 if (!empty($source))
23 {
24 $this->load($source);
25 }
26 }
27
28 public static function getDataClass(): string
29 {
30 return LinkTaskTable::class;
31 }
32
33 public static function getEntityClassName(): string
34 {
35 return \Bitrix\Im\V2\Entity\Task\TaskItem::class;
36 }
37
38 public static function getRestEntityName(): string
39 {
40 return 'link';
41 }
42
43 public static function initByRow(array $row): self
44 {
46 $link = new static();
47 $link
48 ->setEntity($entity)
49 ->setId($row['IM_CHAT_ID'])
50 ->setChatId($row['IM_CHAT_CHAT_ID'])
51 ->setMessageId($row['IM_CHAT_MESSAGE_ID'])
52 ->setAuthorId($row['IM_CHAT_AUTHOR_ID'])
53 ->setDateCreate(new DateTime($row['CREATED_DATE']))
54 ;
55
56 return $link;
57 }
58
59 public static function getByEntity(\Bitrix\Im\V2\Entity\Task\TaskItem $entity): ?self
60 {
62 if ($taskItem === null)
63 {
64 return null;
65 }
66
67 $taskItem->setEntity($entity);
68
69 return $taskItem;
70 }
71
72 protected static function getByEntityInternal(\Bitrix\Im\V2\Entity\Task\TaskItem $entity): ?self
73 {
74 if (array_key_exists($entity->getTaskId(), self::$cache))
75 {
76 return self::$cache[$entity->getTaskId()];
77 }
78
79 $chatTask = LinkTaskTable::query()
80 ->setSelect(['ID', 'MESSAGE_ID', 'CHAT_ID', 'TASK_ID', 'AUTHOR_ID', 'DATE_CREATE'])
81 ->where('TASK_ID', $entity->getTaskId())
82 ->setLimit(1)
83 ->fetchObject()
84 ;
85
86 if ($chatTask === null)
87 {
88 self::$cache[$entity->getTaskId()] = null;
89
90 return null;
91 }
92
93 self::$cache[$entity->getTaskId()] = new static($chatTask);
94
95 return self::$cache[$entity->getTaskId()];
96 }
97
98 public static function getByMessageId(int $messageId): ?self
99 {
100 $chatTask = LinkTaskTable::query()
101 ->setSelect(['ID', 'MESSAGE_ID', 'CHAT_ID', 'TASK_ID', 'AUTHOR_ID', 'DATE_CREATE'])
102 ->where('MESSAGE_ID', $messageId)
103 ->setLimit(1)
104 ->fetchObject()
105 ;
106
107 if ($chatTask === null)
108 {
109 return null;
110 }
111
112 return new static($chatTask);
113 }
114
115 protected static function getEntityIdFieldName(): string
116 {
117 return 'TASK_ID';
118 }
119
123 public function getEntity(): RestEntity
124 {
125 if (isset($this->entity))
126 {
127 return $this->entity;
128 }
129
130 if ($this->getEntityId() !== null)
131 {
133 if (isset($entity))
134 {
135 $this->entity = $entity;
136 }
137 }
138
139 return $this->entity;
140 }
141
142 public static function cleanCache(int $taskId): void
143 {
144 unset(self::$cache[$taskId]);
145 }
146}
static initByRow(array $row)
Определения TaskItem.php:76
static getById(int $id, ?Context $context=null)
Определения TaskItem.php:58
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения ActionUuid.php:3
Определения ufield.php:9