2020-05-15 20:45:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class RoomsApi extends ApiController{
|
|
|
|
|
|
|
|
public function default(){
|
|
|
|
//$this->requireAuth();
|
2020-05-16 20:11:20 +00:00
|
|
|
$response = [];
|
|
|
|
$roomIds = [];
|
|
|
|
$roomsData = RoomManager::getRoomsDefault();
|
2020-05-15 20:45:31 +00:00
|
|
|
|
2020-05-16 20:11:20 +00:00
|
|
|
foreach ($roomsData as $roomKey => $room) {
|
|
|
|
$roomIds[] = $room['room_id'];
|
|
|
|
}
|
2020-05-15 20:45:31 +00:00
|
|
|
|
2020-05-16 20:11:20 +00:00
|
|
|
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds($roomIds);
|
2020-05-15 20:49:35 +00:00
|
|
|
|
2020-05-16 20:11:20 +00:00
|
|
|
foreach ($roomsData as $roomKey => $roomData) {
|
|
|
|
$response[] = [
|
2020-05-15 20:45:31 +00:00
|
|
|
'room_id' => $roomData['room_id'],
|
|
|
|
'name' => $roomData['name'],
|
2020-05-16 20:11:20 +00:00
|
|
|
'widgets' => isset($subDevicesData[$roomData['room_id']]) ? $subDevicesData[$roomData['room_id']] : [],
|
2020-05-15 20:45:31 +00:00
|
|
|
];
|
|
|
|
}
|
2020-05-16 20:11:20 +00:00
|
|
|
$this->response($response);
|
2020-05-15 20:45:31 +00:00
|
|
|
}
|
|
|
|
}
|