예제 #1
0
 public function actionDelete($id)
 {
     $campaign = Campaign::findByPk($id);
     if (empty($campaign)) {
         throw new BadRequestHttpException(Yii::t('product', 'campaign_not_found'));
     }
     if ($campaign->isActivated) {
         throw new BadRequestHttpException(Yii::t('product', 'can_not_delete'));
     }
     if (Campaign::deleteAll(['_id' => new \MongoId($id)]) == false) {
         throw new ServerErrorHttpException('Failed to delete the campaign for unknown reason.');
     }
     Yii::$app->getResponse()->setStatusCode(204);
 }