/**
  * Deletes a block.
  *
  * @return int $id an id of a block to delete.
  * @throws InvalidCallException if id in $_POST does not match the provided id. 
  */
 public function actionDelete($id)
 {
     $templateId = $_POST['id'];
     if ($templateId != $id) {
         throw new InvalidCallException("Invalid form submitted. Template with id: '{$id}' not deleted.");
     }
     $model = TemplateEditor::getModel($id);
     if ($model->is_default) {
         Yii::$app->getSession()->setFlash('info', Yii::t('cms', 'Cannot delete the default template.'));
     } elseif ($model->delete()) {
         Yii::$app->getSession()->setFlash('success', Yii::t('cms', 'Template deleted.'));
     } else {
         Yii::$app->getSession()->setFlash('error', Yii::t('cms', 'Template "{title}" could not be deleted.', ['title' => $model->title]));
     }
     return $this->redirect(['index']);
 }