Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
page.php
1
<?php
2
3
namespace
Bitrix\Main\Engine\Response\DataType
;
4
5
use
Bitrix\Main\Type\Contract\Arrayable
;
6
7
final
class
Page
implements
Arrayable
, \IteratorAggregate, \ArrayAccess, \JsonSerializable
8
{
10
private
$id;
12
private
$items = [];
13
15
private
$totalCount;
16
private
$calculatedTotalCount;
17
23
public
function
__construct
($id, $items, $totalCount)
24
{
25
$data = [];
26
if
(!is_array($items) && $items instanceof \Traversable)
27
{
28
foreach
($items as $item)
29
{
30
$data[] = $item;
31
}
32
}
33
else
34
{
35
$data = $items;
36
}
37
38
$this->
id
= $id;
39
$this->items = $data;
40
$this->totalCount = $totalCount;
41
}
42
46
public
function
getTotalCount
()
47
{
48
if
($this->totalCount instanceof \Closure)
49
{
50
$this->calculatedTotalCount = call_user_func($this->totalCount);
51
}
52
else
53
{
54
$this->calculatedTotalCount = $this->totalCount;
55
}
56
57
return
$this->calculatedTotalCount;
58
}
59
60
64
public
function
getId
()
65
{
66
return
$this->id;
67
}
68
72
public
function
getItems
()
73
{
74
return
$this->items;
75
}
76
84
public
function
getIterator
()
85
{
86
return
new \ArrayIterator($this->items);
87
}
88
103
public
function
offsetExists
($offset)
104
{
105
return
isset($this->items[$offset]) || array_key_exists($offset, $this->items);
106
}
107
119
#[\ReturnTypeWillChange]
120
public
function
offsetGet
($offset)
121
{
122
if
(isset($this->items[$offset]) || array_key_exists($offset, $this->items))
123
{
124
return
$this->items[$offset];
125
}
126
127
return
null
;
128
}
129
144
public
function
offsetSet
($offset, $value): void
145
{
146
if
($offset ===
null
)
147
{
148
$this->items[] = $value;
149
}
150
else
151
{
152
$this->items[$offset] = $value;
153
}
154
}
155
167
public
function
offsetUnset
($offset): void
168
{
169
unset($this->items[$offset]);
170
}
171
179
public
function
jsonSerialize
(): array
180
{
181
return
$this->
toArray
();
182
}
183
184
public
function
toArray
()
185
{
186
return
[
187
$this->
id
=> $this->items
188
];
189
}
190
}
Bitrix\Main\Engine\Response\DataType\Page
Definition
page.php:8
Bitrix\Main\Engine\Response\DataType\Page\getId
getId()
Definition
page.php:64
Bitrix\Main\Engine\Response\DataType\Page\offsetUnset
offsetUnset($offset)
Definition
page.php:167
Bitrix\Main\Engine\Response\DataType\Page\offsetExists
offsetExists($offset)
Definition
page.php:103
Bitrix\Main\Engine\Response\DataType\Page\offsetGet
offsetGet($offset)
Definition
page.php:120
Bitrix\Main\Engine\Response\DataType\Page\toArray
toArray()
Definition
page.php:184
Bitrix\Main\Engine\Response\DataType\Page\getTotalCount
getTotalCount()
Definition
page.php:46
Bitrix\Main\Engine\Response\DataType\Page\getIterator
getIterator()
Definition
page.php:84
Bitrix\Main\Engine\Response\DataType\Page\__construct
__construct($id, $items, $totalCount)
Definition
page.php:23
Bitrix\Main\Engine\Response\DataType\Page\getItems
getItems()
Definition
page.php:72
Bitrix\Main\Engine\Response\DataType\Page\offsetSet
offsetSet($offset, $value)
Definition
page.php:144
Bitrix\Main\Engine\Response\DataType\Page\jsonSerialize
jsonSerialize()
Definition
page.php:179
Bitrix\Main\Type\Contract\Arrayable
Definition
arrayable.php:6
Bitrix\Main\Engine\Response\DataType
Definition
contenturi.php:3
modules
main
lib
engine
response
datatype
page.php
Создано системой
1.10.0