Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 73 |
| EventSpanController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 7 |
156.00 | |
0.00% |
0 / 73 |
| behaviors | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 24 |
|||
| actionIndex | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 8 |
|||
| actionView | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 5 |
|||
| actionCreate | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 11 |
|||
| actionUpdate | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 12 |
|||
| actionDelete | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 6 |
|||
| findModel | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
| <?php | |
| namespace backend\controllers; | |
| use Yii; | |
| use common\models\EventSpan; | |
| use yii\data\ActiveDataProvider; | |
| use yii\web\Controller; | |
| use yii\web\NotFoundHttpException; | |
| use yii\filters\AccessControl; | |
| use yii\filters\VerbFilter; | |
| /** | |
| * EventSpanController implements the CRUD actions for EventSpan model. | |
| */ | |
| class EventSpanController extends Controller | |
| { | |
| public function behaviors() | |
| { | |
| return [ | |
| 'access' => [ | |
| 'class' => AccessControl::className(), | |
| 'rules' => [ | |
| [ | |
| 'actions' => ['view', 'update', 'delete'], | |
| 'allow' => true, | |
| 'roles' => ['admin'], | |
| ], | |
| [ | |
| 'actions' => ['index', 'create'], | |
| 'allow' => false, | |
| ], | |
| ], | |
| ], | |
| 'verbs' => [ | |
| 'class' => VerbFilter::className(), | |
| 'actions' => [ | |
| 'delete' => ['post'], | |
| ], | |
| ], | |
| ]; | |
| } | |
| /** | |
| * Lists all EventSpan models. | |
| * @return mixed | |
| */ | |
| public function actionIndex() | |
| { | |
| $dataProvider = new ActiveDataProvider([ | |
| 'query' => EventSpan::find(), | |
| ]); | |
| return $this->render('index', [ | |
| 'dataProvider' => $dataProvider, | |
| ]); | |
| } | |
| /** | |
| * Displays a single EventSpan model. | |
| * @param string $id | |
| * @return mixed | |
| */ | |
| public function actionView($id) | |
| { | |
| return $this->render('/event/view-span', [ | |
| 'model' => $this->findModel($id), | |
| ]); | |
| } | |
| /** | |
| * Creates a new EventSpan model. | |
| * If creation is successful, the browser will be redirected to the 'view' page. | |
| * @return mixed | |
| */ | |
| public function actionCreate() | |
| { | |
| $model = new EventSpan(); | |
| if ($model->load(Yii::$app->request->post())){ | |
| if ($model->save()) { | |
| return $this->redirect(['view', 'id' => $model->id]); | |
| } | |
| } | |
| return $this->render('create', [ | |
| 'model' => $model, | |
| ]); | |
| } | |
| /** | |
| * Updates an existing EventSpan model. | |
| * If update is successful, the browser will be redirected to the 'view' page. | |
| * @param string $id | |
| * @return mixed | |
| */ | |
| public function actionUpdate($id) | |
| { | |
| $model = $this->findModel($id); | |
| $eventModel = $model->event; | |
| if ($model->load(Yii::$app->request->post())){ | |
| if ($model->save()) { | |
| // return $this->redirect(['view', 'id' => $model->id]); | |
| return $this->redirect(['event/view', 'id' => $eventModel->id]); | |
| } | |
| } | |
| return $this->render('/event/update-span', [ | |
| 'model' => $model, | |
| ]); | |
| } | |
| /** | |
| * Deletes an existing EventSpan model. | |
| * If deletion is successful, the browser will be redirected to the 'index' page. | |
| * @param string $id | |
| * @return mixed | |
| */ | |
| public function actionDelete($id) | |
| { | |
| $model = $this->findModel($id); | |
| $eventModel = $model->event; | |
| $model->delete(); | |
| // return $this->redirect(['index']); | |
| return $this->redirect(['event/view', 'id' => $eventModel->id]); | |
| } | |
| /** | |
| * Finds the EventSpan model based on its primary key value. | |
| * If the model is not found, a 404 HTTP exception will be thrown. | |
| * @param string $id | |
| * @return EventSpan the loaded model | |
| * @throws NotFoundHttpException if the model cannot be found | |
| */ | |
| protected function findModel($id) | |
| { | |
| if (($model = EventSpan::findOne($id)) !== null) { | |
| return $model; | |
| } else { | |
| throw new NotFoundHttpException('The requested page does not exist.'); | |
| } | |
| } | |
| } |