Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
app.php
1
<?php
2
3
namespace
Bitrix\MobileApp
;
4
5
use
Bitrix\Main\Entity
;
6
use Bitrix\Main\Entity\Event;
7
use Bitrix\Main\Entity\FieldError;
8
use Bitrix\Main\Entity\Result;
9
use
Bitrix\Main\Localization\Loc
;
10
use
Bitrix\Main
;
11
12
Loc::loadMessages
(__FILE__);
13
44
class
AppTable
extends
Entity\DataManager
45
{
46
public
static
function
getFilePath
()
47
{
48
return
__FILE__;
49
}
50
51
public
static
function
getTableName
()
52
{
53
return
'b_mobileapp_app'
;
54
}
55
56
57
public
static
function
getMap
()
58
{
59
return
array(
60
new
Entity
\
StringField
(
'CODE'
, array(
61
'primary'
=>
true
,
62
'validation'
=> array(__CLASS__,
'validateCode'
),
63
'title'
=>
Loc::getMessage
(
'APP_ENTITY_CODE_FIELD'
),
64
)),
65
new
Entity
\
StringField
(
'SHORT_NAME'
, array(
66
'validation'
=> array(__CLASS__,
'validateShortName'
),
67
'title'
=>
Loc::getMessage
(
'APP_ENTITY_SHORT_NAME_FIELD'
),
68
'default_value'
=>
"AppName"
69
)),
70
new
Entity
\
StringField
(
'NAME'
, array(
71
'validation'
=> array(__CLASS__,
'validateName'
),
72
"require"
=>
true
,
73
'title'
=>
Loc::getMessage
(
'APP_ENTITY_NAME_FIELD'
),
74
)),
75
new
Entity
\
TextField
(
'DESCRIPTION'
, array(
76
'default_value'
=>
"App description placeholder"
,
77
'title'
=>
Loc::getMessage
(
'APP_ENTITY_DESCRIPTION_FIELD'
),
78
)),
79
new
Entity
\
TextField
(
'FILES'
, array(
80
'serialized'
=>
true
,
81
'default_value'
=> array(),
82
'title'
=>
Loc::getMessage
(
'APP_ENTITY_FILES_FIELD'
),
83
)),
84
new
Entity
\
TextField
(
'LAUNCH_ICONS'
, array(
85
'serialized'
=>
true
,
86
'default_value'
=> array(),
87
'title'
=>
Loc::getMessage
(
'APP_ENTITY_LAUNCH_ICONS_FIELD'
),
88
)),
89
new
Entity
\
TextField
(
'LAUNCH_SCREENS'
, array(
90
'serialized'
=>
true
,
91
'default_value'
=> array(),
92
'title'
=>
Loc::getMessage
(
'APP_ENTITY_LAUNCH_SCREENS_FIELD'
),
93
)),
94
new
Entity
\
StringField
(
'FOLDER'
, array(
95
'validation'
=> array(__CLASS__,
'validateFolder'
),
96
'require'
=>
true
,
97
'title'
=>
Loc::getMessage
(
'APP_ENTITY_FOLDER_FIELD'
),
98
)),
99
new
Entity
\
DatetimeField
(
'DATE_CREATE'
, array(
100
'default_value'
=>
new
\
Bitrix
\Main\
Type
\
Date
,
101
'title'
=>
Loc::getMessage
(
'APP_ENTITY_DATE_CREATE_FIELD'
),
102
)),
103
new
Entity
\ReferenceField(
104
'CONFIG'
,
105
'Bitrix\MobileApp\Designer\ConfigTable'
,
106
array(
'=this.CODE'
=>
'ref.APP_CODE'
)
107
)
108
);
109
}
110
111
public
static
function
validateCode
()
112
{
113
return
array(
114
new
Entity
\Validator\Unique(
null
, 255),
115
);
116
}
117
118
public
static
function
validateShortName
()
119
{
120
return
array(
121
new
Entity
\Validator\Length(
null
, 20),
122
);
123
}
124
125
public
static
function
validateName
()
126
{
127
return
array(
128
new
Entity
\Validator\Length(
null
, 255),
129
);
130
}
131
132
public
static
function
validateFolder
()
133
{
134
return
array(
135
new
Entity
\Validator\Length(
null
, 255),
136
);
137
}
138
139
public
static
function
isAppExists
($code)
140
{
141
$result = self::getById($code);
142
143
return
($result->getSelectedRowsCount() ?
true
:
false
);
144
}
145
146
public
static
function
onAfterDelete
(
Event
$event)
147
{
148
$parameters = $event->
getParameter
(
"id"
);
149
$code = $parameters[
"CODE"
];
150
Designer\ConfigTable::delete(array(
"APP_CODE"
=> $code));
151
parent::onAfterDelete($event);
152
}
153
154
public
static
function
checkFields
(
Result
$result, $primary, array $data)
155
{
156
parent::checkFields($result, $primary, $data);
157
158
if
($result instanceof
Entity
\
AddResult
)
159
{
160
$entity = self::getEntity();
161
if
(!$data[
"CODE"
])
162
{
163
$result->
addError
(
new
Entity
\
FieldError
($entity->getField(
"CODE"
),
"Can not be empty!"
, FieldError::EMPTY_REQUIRED));
164
}
165
elseif (!$data[
"FOLDER"
])
166
{
167
$result->
addError
(
new
Entity
\
FieldError
($entity->getField(
"FOLDER"
),
"Can not be empty!"
, FieldError::EMPTY_REQUIRED));
168
}
169
elseif (!$data[
"NAME"
])
170
{
171
$result->
addError
(
new
Entity
\
FieldError
($entity->getField(
"NAME"
),
"Can not be empty!"
, FieldError::EMPTY_REQUIRED));
172
}
173
174
}
175
}
176
177
public
static
function
getSupportedPlatforms
()
178
{
179
return
array(
180
"android"
,
181
"ios"
,
182
);
183
}
184
185
186
}
Bitrix\Main\Event
Definition
event.php:5
Bitrix\Main\Event\getParameter
getParameter($key)
Definition
event.php:80
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\AddResult
Definition
addresult.php:12
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\ORM\Fields\DatetimeField
Definition
datetimefield.php:22
Bitrix\Main\ORM\Fields\FieldError
Definition
fielderror.php:14
Bitrix\Main\ORM\Fields\StringField
Definition
stringfield.php:20
Bitrix\Main\ORM\Fields\TextField
Definition
textfield.php:20
Bitrix\Main\Result\addError
addError(Error $error)
Definition
result.php:50
Bitrix\Main\Type\Date
Definition
date.php:9
Bitrix\MobileApp\AppTable
Definition
app.php:45
Bitrix\MobileApp\AppTable\validateShortName
static validateShortName()
Definition
app.php:118
Bitrix\MobileApp\AppTable\getMap
static getMap()
Definition
app.php:57
Bitrix\MobileApp\AppTable\isAppExists
static isAppExists($code)
Definition
app.php:139
Bitrix\MobileApp\AppTable\getFilePath
static getFilePath()
Definition
app.php:46
Bitrix\MobileApp\AppTable\checkFields
static checkFields(Result $result, $primary, array $data)
Definition
app.php:154
Bitrix\MobileApp\AppTable\onAfterDelete
static onAfterDelete(Event $event)
Definition
app.php:146
Bitrix\MobileApp\AppTable\validateFolder
static validateFolder()
Definition
app.php:132
Bitrix\MobileApp\AppTable\getSupportedPlatforms
static getSupportedPlatforms()
Definition
app.php:177
Bitrix\MobileApp\AppTable\validateName
static validateName()
Definition
app.php:125
Bitrix\MobileApp\AppTable\getTableName
static getTableName()
Definition
app.php:51
Bitrix\MobileApp\AppTable\validateCode
static validateCode()
Definition
app.php:111
Bitrix\Main\Type
Definition
collection.php:2
Bitrix\Main
Bitrix\MobileApp
Definition
app.php:3
Bitrix
modules
mobileapp
lib
app.php
Создано системой
1.10.0