Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
sectionmodel.php
1
<?php
2
3
namespace
Bitrix\Calendar\Access\Model
;
4
5
use
Bitrix\Calendar\Access\AccessibleSection
;
6
use
Bitrix\Main\Access\AccessibleItem
;
7
8
class
SectionModel
implements
AccessibleSection
9
{
10
private
static
array $cache = [];
11
12
private
int
$id = 0;
13
private
string
$type =
''
;
14
private
int
$ownerId = 0;
15
16
public
static
function
createFromId
(
int
$itemId):
AccessibleItem
17
{
18
if
(!isset(static::$cache[$itemId]))
19
{
20
$model =
new
self
();
21
$model->setId($itemId);
22
static::$cache[$itemId] = $model;
23
}
24
25
return
static::$cache[$itemId];
26
}
27
28
public
static
function
createNew
(): self
29
{
30
return
new
self
();
31
}
32
33
public
static
function
createFromArray
(array $fields): self
34
{
35
if
(($fields[
'ID'
] ??
false
) && (
int
)$fields[
'ID'
] > 0)
36
{
37
$model =
self::createFromId
((
int
)$fields[
'ID'
]);
38
}
39
else
40
{
41
$model =
self::createNew
();
42
}
43
44
if
(($fields[
'CAL_TYPE'
] ??
false
) && is_string($fields[
'CAL_TYPE'
]))
45
{
46
$model->setType($fields[
'CAL_TYPE'
]);
47
}
48
49
if
(($fields[
'OWNER_ID'
] ??
false
) && (
int
)$fields[
'OWNER_ID'
] > 0)
50
{
51
$model->setOwnerId((
int
)$fields[
'OWNER_ID'
]);
52
}
53
54
return
$model;
55
}
56
57
public
static
function
createFromEventModel
(
EventModel
$eventModel): self
58
{
59
if
($eventModel->
getSectionId
() > 0)
60
{
61
$model =
self::createFromId
($eventModel->
getSectionId
());
62
}
63
else
64
{
65
$model =
self::createNew
();
66
}
67
68
$model
69
->setType($eventModel->
getSectionType
())
70
->setOwnerId($eventModel->
getOwnerId
())
71
;
72
73
return
$model;
74
}
75
76
public
static
function
createFromEventModelParentFields
(
EventModel
$eventModel): self
77
{
78
if
($eventModel->
getSectionId
() > 0)
79
{
80
$model =
self::createFromId
($eventModel->
getParentEventSectionId
());
81
}
82
else
83
{
84
$model =
self::createNew
();
85
}
86
87
$model
88
->setType($eventModel->
getParentEventSectionType
())
89
->setOwnerId($eventModel->
getParentEventOwnerId
())
90
;
91
92
return
$model;
93
}
94
95
public
function
setId
(
int
$id): self
96
{
97
$this->
id
= $id;
98
return
$this;
99
}
100
101
public
function
getId
(): int
102
{
103
return
$this->id;
104
}
105
106
public
function
setType
(
string
$type): self
107
{
108
$this->type = $type;
109
return
$this;
110
}
111
112
public
function
getType
(): string
113
{
114
return
$this->type;
115
}
116
117
public
function
setOwnerId
(
int
$ownerId): self
118
{
119
$this->ownerId = $ownerId;
120
return
$this;
121
}
122
123
public
function
getOwnerId
(): int
124
{
125
return
$this->ownerId;
126
}
127
}
Bitrix\Calendar\Access\Model\EventModel
Definition
eventmodel.php:11
Bitrix\Calendar\Access\Model\EventModel\getParentEventSectionId
getParentEventSectionId()
Definition
eventmodel.php:246
Bitrix\Calendar\Access\Model\EventModel\getSectionId
getSectionId()
Definition
eventmodel.php:191
Bitrix\Calendar\Access\Model\EventModel\getParentEventOwnerId
getParentEventOwnerId()
Definition
eventmodel.php:269
Bitrix\Calendar\Access\Model\EventModel\getSectionType
getSectionType()
Definition
eventmodel.php:203
Bitrix\Calendar\Access\Model\EventModel\getParentEventSectionType
getParentEventSectionType()
Definition
eventmodel.php:258
Bitrix\Calendar\Access\Model\EventModel\getOwnerId
getOwnerId()
Definition
eventmodel.php:179
Bitrix\Calendar\Access\Model\SectionModel
Definition
sectionmodel.php:9
Bitrix\Calendar\Access\Model\SectionModel\createNew
static createNew()
Definition
sectionmodel.php:28
Bitrix\Calendar\Access\Model\SectionModel\setOwnerId
setOwnerId(int $ownerId)
Definition
sectionmodel.php:117
Bitrix\Calendar\Access\Model\SectionModel\getId
getId()
Definition
sectionmodel.php:101
Bitrix\Calendar\Access\Model\SectionModel\createFromArray
static createFromArray(array $fields)
Definition
sectionmodel.php:33
Bitrix\Calendar\Access\Model\SectionModel\createFromEventModelParentFields
static createFromEventModelParentFields(EventModel $eventModel)
Definition
sectionmodel.php:76
Bitrix\Calendar\Access\Model\SectionModel\getType
getType()
Definition
sectionmodel.php:112
Bitrix\Calendar\Access\Model\SectionModel\createFromId
static createFromId(int $itemId)
Definition
sectionmodel.php:16
Bitrix\Calendar\Access\Model\SectionModel\getOwnerId
getOwnerId()
Definition
sectionmodel.php:123
Bitrix\Calendar\Access\Model\SectionModel\createFromEventModel
static createFromEventModel(EventModel $eventModel)
Definition
sectionmodel.php:57
Bitrix\Calendar\Access\Model\SectionModel\setId
setId(int $id)
Definition
sectionmodel.php:95
Bitrix\Calendar\Access\Model\SectionModel\setType
setType(string $type)
Definition
sectionmodel.php:106
Bitrix\Calendar\Access\AccessibleSection
Definition
accessiblesection.php:10
Bitrix\Main\Access\AccessibleItem
Definition
accessibleitem.php:13
Bitrix\Calendar\Access\Model
Definition
eventmodel.php:3
modules
calendar
lib
access
model
sectionmodel.php
Создано системой
1.10.0