Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Event.php
1<?php
2
3namespace Bitrix\Im\V2\Sync;
4
5use Bitrix\Im\Model\EO_Log_Collection;
7
8class Event
9{
10 public const DELETE_EVENT = 'delete';
11 public const COMPLETE_DELETE_EVENT = 'completeDelete';
12 public const ADD_EVENT = 'add';
13 public const READ_ALL_EVENT = 'readAll';
14 public const CHAT_ENTITY = 'chat';
15 public const PIN_MESSAGE_ENTITY = 'pin';
16 public const MESSAGE_ENTITY = 'message';
17
18 private ?int $id;
19 private DateTime $dateCreate;
20 private ?DateTime $dateDelete;
21 public string $entityType;
22 public int $entityId;
23 public string $eventName;
24
25 public function __construct(
26 string $eventName,
27 string $entityType,
28 int $entityId,
29 ?DateTime $dateDelete = null,
30 ?DateTime $dateCreate = null,
31 ?int $id = null
32 )
33 {
34 $dateCreate ??= new DateTime();
35 if ($dateDelete === null)
36 {
37 $dateDelete = clone $dateCreate;
39 }
40 $this->eventName = $eventName;
41 $this->entityType = $entityType;
42 $this->entityId = $entityId;
43 $this->dateDelete = $dateDelete;
44 $this->dateCreate = $dateCreate;
45 $this->id = $id;
46 }
47
48 public function getId(): ?int
49 {
50 return $this->id;
51 }
52
53 public function getDateCreate(): DateTime
54 {
55 return $this->dateCreate;
56 }
57
58 public function getDateDelete(): ?DateTime
59 {
60 return $this->dateDelete;
61 }
62
67 public static function initByOrmEntities(EO_Log_Collection $logCollection): array
68 {
69 $events = [];
70
71 foreach ($logCollection as $logItem)
72 {
73 $events[] = new self(
74 $logItem->getEvent(),
75 $logItem->getEntityType(),
76 $logItem->getEntityId(),
77 $logItem->getDateCreate(),
78 $logItem->getDateDelete(),
79 $logItem->getId()
80 );
81 }
82
83 return $events;
84 }
85}
const COMPLETE_DELETE_EVENT
Definition Event.php:11
static initByOrmEntities(EO_Log_Collection $logCollection)
Definition Event.php:67
__construct(string $eventName, string $entityType, int $entityId, ?DateTime $dateDelete=null, ?DateTime $dateCreate=null, ?int $id=null)
Definition Event.php:25
add($interval)
Definition date.php:145