Exemplo n.º 1
0
 /**
  * Deletes a model
  *
  * @param $id
  * @throws ForbiddenHttpException
  * @throws ServerErrorHttpException
  * @throws \Exception
  */
 public function actionDelete($id)
 {
     /** @var Video $videoModel */
     $videoModel = $this->findModel($id);
     $this->checkAccess($this->action->id, $videoModel);
     // remove all related files
     $paths = $videoModel->getPaths();
     FileHelper::removeFiles($paths);
     // remove model
     if ($videoModel->delete() === false) {
         throw new ServerErrorHttpException('Failed to delete the object for unknown reason.');
     }
     Yii::$app->getResponse()->setStatusCode(204);
 }