1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
CollabLogEntryBuilderFromEntityObject.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Collab\Log;
4
5use Bitrix\Main\EventManager;
6use Bitrix\Socialnetwork\Collab\Entity\CollabEntityFactory;
7use Bitrix\Socialnetwork\Collab\Internals\EO_CollabLog;
8use Bitrix\Socialnetwork\Collab\Log\Entry\AddCalendarEventLogEntry;
9use Bitrix\Socialnetwork\Collab\Log\Entry\AddFileLogEntry;
10use Bitrix\Socialnetwork\Collab\Log\Entry\AddFilePublicLinkLogEntry;
11use Bitrix\Socialnetwork\Collab\Log\Entry\AddTaskLogEntry;
12use Bitrix\Socialnetwork\Collab\Log\Entry\AddUserToCollabLogEntry;
13use Bitrix\Socialnetwork\Collab\Log\Entry\ChangeCollabMemberRoleLogEntry;
14use Bitrix\Socialnetwork\Collab\Log\Entry\CompleteTaskLogEntry;
15use Bitrix\Socialnetwork\Collab\Log\Entry\CopyInvitationLinkLogEntry;
16use Bitrix\Socialnetwork\Collab\Log\Entry\CreateCollabLogEntry;
17use Bitrix\Socialnetwork\Collab\Log\Entry\DeleteCalendarEventLogEntry;
18use Bitrix\Socialnetwork\Collab\Log\Entry\DeleteFileLogEntry;
19use Bitrix\Socialnetwork\Collab\Log\Entry\DeleteTaskLogEntry;
20use Bitrix\Socialnetwork\Collab\Log\Entry\RemoveUserFromCollabLogEntry;
21use Bitrix\Socialnetwork\Collab\Log\Entry\UpdateCollabLogEntry;
22
24{
25 private ?array $logEntryClasses = null;
26
27 public function build(EO_CollabLog $entityObject): ?AbstractCollabLogEntry
28 {
29 $logEntryClasses = $this->getLogEntryClasses();
30
31 $logEntryClass = $logEntryClasses[$entityObject->getType()] ?? null;
32
33 if (!is_string($logEntryClass) || !is_subclass_of($logEntryClass, AbstractCollabLogEntry::class))
34 {
35 return null;
36 }
37
38 $logEntry = new $logEntryClass(
39 id: $entityObject->getId(),
40 userId: $entityObject->getUserId(),
41 collabId: $entityObject->getCollabId(),
42 dateTime: $entityObject->getDateTime(),
43 );
44
45 if ($entityObject->getEntityId() > 0)
46 {
47 $logEntry->setEntity(CollabEntityFactory::getById($entityObject->getEntityId(), $entityObject->getEntityType()));
48 }
49
50 $logEntry->setData($entityObject->getData());
51
52 return $logEntry;
53 }
54
55 private function getLogEntryClasses(): array
56 {
57 if (is_array($this->logEntryClasses))
58 {
59 return $this->logEntryClasses;
60 }
61
62 $classes = $this->getSocialNetworkLogEntryClasses();
63
64 $events = EventManager::getInstance()->findEventHandlers('socialnetwork', 'onCollabLogEntryClassesFetch');
65 foreach ($events as $event)
66 {
67 $fetchedClasses = ExecuteModuleEventEx($event);
68
69 if (is_array($fetchedClasses))
70 {
71 $classes = array_merge($classes, $fetchedClasses);
72 }
73 }
74
75 $this->logEntryClasses = $classes;
76
77 return $this->logEntryClasses;
78 }
79
80 private function getSocialNetworkLogEntryClasses(): array
81 {
82 return [
83 AddCalendarEventLogEntry::getEventType() => AddCalendarEventLogEntry::class,
84 AddFileLogEntry::getEventType() => AddFileLogEntry::class,
85 AddFilePublicLinkLogEntry::getEventType() => AddFilePublicLinkLogEntry::class,
86 AddTaskLogEntry::getEventType() => AddTaskLogEntry::class,
87 AddUserToCollabLogEntry::getEventType() => AddUserToCollabLogEntry::class,
88 ChangeCollabMemberRoleLogEntry::getEventType() => ChangeCollabMemberRoleLogEntry::class,
89 CompleteTaskLogEntry::getEventType() => CompleteTaskLogEntry::class,
90 CopyInvitationLinkLogEntry::getEventType() => CopyInvitationLinkLogEntry::class,
91 CreateCollabLogEntry::getEventType() => CreateCollabLogEntry::class,
92 DeleteCalendarEventLogEntry::getEventType() => DeleteCalendarEventLogEntry::class,
93 DeleteFileLogEntry::getEventType() => DeleteFileLogEntry::class,
94 DeleteTaskLogEntry::getEventType() => DeleteTaskLogEntry::class,
95 RemoveUserFromCollabLogEntry::getEventType() => RemoveUserFromCollabLogEntry::class,
96 UpdateCollabLogEntry::getEventType() => UpdateCollabLogEntry::class,
97 ];
98 }
99}
Определения AbstractCollabLogEntry.php:10
build(EO_CollabLog $entityObject)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
ExecuteModuleEventEx($arEvent, $arParams=[])
Определения tools.php:5214
$event
Определения prolog_after.php:141