Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
eventaccesscontroller.php
1<?php
2
4
11
13{
14 public static array $cache = [];
15
16 private const ITEM_TYPE = 'EVENT';
17 private const USER_TYPE = 'USER';
18
19 protected function loadItem(int $itemId = null): ?AccessibleItem
20 {
21 $key = self::ITEM_TYPE . '_' . $itemId;
22 if (!array_key_exists($key, static::$cache))
23 {
25 $event = (new Event())->getById($itemId);
26
27 if ($event instanceof \Bitrix\Calendar\Core\Event\Event)
28 {
29 $eventModel = EventModel::createFromObject($event);
30 }
31 else
32 {
33 $eventModel = EventModel::createNew();
34 }
35
36 static::$cache[$key] = $eventModel;
37 }
38
39 return static::$cache[$key];
40 }
41
42 protected function loadUser(int $userId): AccessibleUser
43 {
44 $key = self::USER_TYPE . '_' . $userId;
45 if (!array_key_exists($key, static::$cache))
46 {
47 static::$cache[$key] = UserModel::createFromId($userId);
48 }
49
50 return static::$cache[$key];
51 }
52}