Example #1
0
 /**
  * Deletes an existing Url model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     try {
         $this->findModel($id)->delete();
     } catch (yii\db\IntegrityException $e) {
         $page = Page::findOne(['url' => $id]);
         return $this->render('integrityException', ['exep' => $e, 'page' => $page]);
     }
     return $this->redirect(['index']);
 }
Example #2
0
 public function actionIndex($hrurl)
 {
     $url = Url::find()->byUrl($hrurl);
     if (!$url) {
         throw new NotFoundHttpException();
     }
     $model = Page::findOne(['url' => $url->id]);
     if (!$model) {
         throw new NotFoundHttpException();
     }
     return $this->render('index', ['hrurl' => $hrurl, 'url' => $url, 'model' => $model]);
 }
Example #3
0
 /**
  * Finds the Page model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Page the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Page::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }