1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
EntityCollection.php
См. документацию.
1
<?php
2
3
declare(strict_types=1);
4
5
namespace
Bitrix\Main\Entity;
6
7
use Bitrix\Main\ArgumentTypeException;
8
9
class
EntityCollection
implements
EntityCollectionInterface
10
{
11
protected
array
$items
= [];
12
13
public
function
__construct
(
EntityInterface
...
$items
)
14
{
15
foreach
(
$items
as $item)
16
{
17
$this->
add
($item);
18
}
19
}
20
21
public
function
count
(): int
22
{
23
return
count
($this->items);
24
}
25
26
public
function
isEmpty
(): bool
27
{
28
return
empty($this->items);
29
}
30
31
public
function
getIterator
(): \ArrayIterator
32
{
33
return
new \ArrayIterator($this->items);
34
}
35
39
public
function
add
(
EntityInterface
$item): void
40
{
41
if
(!is_a($item, static::getEntityClass()))
42
{
43
throw
new
ArgumentTypeException
(
'item'
, static::getEntityClass());
44
}
45
46
$this->items[] = $item;
47
}
48
49
public
function
find
(callable $callback): ?
EntityInterface
50
{
51
// On PHP 8.4 replace to
52
// return array_find($this->items, $callback);
53
54
foreach
($this->items as
$key
=> $item)
55
{
56
if
($callback($item,
$key
))
57
{
58
return
$item;
59
}
60
}
61
62
return
null
;
63
}
64
65
public
function
filter
(callable $callback): static
66
{
67
return
new
static
(...array_filter($this->items, $callback));
68
}
69
73
public
function
map
(callable $callback):
array
74
{
75
return
array_map($callback, $this->items);
76
}
77
81
protected
static
function
getEntityClass
(): string
82
{
83
return
EntityInterface::class;
84
}
85
}
Bitrix\Main\ArgumentTypeException
Определения
ArgumentTypeException.php:9
Bitrix\Main\Entity\EntityCollection
Определения
EntityCollection.php:10
Bitrix\Main\Entity\EntityCollection\getIterator
getIterator()
Определения
EntityCollection.php:31
Bitrix\Main\Entity\EntityCollection\getEntityClass
static getEntityClass()
Определения
EntityCollection.php:81
Bitrix\Main\Entity\EntityCollection\$items
array $items
Определения
EntityCollection.php:11
Bitrix\Main\Entity\EntityCollection\__construct
__construct(EntityInterface ... $items)
Определения
EntityCollection.php:13
Bitrix\Main\Entity\EntityCollection\add
add(EntityInterface $item)
Определения
EntityCollection.php:39
Bitrix\Main\Entity\EntityCollection\filter
filter(callable $callback)
Определения
EntityCollection.php:65
Bitrix\Main\Entity\EntityCollection\count
count()
Определения
EntityCollection.php:21
Bitrix\Main\Entity\EntityCollection\map
map(callable $callback)
Определения
EntityCollection.php:73
Bitrix\Main\Entity\EntityCollection\find
find(callable $callback)
Определения
EntityCollection.php:49
Bitrix\Main\Entity\EntityCollection\isEmpty
isEmpty()
Определения
EntityCollection.php:26
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Main\Entity\EntityCollectionInterface
Определения
EntityCollectionInterface.php:10
Bitrix\Main\Entity\EntityInterface
Определения
EntityInterface.php:8
$key
if(empty($signedUserToken)) $key
Определения
quickway.php:257
bitrix
modules
main
lib
Entity
EntityCollection.php
Создано системой
1.14.0