Bitrix-D7
20.5.0
main/lib/response.php
См. документацию.
1
<?php
2
namespace
Bitrix\Main;
3
4
abstract
class
Response
5
{
6
/** @var string */
7
protected
$content
;
8
9
public
function
__construct
()
10
{
11
}
12
13
public
function
clear
()
14
{
15
}
16
17
public
function
flush
($text =
''
)
18
{
19
$this->
writeBody
($text);
20
}
21
22
/**
23
* Sets content.
24
* Valid types are strings, numbers, null, and objects that implement a __toString() method.
25
*
26
* @param mixed $content Content that can be cast to string.
27
*
28
* @return $this
29
* @throws ArgumentTypeException
30
*/
31
public
function
setContent
(
$content
)
32
{
33
if
(!$this->
checkContent
(
$content
))
34
{
35
throw
new
ArgumentTypeException
(
'content'
,
'string'
);
36
}
37
38
$this->content = (string)
$content
;
39
40
return
$this;
41
}
42
43
/**
44
* Appends content.
45
* Valid types are strings, numbers, null, and objects that implement a __toString() method.
46
*
47
* @param mixed $content Content that can be cast to string.
48
*
49
* @return $this
50
* @throws ArgumentTypeException
51
*/
52
public
function
appendContent
(
$content
)
53
{
54
if
(!$this->
checkContent
(
$content
))
55
{
56
throw
new
ArgumentTypeException
(
'content'
,
'string'
);
57
}
58
59
$this->content .= (string)
$content
;
60
61
return
$this;
62
}
63
64
protected
function
checkContent
(
$content
)
65
{
66
return
(
67
$content
===
null
||
68
is_string(
$content
) ||
69
is_numeric(
$content
) ||
70
is_callable(array(
$content
,
'__toString'
))
71
);
72
}
73
74
/**
75
* Returns content of response.
76
*
77
* @return string
78
*/
79
public
function
getContent
()
80
{
81
return
$this->content
;
82
}
83
84
/**
85
* Sends content to the output.
86
*
87
* @return void
88
*/
89
public
function
send
()
90
{
91
$this->
flush
($this->content);
92
}
93
94
protected
function
writeBody
($text)
95
{
96
echo $text;
97
}
98
}
Bitrix\Main\ArgumentTypeException
Exception is thrown when the type of an argument is not accepted by function.
Definition:
main/lib/exception.php:114
Bitrix\Main\Response
Definition:
main/lib/response.php:5
Bitrix\Main\Response\appendContent
appendContent($content)
Appends content.
Definition:
main/lib/response.php:52
Bitrix\Main\Response\setContent
setContent($content)
Sets content.
Definition:
main/lib/response.php:31
Bitrix\Main\Response\__construct
__construct()
Definition:
main/lib/response.php:9
Bitrix\Main\Response\send
send()
Sends content to the output.
Definition:
main/lib/response.php:89
Bitrix\Main\Response\flush
flush($text='')
Definition:
main/lib/response.php:17
Bitrix\Main\Response\$content
$content
Definition:
main/lib/response.php:7
Bitrix\Main\Response\getContent
getContent()
Returns content of response.
Definition:
main/lib/response.php:79
Bitrix\Main\Response\clear
clear()
Definition:
main/lib/response.php:13
Bitrix\Main\Response\checkContent
checkContent($content)
Definition:
main/lib/response.php:64
Bitrix\Main\Response\writeBody
writeBody($text)
Definition:
main/lib/response.php:94
modules
main
lib
response.php
Создано системой
1.9.1