1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
templatecollection.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Location\Entity\Format;
4
5
use Bitrix\Location\Entity\Generic\Collection;
6
use Bitrix\Main\ArgumentTypeException;
7
8
final
class
TemplateCollection
extends
Collection
9
{
11
protected
$items
= [];
12
19
public
function
addItem
(
$template
): int
20
{
21
if
(!(
$template
instanceof
Template
))
22
{
23
throw
new
ArgumentTypeException
(
'field must be the instance of Template'
);
24
}
25
26
$this->removeTemplateByType(
$template
->getType());
27
return
parent::addItem(
$template
);
28
}
29
33
private
function
removeTemplateByType(
string
$type
): void
34
{
35
foreach
($this->items as $idx =>
$template
)
36
{
37
if
(
$template
->getType() ===
$type
)
38
{
39
unset($this->items[$idx]);
40
break
;
41
}
42
}
43
}
44
49
public
function
getTemplate
(
string
$type
): ?
Template
50
{
51
foreach
($this->items as
$template
)
52
{
53
if
(
$template
->getType() ===
$type
)
54
{
55
return
$template
;
56
}
57
}
58
59
return
null
;
60
}
61
}
$type
$type
Определения
options.php:106
Bitrix\Location\Entity\Format\TemplateCollection
Определения
templatecollection.php:9
Bitrix\Location\Entity\Format\TemplateCollection\addItem
addItem($template)
Определения
templatecollection.php:19
Bitrix\Location\Entity\Format\TemplateCollection\$items
$items
Определения
templatecollection.php:11
Bitrix\Location\Entity\Format\TemplateCollection\getTemplate
getTemplate(string $type)
Определения
templatecollection.php:49
Bitrix\Location\Entity\Format\Template
Определения
template.php:12
Bitrix\Location\Entity\Generic\Collection
Определения
collection.php:12
Bitrix\Main\ArgumentTypeException
Определения
ArgumentTypeException.php:9
$template
$template
Определения
file_edit.php:49
bitrix
modules
location
lib
entity
format
templatecollection.php
Создано системой
1.14.0