Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
listconfig.php
1<?php
2
4
6
7class ListConfig extends Config
8{
9 private array $items;
10
15 public function __construct(string $name, array $items, string $type = Types::DROPDOWN)
16 {
17 parent::__construct($name, $type);
18
19 $this->items = $items;
20 }
21
27 private function getItemsAsDropdown(): array
28 {
29 $result = [];
30
31 foreach ($this->items as $value => $name)
32 {
33 $result[] = [
34 'VALUE' => $value,
35 'NAME' => $name,
36 ];
37 }
38
39 return $result;
40 }
41
45 public function toArray(): array
46 {
47 $result = parent::toArray();
48
49 $result['DATA'] = [
50 'ITEMS' => $this->getItemsAsDropdown(),
51 ];
52
53 return $result;
54 }
55}
__construct(string $name, array $items, string $type=Types::DROPDOWN)