Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
roomprovider.php
1<?php
5
7{
8 public const ENTITY_ID = 'room';
9
10 public function __construct(array $options = [])
11 {
12 parent::__construct();
14 }
15
16 protected function prepareOptions(array $options = [])
17 {
18
19 }
20
21 public function isAvailable(): bool
22 {
23 return $GLOBALS['USER']->isAuthorized();
24 }
25
26 public function shouldFillDialog(): bool
27 {
28 return $this->getOption('fillDialog', true);
29 }
30
31 public function getItems(array $ids): array
32 {
33 $roomList = \Bitrix\Calendar\Rooms\Manager::getRoomsList();
34
35 return $this->getItemsFromRoomList($roomList);
36 }
37
38 public function getSelectedItems(array $ids): array
39 {
40 $roomList = \Bitrix\Calendar\Rooms\Manager::getRoomsList();
41
42 return $this->getItemsFromRoomList($roomList);
43 }
44
45 public function getItemsFromRoomList(array $roomList)
46 {
47 $items = [];
48 foreach ($roomList as $room)
49 {
50 $items[] = $this->makeItem(['id' => $room['ID'], 'title' => $room['NAME'], 'color' => $room['COLOR']]);
51 }
52
53 return $items;
54 }
55
56 public function makeItem(array $item, array $options = []): Item
57 {
58 $itemOptions = [
59 'id' => $item['id'],
60 'entityId' => self::ENTITY_ID,
61 'title' => $item['title'],
62 'avatarOptions' => [
63 'bgColor' => $item['color'],
64 'bgSize' => '22px',
65 'bgImage' => '',
66 ],
67 'tabs' => 'room',
68 ];
69
70 return new Item($itemOptions);
71 }
72
73 public function getRooms()
74 {
75 $roomList = \Bitrix\Calendar\Rooms\Manager::getRoomsList();
76 return $this->getItemsFromRoomList($roomList);
77 }
78
79 public function fillDialog(Dialog $dialog): void
80 {
81 $dialog->addItems($this->getRooms());
82 }
83}
getOption(string $option, $defaultValue=null)
$GLOBALS['____1444769544']
Definition license.php:1