Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
collection.php
1
<?php
2
namespace
Bitrix\Sale\Exchange\Integration\Service\Container
;
3
4
use Traversable;
5
6
class
Collection
implements
\IteratorAggregate
7
{
8
protected
$collection
= [];
9
static
$internalIndex
= 0;
10
11
public
function
addItem
(
Item
$item)
12
{
13
$index = $item->
getInternalIndex
() ==
''
?
'n'
.static::$internalIndex++ : $item->
getInternalIndex
();
14
15
$this->collection[$index] = $item;
16
}
17
18
public
function
count
()
19
{
20
return
count
($this->collection);
21
}
22
23
public
function
toArray()
24
{
25
$result = [];
26
if
(
count
($this->collection)>0)
27
{
31
foreach
($this->collection as $index=>$item)
32
{
33
$result[$index] = $item->getEntity()->getFieldsValues();
34
}
35
}
36
return
$result;
37
}
38
39
public
function
getIndexes
()
40
{
41
return
count
($this->collection)>0 ? array_keys($this->collection):[];
42
}
43
48
public
function
getItemByIndex
($index)
49
{
50
$result =
null
;
51
if
(
count
($this->collection)>0)
52
{
53
foreach
($this->collection as $k=>$item)
54
{
55
if
($index == $k)
56
{
57
$result = $item;
58
break
;
59
}
60
}
61
}
62
return
$result;
63
}
64
72
public
function
getIterator
()
73
{
74
return
new \ArrayIterator($this->collection);
75
}
76
}
Bitrix\Sale\Exchange\Integration\Service\Container\Collection
Definition
collection.php:7
Bitrix\Sale\Exchange\Integration\Service\Container\Collection\getIndexes
getIndexes()
Definition
collection.php:39
Bitrix\Sale\Exchange\Integration\Service\Container\Collection\getIterator
getIterator()
Definition
collection.php:72
Bitrix\Sale\Exchange\Integration\Service\Container\Collection\getItemByIndex
getItemByIndex($index)
Definition
collection.php:48
Bitrix\Sale\Exchange\Integration\Service\Container\Collection\$internalIndex
static $internalIndex
Definition
collection.php:9
Bitrix\Sale\Exchange\Integration\Service\Container\Collection\addItem
addItem(Item $item)
Definition
collection.php:11
Bitrix\Sale\Exchange\Integration\Service\Container\Collection\$collection
$collection
Definition
collection.php:8
Bitrix\Sale\Exchange\Integration\Service\Container\Collection\count
count()
Definition
collection.php:18
Bitrix\Sale\Exchange\Integration\Service\Container\Item
Definition
item.php:9
Bitrix\Sale\Exchange\Integration\Service\Container\Item\getInternalIndex
getInternalIndex()
Definition
item.php:31
Bitrix\Sale\Exchange\Integration\Service\Container
Definition
collection.php:2
modules
sale
lib
exchange
integration
service
container
collection.php
Создано системой
1.10.0