Esempio n. 1
0
 public function actionReorder($id)
 {
     if (Yii::$app->request->getIsAjax()) {
         $section = Section::findOne(['id' => $id]);
         $section->reorder(Yii::$app->request->post());
     }
 }
Esempio n. 2
0
 public function parseRequest($manager, $request)
 {
     /* @var Section $section */
     $pathInfo = $request->getPathInfo();
     if (($pos = strpos($pathInfo, '-')) === false && is_numeric($pathInfo)) {
         $section = Section::find()->where('id = :id', array(':id' => $pathInfo))->andWhere('slug = "" OR slug IS NULL')->one();
     } elseif ($pos !== false && is_numeric($id = substr($pathInfo, 0, $pos))) {
         $section = Section::findOne(['id' => $id, 'slug' => substr($pathInfo, $pos + 1)]);
     }
     if (isset($section)) {
         return ['section/view', ['id' => $section->id, 'slug' => $section->slug]];
     }
     return false;
 }
Esempio n. 3
0
 /**
  * Finds the Section model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Section the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Section::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }