Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
contentjson.php
1
<?php
8
namespace
Bitrix\Sender\Internals\QueryController
;
9
10
use
Bitrix\Main\Localization\Loc
;
11
use
Bitrix\Main\Web\Json
;
12
13
Loc::loadMessages
(__FILE__);
14
19
class
ContentJson
extends
Content
20
{
21
protected
$parameters
= array();
22
23
public
function
set
(array
$parameters
)
24
{
25
$this->parameters =
$parameters
;
26
}
27
28
public
function
add
($name, $value)
29
{
30
$this->parameters[$name] = $value;
31
}
32
33
public
function
toText
()
34
{
35
$default = array(
36
'error'
=> !$this->errors->isEmpty(),
37
'text'
=> implode(
'<br>'
, $this->getErrorMessages()),
38
);
39
$errorCodes = [];
40
foreach
($this->
getErrorCollection
() as $error)
41
{
43
if
($error->getCode())
44
$errorCodes[] = $error->getCode();
45
}
46
if
($errorCodes)
47
{
48
$default[
'code'
] = $errorCodes[0];
49
}
50
return
Json::encode($this->parameters + $default);
51
}
52
53
public
function
onFlush
()
54
{
55
$this->response->addHeader(
'Content-Type'
,
'application/json; charset=UTF-8'
);
56
}
57
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Web\Json
Definition
json.php:11
Bitrix\Sender\Internals\QueryController\Content
Definition
content.php:21
Bitrix\Sender\Internals\QueryController\Content\toText
toText()
Bitrix\Sender\Internals\QueryController\Content\getErrorCollection
getErrorCollection()
Definition
content.php:91
Bitrix\Sender\Internals\QueryController\ContentJson
Definition
contentjson.php:20
Bitrix\Sender\Internals\QueryController\ContentJson\add
add($name, $value)
Definition
contentjson.php:28
Bitrix\Sender\Internals\QueryController\ContentJson\onFlush
onFlush()
Definition
contentjson.php:53
Bitrix\Sender\Internals\QueryController\ContentJson\$parameters
$parameters
Definition
contentjson.php:21
Bitrix\Sender\Internals\QueryController
Definition
action.php:8
modules
sender
lib
internals
querycontroller
contentjson.php
Создано системой
1.10.0