Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
storage.php
1
<?php
2
3
namespace
Bitrix\Rest\Configuration\Core
;
4
5
use
Bitrix\Main\Localization\Loc
;
6
use
Bitrix\Main\ORM\Data\DataManager
;
7
use
Bitrix\Main\ORM\Fields\DatetimeField
;
8
use
Bitrix\Main\ORM\Fields\IntegerField
;
9
use
Bitrix\Main\ORM\Fields\StringField
;
10
use
Bitrix\Main\ORM\Fields\ArrayField
;
11
use
Bitrix\Rest\Configuration\Structure
;
12
13
use
Bitrix\Main\ORM\Fields\Validators\LengthValidator
;
14
15
Loc::loadMessages
(__FILE__);
16
44
class
StorageTable
extends
DataManager
45
{
51
public
static
function
getTableName
()
52
{
53
return
'b_rest_configuration_storage'
;
54
}
55
61
public
static
function
getMap
()
62
{
63
return
[
64
new
IntegerField
(
65
'ID'
,
66
[
67
'primary'
=>
true
,
68
'autocomplete'
=>
true
,
69
]
70
),
71
new
DatetimeField
(
72
'CREATE_TIME'
,
73
[
74
'required'
=>
true
,
75
]
76
),
77
new
StringField
(
78
'CONTEXT'
,
79
[
80
'required'
=>
true
,
81
'validation'
=> [__CLASS__,
'validateContext'
],
82
]
83
),
84
new
StringField
(
85
'CODE'
,
86
[
87
'required'
=>
true
,
88
'validation'
=> [__CLASS__,
'validateCode'
],
89
]
90
),
91
new
ArrayField
(
92
'DATA'
,
93
[
94
'required'
=>
true
,
95
]
96
),
97
];
98
}
99
105
public
static
function
validateContext
()
106
{
107
return
[
108
new
LengthValidator
(
null
, 128),
109
];
110
}
111
117
public
static
function
validateCode
()
118
{
119
return
[
120
new
LengthValidator
(
null
, 32),
121
];
122
}
123
124
public
static
function
deleteByFilter
($filter)
125
{
126
$res = static::getList(
127
[
128
'filter'
=> $filter
129
]
130
);
131
while
($item = $res->fetch())
132
{
133
static::deleteFile($item);
134
static::delete($item[
'ID'
]);
135
}
136
}
137
138
public
static
function
deleteFile
($item)
139
{
140
if
(
141
isset($item[
'DATA'
][
'ID'
])
142
&& (
int
) $item[
'DATA'
][
'ID'
] > 0
143
&& (
144
$item[
'CODE'
] ===
Structure::CODE_CONFIGURATION_FILES_LIST
145
|| mb_strpos($item[
'CODE'
],
Structure::CODE_CUSTOM_FILE
) !==
false
146
)
147
)
148
{
149
\CFile::Delete((
int
) $item[
'DATA'
][
'ID'
]);
150
}
151
}
152
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\ORM\Data\DataManager
Definition
datamanager.php:33
Bitrix\Main\ORM\Fields\ArrayField
Definition
arrayfield.php:19
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\Rest\Configuration\Core\StorageTable
Definition
storage.php:45
Bitrix\Rest\Configuration\Core\StorageTable\getMap
static getMap()
Definition
storage.php:61
Bitrix\Rest\Configuration\Core\StorageTable\deleteByFilter
static deleteByFilter($filter)
Definition
storage.php:124
Bitrix\Rest\Configuration\Core\StorageTable\deleteFile
static deleteFile($item)
Definition
storage.php:138
Bitrix\Rest\Configuration\Core\StorageTable\getTableName
static getTableName()
Definition
storage.php:51
Bitrix\Rest\Configuration\Core\StorageTable\validateContext
static validateContext()
Definition
storage.php:105
Bitrix\Rest\Configuration\Core\StorageTable\validateCode
static validateCode()
Definition
storage.php:117
Bitrix\Rest\Configuration\Structure
Definition
structure.php:17
Bitrix\Rest\Configuration\Structure\CODE_CONFIGURATION_FILES_LIST
const CODE_CONFIGURATION_FILES_LIST
Definition
structure.php:18
Bitrix\Rest\Configuration\Structure\CODE_CUSTOM_FILE
const CODE_CUSTOM_FILE
Definition
structure.php:22
Bitrix\Rest\Configuration\Core
Definition
ownerentity.php:3
modules
rest
lib
configuration
core
storage.php
Создано системой
1.10.0