Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
optiongrouptable.php
1
<?php
2
3
namespace
Bitrix\Im\Model
;
4
5
use
Bitrix\Main\ArgumentTypeException
,
6
Bitrix\Main\ORM\Data\DataManager
,
7
Bitrix\Main\ORM\Fields\DatetimeField
,
8
Bitrix\Main\ORM\Fields\IntegerField
,
9
Bitrix\Main\ORM\Fields\StringField
,
10
Bitrix\Main\ORM\Fields\Validators\LengthValidator
,
11
Bitrix\Main\SystemException
;
12
use Bitrix\Main\Entity\Event;
13
use
Bitrix\Main\ORM\EventResult
;
14
use
Bitrix\Main\Type\DateTime
;
15
16
17
36
class
OptionGroupTable
extends
DataManager
37
{
43
public
static
function
getTableName
(): string
44
{
45
return
'b_im_option_group'
;
46
}
47
54
public
static
function
getMap
(): array
55
{
56
return
[
57
'ID'
=> (
new
IntegerField
(
'ID'
, [
58
'primary'
=>
true
,
59
'autocomplete'
=>
true
,
60
])),
61
'NAME'
=> (
new
StringField
(
'NAME'
, [
62
'validation'
=> [__CLASS__,
'validateName'
]
63
])),
64
'USER_ID'
=> (
new
IntegerField
(
'USER_ID'
, [])),
65
'SORT'
=> (
new
IntegerField
(
'SORT'
, [
66
'required'
=>
true
,
67
])),
68
'DATE_CREATE'
=> (
new
DatetimeField
(
'DATE_CREATE'
, [
69
'required'
=>
true
,
70
])),
71
'CREATE_BY_ID'
=> (
new
IntegerField
(
'CREATE_BY_ID'
, [
72
'required'
=>
true
,
73
])),
74
'DATE_MODIFY'
=> (
new
DatetimeField
(
'DATE_MODIFY'
, [])),
75
'MODIFY_BY_ID'
=> (
new
IntegerField
(
'MODIFY_BY_ID'
, [])),
76
];
77
}
78
85
public
static
function
validateName
(): array
86
{
87
return
[
88
new
LengthValidator
(
null
, 255),
89
];
90
}
91
92
public
static
function
onBeforeAdd
(
Event
$event):
EventResult
93
{
94
$data = $event->getParameter(
'fields'
);
95
$result =
new
EventResult
();
96
if
(!isset($data[
'CREATE_DATE'
]) || !is_array($data[
'CREATE_DATE'
]))
97
{
98
$result->modifyFields([
'DATE_CREATE'
=>
new
Datetime()]);
99
}
100
101
return
$result;
102
}
103
104
public
static
function
onBeforeUpdate
(
Event
$event):
EventResult
105
{
106
$data = $event->getParameter(
'fields'
);
107
$result =
new
EventResult
();
108
if
(!isset($data[
'MODIFY_DATE'
]) || !is_array($data[
'MODIFY_DATE'
]))
109
{
110
$result->modifyFields([
'DATE_MODIFY'
=>
new
DateTime
()]);
111
}
112
113
return
$result;
114
}
115
}
Bitrix\Im\Model\OptionGroupTable
Definition
optiongrouptable.php:37
Bitrix\Im\Model\OptionGroupTable\getMap
static getMap()
Definition
optiongrouptable.php:54
Bitrix\Im\Model\OptionGroupTable\onBeforeAdd
static onBeforeAdd(Event $event)
Definition
optiongrouptable.php:92
Bitrix\Im\Model\OptionGroupTable\validateName
static validateName()
Definition
optiongrouptable.php:85
Bitrix\Im\Model\OptionGroupTable\onBeforeUpdate
static onBeforeUpdate(Event $event)
Definition
optiongrouptable.php:104
Bitrix\Im\Model\OptionGroupTable\getTableName
static getTableName()
Definition
optiongrouptable.php:43
Bitrix\Im\V2\Sync\Event
Definition
Event.php:9
Bitrix\Main\ArgumentTypeException
Definition
exception.php:114
Bitrix\Main\EventResult
Definition
eventresult.php:5
Bitrix\Main\ORM\Data\DataManager
Definition
datamanager.php:33
Bitrix\Main\ORM\Fields\DatetimeField
Definition
datetimefield.php:22
Bitrix\Main\ORM\Fields\IntegerField
Definition
integerfield.php:20
Bitrix\Main\ORM\Fields\StringField
Definition
stringfield.php:20
Bitrix\Main\ORM\Fields\Validators\LengthValidator
Definition
lengthvalidator.php:19
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Im\Model
Definition
alias.php:2
modules
im
lib
model
optiongrouptable.php
Создано системой
1.10.0