Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
tag.php
1<?php
2
4
5use Bitrix\Main\Entity\Query;
7
8class Tag
9{
10 public static function fillTags(array $params = []): array
11 {
12 $result = [];
13
14 if (
15 !isset($params['groupIdList'])
16 || !is_array($params['groupIdList'])
17 )
18 {
19 return $result;
20 }
21
22 $groupIdList = Util::filterNumericIdList($params['groupIdList']);
23 if (empty($groupIdList))
24 {
25 return $result;
26 }
27
28 $query = new Query(WorkgroupTagTable::getEntity());
29 $records = $query
30 ->setSelect([
31 'GROUP_ID',
32 'NAME',
33 ])
34 ->whereIn('GROUP_ID', $groupIdList)
35 ->exec()->fetchCollection();
36
37 foreach ($records as $record)
38 {
39 $tag = (string)$record->get('NAME');
40 $groupId = (int)$record->get('GROUP_ID');
41
42 if (!isset($result[$groupId]))
43 {
44 $result[$groupId] = [];
45 }
46
47 $result[$groupId][] = $tag;
48 }
49
50 return $result;
51 }
52}
Definition tag.php:9