public function actionBindSidebars()
 {
     $binder = new Binder();
     if ($binder->load(Yii::$app->request->post(), 'Binder')) {
         if (WidgetService::bindSidebars($binder)) {
             // Trigger Ajax Success
             return AjaxUtil::generateSuccess(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::MESSAGE_REQUEST));
         }
     }
     // Trigger Ajax Failure
     return AjaxUtil::generateFailure(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_REQUEST));
 }
 public function actionSettings($id)
 {
     // Find Model
     $model = WidgetService::findById($id);
     // Update/Render if exist
     if (isset($model)) {
         $meta = new WidgetForm($model->data);
         if ($meta->load(Yii::$app->request->post(), 'WidgetForm')) {
             if (WidgetService::update($model, $meta)) {
                 return $this->redirect(['all']);
             }
         }
         $templatesMap = TemplateService::getIdNameMap(CmsGlobal::TYPE_WIDGET);
         return $this->render('settings', ['model' => $model, 'meta' => $meta, 'templatesMap' => $templatesMap]);
     }
     // Model not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }
 public function actionDelete($id)
 {
     // Find Model
     $model = SidebarService::findById($id);
     // Delete/Render if exist
     if (isset($model)) {
         if ($model->load(Yii::$app->request->post(), 'ObjectData')) {
             if (SidebarService::delete($model)) {
                 $this->redirect(['all']);
             }
         }
         $widgets = WidgetService::getIdNameList();
         return $this->render('delete', ['model' => $model, 'widgets' => $widgets]);
     }
     // Model not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }