Esempio n. 1
0
 /**
  * @inheritdoc
  */
 public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         // Delete related Models
         $this->formData->delete();
         $this->ui->delete();
         $this->formConfirmation->delete();
         $this->formEmail->delete();
         // Delete all Charts, Submissions and Files related to this form
         // We use deleteAll for performance reason
         FormUser::deleteAll(["form_id" => $this->id]);
         FormRule::deleteAll(["form_id" => $this->id]);
         FormChart::deleteAll(["form_id" => $this->id]);
         FormSubmissionFile::deleteAll(["form_id" => $this->id]);
         FormSubmission::deleteAll(["form_id" => $this->id]);
         // Delete all Stats related to this form
         Event::deleteAll(["app_id" => $this->id]);
         StatsPerformance::deleteAll(["app_id" => $this->id]);
         StatsSubmissions::deleteAll(["app_id" => $this->id]);
         // Removes files directory (and all its content)
         // of this form (if exists)
         FileHelper::removeDirectory($this::FILES_DIRECTORY . DIRECTORY_SEPARATOR . $this->id);
         return true;
     } else {
         return false;
     }
 }