1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
CalendarItem.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Im\V2\Link\Calendar;
4
5
use Bitrix\Im\Model\LinkCalendarIndexTable;
6
use Bitrix\Im\Model\LinkCalendarTable;
7
use Bitrix\Im\Model\EO_LinkCalendar;
8
use Bitrix\Im\V2\Entity;
9
use Bitrix\Im\V2\Link\BaseLinkItem;
10
use Bitrix\Im\V2\Rest\RestEntity;
11
use Bitrix\Im\V2\Result;
12
use Bitrix\Main\Type\DateTime;
13
14
class
CalendarItem
extends
BaseLinkItem
15
{
16
protected
string
$title
;
17
protected
DateTime
$dateFrom
;
18
protected
DateTime
$dateTo
;
19
23
public
function
__construct
($source =
null
)
24
{
25
$this->initByDefault();
26
27
if
(!empty($source))
28
{
29
$this->
load
($source);
30
}
31
}
32
37
public
function
setEntity
(
RestEntity
$entity
): self
38
{
39
$this->
setTitle
($entity->
getTitle
())->setDateTo(
$entity
->getDateTo())->setDateFrom(
$entity
->getDateFrom());
40
41
return
parent::setEntity(
$entity
);
42
}
43
44
public
function
getEntity
():
Entity
\
Calendar
\
CalendarItem
45
{
46
$this->entity ??=
Entity\Calendar\CalendarItem::initById
($this->
getEntityId
());
47
48
return
$this->entity
;
49
}
50
51
public
static
function
getByCalendarId
(
int
$id
,
bool
$fillEntity =
true
): ?self
52
{
53
$ormObject = LinkCalendarTable::query()
54
->setSelect([
'*'
])
55
->where(
'CALENDAR_ID'
,
$id
)
56
->setLimit(1)
57
->fetchObject()
58
;
59
60
if
($ormObject ===
null
)
61
{
62
return
null
;
63
}
64
65
if
($fillEntity)
66
{
67
return
(
new
static
($ormObject))->setEntity(
Entity
\
Calendar
\CalendarItem::initById(
$id
));
68
}
69
70
return
new
static
($ormObject);
71
}
72
73
public
static
function
getByMessageId
(
int
$messageId
): ?self
74
{
75
$ormObject = LinkCalendarTable::query()
76
->setSelect([
'*'
])
77
->where(
'MESSAGE_ID'
,
$messageId
)
78
->setLimit(1)
79
->fetchObject()
80
;
81
82
if
($ormObject ===
null
)
83
{
84
return
null
;
85
}
86
87
return
new
static
($ormObject);
88
}
89
90
public
function
save
():
Result
91
{
92
$result
= parent::save();
93
if
(
$result
->isSuccess())
94
{
95
LinkCalendarIndexTable::indexInBackground([$this->
getId
()]);
96
}
97
98
return
$result
;
99
}
100
101
public
function
delete
():
Result
102
{
103
LinkCalendarIndexTable::delete($this->
getPrimaryId
());
104
105
return
parent::delete();
106
}
107
108
public
static
function
getDataClass
(): string
109
{
110
return
LinkCalendarTable::class;
111
}
112
113
protected
static
function
getEntityIdFieldName
(): string
114
{
115
return
'CALENDAR_ID'
;
116
}
117
118
public
static
function
getEntityClassName
(): string
119
{
120
return
Entity\Calendar\CalendarItem::class;
121
}
122
123
public
static
function
getRestEntityName
(): string
124
{
125
return
'link'
;
126
}
127
128
protected
static
function
mirrorDataEntityFields
():
array
129
{
130
$additionalFields = [
131
'CALENDAR_TITLE'
=> [
132
'field'
=>
'title'
,
133
'set'
=>
'setTitle'
,
134
'get'
=>
'getTitle'
,
135
],
136
'CALENDAR_DATE_FROM'
=> [
137
'field'
=>
'dateFrom'
,
138
'set'
=>
'setDateFrom'
,
139
'get'
=>
'getDateFrom'
,
140
],
141
'CALENDAR_DATE_TO'
=> [
142
'field'
=>
'dateTo'
,
143
'set'
=>
'setDateTo'
,
144
'get'
=>
'getDateTo'
,
145
]
146
];
147
148
return
array_merge(parent::mirrorDataEntityFields(), $additionalFields);
149
}
150
151
//region Setters & getters
152
153
public
function
getTitle
(): string
154
{
155
return
$this->title
;
156
}
157
158
public
function
setTitle
(
string
$title
):
CalendarItem
159
{
160
$this->
title
=
$title
;
161
return
$this;
162
}
163
164
public
function
getDateFrom
():
DateTime
165
{
166
return
$this->dateFrom
;
167
}
168
169
public
function
setDateFrom
(
DateTime
$dateFrom
):
CalendarItem
170
{
171
$this->dateFrom =
$dateFrom
;
172
return
$this;
173
}
174
175
public
function
getDateTo
():
DateTime
176
{
177
return
$this->dateTo
;
178
}
179
180
public
function
setDateTo
(
DateTime
$dateTo
):
CalendarItem
181
{
182
$this->dateTo =
$dateTo
;
183
return
$this;
184
}
185
186
//endregion
187
}
Bitrix\Im\V2\Entity\Calendar\CalendarItem\initById
static initById(int $id, ?Context $context=null)
Определения
CalendarItem.php:64
Bitrix\Im\V2\Link\BaseLinkItem
Определения
BaseLinkItem.php:18
Bitrix\Im\V2\Link\BaseLinkItem\getEntityId
getEntityId()
Определения
BaseLinkItem.php:122
Bitrix\Im\V2\Link\BaseLinkItem\getId
getId()
Определения
BaseLinkItem.php:67
Bitrix\Im\V2\Link\BaseLinkItem\$id
int $id
Определения
BaseLinkItem.php:23
Bitrix\Im\V2\Link\BaseLinkItem\getPrimaryId
getPrimaryId()
Определения
BaseLinkItem.php:78
Bitrix\Im\V2\Link\BaseLinkItem\$entity
RestEntity $entity
Определения
BaseLinkItem.php:29
Bitrix\Im\V2\Link\BaseLinkItem\$messageId
int $messageId
Определения
BaseLinkItem.php:25
Bitrix\Im\V2\Link\Calendar\CalendarItem
Определения
CalendarItem.php:15
Bitrix\Im\V2\Link\Calendar\CalendarItem\getRestEntityName
static getRestEntityName()
Определения
CalendarItem.php:123
Bitrix\Im\V2\Link\Calendar\CalendarItem\getEntity
getEntity()
Определения
CalendarItem.php:44
Bitrix\Im\V2\Link\Calendar\CalendarItem\getEntityClassName
static getEntityClassName()
Определения
CalendarItem.php:118
Bitrix\Im\V2\Link\Calendar\CalendarItem\getByCalendarId
static getByCalendarId(int $id, bool $fillEntity=true)
Определения
CalendarItem.php:51
Bitrix\Im\V2\Link\Calendar\CalendarItem\__construct
__construct($source=null)
Определения
CalendarItem.php:23
Bitrix\Im\V2\Link\Calendar\CalendarItem\$title
string $title
Определения
CalendarItem.php:16
Bitrix\Im\V2\Link\Calendar\CalendarItem\getByMessageId
static getByMessageId(int $messageId)
Определения
CalendarItem.php:73
Bitrix\Im\V2\Link\Calendar\CalendarItem\setTitle
setTitle(string $title)
Определения
CalendarItem.php:158
Bitrix\Im\V2\Link\Calendar\CalendarItem\getDateFrom
getDateFrom()
Определения
CalendarItem.php:164
Bitrix\Im\V2\Link\Calendar\CalendarItem\$dateTo
DateTime $dateTo
Определения
CalendarItem.php:18
Bitrix\Im\V2\Link\Calendar\CalendarItem\getTitle
getTitle()
Определения
CalendarItem.php:153
Bitrix\Im\V2\Link\Calendar\CalendarItem\setEntity
setEntity(RestEntity $entity)
Определения
CalendarItem.php:37
Bitrix\Im\V2\Link\Calendar\CalendarItem\getDateTo
getDateTo()
Определения
CalendarItem.php:175
Bitrix\Im\V2\Link\Calendar\CalendarItem\getEntityIdFieldName
static getEntityIdFieldName()
Определения
CalendarItem.php:113
Bitrix\Im\V2\Link\Calendar\CalendarItem\setDateFrom
setDateFrom(DateTime $dateFrom)
Определения
CalendarItem.php:169
Bitrix\Im\V2\Link\Calendar\CalendarItem\getDataClass
static getDataClass()
Определения
CalendarItem.php:108
Bitrix\Im\V2\Link\Calendar\CalendarItem\setDateTo
setDateTo(DateTime $dateTo)
Определения
CalendarItem.php:180
Bitrix\Im\V2\Link\Calendar\CalendarItem\$dateFrom
DateTime $dateFrom
Определения
CalendarItem.php:17
Bitrix\Im\V2\Link\Calendar\CalendarItem\mirrorDataEntityFields
static mirrorDataEntityFields()
Определения
CalendarItem.php:128
Bitrix\Im\V2\Link\Calendar\CalendarItem\save
save()
Определения
CalendarItem.php:90
Bitrix\Main\DB\Result
Определения
result.php:20
Bitrix\Main\ORM\Entity\getTitle
getTitle()
Определения
entity.php:840
Bitrix\Main\Type\DateTime
Определения
datetime.php:9
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
Bitrix\Im\V2\ActiveRecord\load
load($source)
Bitrix\Im\V2\Rest\RestEntity
Определения
RestEntity.php:8
Bitrix\Im\V2\Entity\Calendar
Определения
CalendarCollection.php:3
Bitrix\Main\Entity
Определения
ufield.php:9
title
<? endif;?> window document title
Определения
prolog_main_admin.php:76
bitrix
modules
im
lib
V2
Link
Calendar
CalendarItem.php
Создано системой
1.14.0