Files
SmartHomePHP/modules/api/controllers/PanelController.php
Alex Solomaha 1d8d5d9896 Close #20
2017-01-20 21:00:28 +02:00

62 lines
1.1 KiB
PHP

<?php
namespace app\modules\api\controllers;
use app\modules\api\components\WebSocketAPIBridge;
use Yii;
use yii\base\NotSupportedException;
use yii\rest\Controller;
class PanelController extends Controller
{
/**
* @inheritdoc
*/
public function verbs()
{
return [
'schedule-triggers' => ['POST'],
];
}
/**
* @throws NotSupportedException
*/
public function actionIndex()
{
throw new NotSupportedException();
}
/**
* @return array|bool
*/
public function actionScheduleTriggers()
{
$api = new WebSocketAPIBridge(Yii::$app->user->identity);
$result = $api->send([
'type' => 'schedule-triggers',
]);
return [
'success' => $result,
];
}
/**
* @return array|bool
*/
public function actionUpdateItems()
{
$api = new WebSocketAPIBridge(Yii::$app->user->identity);
$result = $api->send([
'type' => 'update-items',
]);
return [
'success' => $result,
];
}
}