예제 #1
0
 /**
  * @throws \yii\db\StaleObjectException
  * @throws \yii\web\BadRequestHttpException
  * @throws \yii\web\NotFoundHttpException
  */
 public function run()
 {
     $model = $this->loadModel(\Yii::$app->request->get());
     $this->ensureAccess(['model' => $model]);
     if ($model->delete() === false) {
         throw new ServerErrorHttpException('Failed to delete the object for unknown reason.');
     }
     $redirectUrl = RedirectTo::build($this->redirectTo, $model);
     return $this->controller->redirect($redirectUrl);
 }
예제 #2
0
 /**
  * Bootstrap method to be called during application bootstrap stage.
  * @param Application $app the application currently running
  */
 public function bootstrap($app)
 {
     $i18n = \Yii::$app->i18n;
     if (!isset($i18n->translations[Constants::MSG_CATEGORY_NAME]) && !isset($i18n->translations['ekstazi.*'])) {
         $i18n->translations[Constants::MSG_CATEGORY_NAME] = ['class' => 'yii\\i18n\\PhpMessageSource', 'sourceLanguage' => 'en-US', 'basePath' => '@ekstazi/crud/messages', 'fileMap' => ['ekstazi/crud' => 'crud.php']];
     }
     $di = \Yii::$container;
     $di->set('ekstazi\\crud\\actions\\CreateAction', ['redirectTo' => RedirectTo::byPk(['view'])]);
     $di->set('ekstazi\\crud\\actions\\UpdateAction', ['redirectTo' => RedirectTo::byPk(['view'])]);
 }
예제 #3
0
 /**
  * @throws \yii\web\BadRequestHttpException
  * @throws \yii\web\NotFoundHttpException
  */
 public function run()
 {
     $model = $this->loadModel(\Yii::$app->request->get());
     $model->scenario = $this->scenario;
     $this->ensureAccess(['model' => $model]);
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         $redirectUrl = RedirectTo::build($this->redirectTo, $model);
         return $this->controller->redirect($redirectUrl);
     }
     return $this->controller->render($this->viewName, ['model' => $model]);
 }
예제 #4
0
 /**
  * @throws \yii\web\ForbiddenHttpException
  */
 public function run()
 {
     $this->ensureAccess();
     /** @var BaseActiveRecord $model */
     $model = new $this->modelClass(['scenario' => $this->scenario]);
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         $redirectUrl = RedirectTo::build($this->redirectTo, $model);
         return $this->controller->redirect($redirectUrl);
     }
     return $this->controller->render($this->viewName, ['model' => $model]);
 }