Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
category.php
1
<?php
2
3
namespace
Bitrix\Calendar\Rooms\Categories
;
4
5
6
7
use
Bitrix\Calendar\Internals\RoomCategoryTable
;
8
use
Bitrix\Main\Error
;
9
use
Bitrix\Main\Localization\Loc
;
10
use
Bitrix\Main\Text\Emoji
;
11
12
class
Category
13
{
15
private
?
int
$id;
17
private
string
$name =
''
;
19
private
?
Error
$error =
null
;
21
private
?array $rooms =
null
;
22
28
public
function
setId
(?
int
$id):
Category
29
{
30
$this->
id
= $id;
31
32
return
$this;
33
}
34
40
public
function
setName
(?
string
$name):
Category
41
{
42
$this->name =
Manager::checkCategoryName
($name);
43
44
return
$this;
45
}
46
51
public
function
setRooms
(?array $rooms):
Category
52
{
53
$this->rooms = $rooms;
54
55
return
$this;
56
}
57
63
private
function
addError($error)
64
{
65
$this->error = $error;
66
}
67
71
public
function
getId
(): int
72
{
73
return
$this->id;
74
}
75
79
public
function
getName
(): string
80
{
81
return
$this->name;
82
}
83
87
public
function
getRooms
() : ?array
88
{
89
return
$this->rooms;
90
}
91
95
public
function
getError
(): ?
Error
96
{
97
return
$this->error;
98
}
99
103
public
function
create
():
Category
104
{
105
$section = RoomCategoryTable::add([
106
'NAME'
=> Emoji::encode($this->name),
107
]);
108
if
(!$section->isSuccess())
109
{
110
$this->addError(
new
Error
(
'An error occurred while saving the category'
));
111
}
112
113
$this->
setId
($section->getId());
114
115
return
$this;
116
}
117
121
public
function
update
():
Category
122
{
123
$section = RoomCategoryTable::update(
124
$this->
id
,
125
[
126
'NAME'
=> Emoji::encode($this->name),
127
]
128
);
129
if
(!$section->isSuccess())
130
{
131
$this->addError(
new
Error
(
'An error occurred while saving the category'
));
132
}
133
return
$this;
134
}
135
139
public
function
delete
():
Category
140
{
141
$category = RoomCategoryTable::delete($this->
id
);
142
if
(!$category->isSuccess())
143
{
144
$this->addError(
new
Error
(
'An error occurred while deleting the category'
));
145
}
146
return
$this;
147
}
148
}
Bitrix\Calendar\Internals\RoomCategoryTable
Definition
roomcategorytable.php:36
Bitrix\Calendar\Rooms\Categories\Category
Definition
category.php:13
Bitrix\Calendar\Rooms\Categories\Category\getRooms
getRooms()
Definition
category.php:87
Bitrix\Calendar\Rooms\Categories\Category\setId
setId(?int $id)
Definition
category.php:28
Bitrix\Calendar\Rooms\Categories\Category\getId
getId()
Definition
category.php:71
Bitrix\Calendar\Rooms\Categories\Category\getError
getError()
Definition
category.php:95
Bitrix\Calendar\Rooms\Categories\Category\getName
getName()
Definition
category.php:79
Bitrix\Calendar\Rooms\Categories\Category\create
create()
Definition
category.php:103
Bitrix\Calendar\Rooms\Categories\Category\update
update()
Definition
category.php:121
Bitrix\Calendar\Rooms\Categories\Category\setName
setName(?string $name)
Definition
category.php:40
Bitrix\Calendar\Rooms\Categories\Category\setRooms
setRooms(?array $rooms)
Definition
category.php:51
Bitrix\Calendar\Rooms\Categories\Manager\checkCategoryName
static checkCategoryName(?string $name)
Definition
manager.php:224
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Text\Emoji
Definition
emoji.php:10
Bitrix\Calendar\Rooms\Categories
Definition
category.php:3
modules
calendar
lib
rooms
categories
category.php
Создано системой
1.10.0