2020-05-12 17:41:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class RoomsApi extends ApiController{
|
|
|
|
|
|
|
|
public function default(){
|
2020-05-13 08:05:54 +00:00
|
|
|
//$this->requireAuth();
|
2020-05-15 18:59:12 +00:00
|
|
|
$response = [];
|
|
|
|
$roomIds = [];
|
|
|
|
$roomsData = RoomManager::getRoomsDefault();
|
|
|
|
|
|
|
|
foreach ($roomsData as $roomKey => $room) {
|
|
|
|
$roomIds[] = $room['room_id'];
|
|
|
|
}
|
2020-05-12 17:41:46 +00:00
|
|
|
|
2020-05-15 18:59:12 +00:00
|
|
|
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds);
|
|
|
|
|
|
|
|
foreach ($roomsData as $roomKey => $roomData) {
|
|
|
|
$response[] = [
|
2020-05-13 08:05:54 +00:00
|
|
|
'room_id' => $roomData['room_id'],
|
|
|
|
'name' => $roomData['name'],
|
2020-05-15 18:59:12 +00:00
|
|
|
'widgets' => isset($subDevicesData[$roomData['room_id']]) ? $subDevicesData[$roomData['room_id']] : [],
|
2020-05-13 08:05:54 +00:00
|
|
|
];
|
|
|
|
}
|
2020-05-15 18:59:12 +00:00
|
|
|
$this->response($response);
|
2020-05-12 17:41:46 +00:00
|
|
|
}
|
|
|
|
}
|