Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
eventaccesscontroller.php
1
<?php
2
3
namespace
Bitrix\Calendar\Access
;
4
5
use
Bitrix\Calendar\Access\Model\EventModel
;
6
use
Bitrix\Calendar\Access\Model\UserModel
;
7
use
Bitrix\Main\Access\AccessibleItem
;
8
use
Bitrix\Main\Access\BaseAccessController
;
9
use
Bitrix\Main\Access\User\AccessibleUser
;
10
use
Bitrix\Calendar\Core\Mappers\Event
;
11
12
class
EventAccessController
extends
BaseAccessController
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
}
Bitrix\Calendar\Access\EventAccessController
Definition
eventaccesscontroller.php:13
Bitrix\Calendar\Access\EventAccessController\$cache
static array $cache
Definition
eventaccesscontroller.php:14
Bitrix\Calendar\Access\EventAccessController\loadUser
loadUser(int $userId)
Definition
eventaccesscontroller.php:42
Bitrix\Calendar\Access\Model\EventModel
Definition
eventmodel.php:11
Bitrix\Calendar\Access\Model\EventModel\createNew
static createNew()
Definition
eventmodel.php:42
Bitrix\Calendar\Access\Model\EventModel\createFromObject
static createFromObject(Event $event)
Definition
eventmodel.php:107
Bitrix\Calendar\Access\Model\UserModel
Definition
usermodel.php:10
Bitrix\Calendar\Core\Mappers\Event
Definition
event.php:20
Bitrix\Main\Access\BaseAccessController
Definition
baseaccesscontroller.php:23
Bitrix\Main\Access\BaseAccessController\loadItem
loadItem(int $itemId=null)
Bitrix\Main\Access\AccessibleItem
Definition
accessibleitem.php:13
Bitrix\Main\Access\User\AccessibleUser
Definition
accessibleuser.php:13
Bitrix\Calendar\Access
Definition
accessibleevent.php:3
Bitrix
modules
calendar
lib
access
eventaccesscontroller.php
Создано системой
1.10.0