예제 #1
0
파일: Content.php 프로젝트: phpffcms/ffcms
 /**
  * Delete category action
  * @param int $id
  * @return string
  * @throws ForbiddenException
  * @throws \Ffcms\Core\Exception\SyntaxException
  * @throws \Ffcms\Core\Exception\NativeException
  */
 public function actionCategorydelete($id)
 {
     // check id
     if (!Obj::isLikeInt($id) || $id < 2) {
         throw new ForbiddenException();
     }
     // get object relation
     $record = ContentCategory::find($id);
     if ($record === null || $record === false) {
         throw new ForbiddenException();
     }
     // init model with object relation
     $model = new FormCategoryDelete($record);
     // check if delete is submited
     if ($model->send() && $model->validate()) {
         $model->make();
         App::$Session->getFlashBag()->add('success', __('Category is successful removed'));
         $this->response->redirect('content/categories');
     }
     // draw view
     return $this->view->render('category_delete', ['model' => $model]);
 }