1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
channelprovider.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Integration\UI\EntitySelector\OpenEvents;
4
5use Bitrix\Calendar\Integration\Im\EventCategoryService;
6use Bitrix\Main\Engine\CurrentUser;
7use Bitrix\UI\EntitySelector\BaseProvider;
8use Bitrix\UI\EntitySelector\Dialog;
9use Bitrix\UI\EntitySelector\Item;
10
11final class ChannelProvider extends BaseProvider
12{
13 public const ENTITY_ID = 'im-channel';
14
15 private int $userId;
16
17 public function __construct()
18 {
19 parent::__construct();
20
21 $this->userId = (int)CurrentUser::get()->getId();
22 }
23
24 public function isAvailable(): bool
25 {
26 return $this->userId > 0;
27 }
28
29 public function getItems(array $ids): array
30 {
31 return $this->getChannels();
32 }
33
34 public function fillDialog(Dialog $dialog): void
35 {
36 $dialog->addItems($this->getChannels());
37 }
38
39 private function getChannels(): array
40 {
41 $channels = (new EventCategoryService())->getAvailableChannelsList($this->userId);
42
43 return array_map(static fn (array $it) => self::makeItem($it), $channels);
44 }
45
46 private static function makeItem(array $item): Item
47 {
48 return new Item([
49 'id' => $item['id'],
50 'entityId' => self::ENTITY_ID,
51 'title' => $item['title'],
52 'tabs' => 'recents',
53 'avatar' => $item['avatar'],
54 'customData' => [
55 'color' => $item['color'],
56 'closed' => $item['closed'],
57 ],
58 ]);
59 }
60}
Определения dialog.php:11
addItems(array $items)
Определения dialog.php:135
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804