Skip to content

Commit

Permalink
In the middle of nowhere. Playing with SwitchAction
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed May 8, 2015
1 parent bcca4d3 commit 16b1be8
Showing 1 changed file with 93 additions and 5 deletions.
98 changes: 93 additions & 5 deletions controllers/DbController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

class DBController extends CrudController
{
public function behaviors () {
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
Expand All @@ -24,7 +25,91 @@ public function behaviors () {
];
}

public function actionCreate () {
public function actions()
{
return [
'delete' => [
'class' => 'hipanel\actions\SwitchAction',
'addFlash' => true,
'success' => Yii::t('app', 'DB delete task has been created successfully'),
'error' => Yii::t('app', 'Error while deleting DB'),
'POST html' => [
'perform' => true,
'success' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => ['index'],
],
'error' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => [
'view',
function ($model) {
return ['id' => $model->id];
}
],
]
],
],
'create' => [
'class' => 'hipanel\actions\SwitchAction',
'addFlash' => true,
'success' => Yii::t('app', 'DB delete task has been created successfully'),
'error' => Yii::t('app', 'Error while deleting DB'),
'GET html | GET pjax' => [
'class' => 'hipanel\actions\RenderAction',
'view' => 'create',
'params' => $this->newModel(['scenario' => 'create'])
],
'POST html' => [
'perform' => true,
'success' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => [
'view',
function ($model) {
return ['id' => $model->id];
}
],
],
'error' => [
'class' => 'hipanel\actions\RenderAction',
'url' => [
'create',
function ($model) {
return compact('model');
}
],
],
],
'POST pjax' => [
'perform' => true,
'success' => [
'class' => 'hipanel\actions\RedirectAction',
'url' => [
'view',
function ($model) {
return ['id' => $model->id];
}
],
'pjaxLocationHeader' => true,
],
'error' => [
'class' => 'hipanel\actions\RenderAction',
'url' => [
'create',
function ($model) {
return [$model->model];
}
],
'pjaxLocationHeader' => true,
],
],
],
];
}

public function actionCreate()
{
$model = $this->newModel(['scenario' => 'create']);

return $this->perform([
Expand All @@ -46,7 +131,8 @@ public function actionCreate () {

}

public function actionDelete () {
public function actionDelete()
{
return $this->perform([
'success' => [
'message' => Yii::t('app', 'DB deleting task has been created successfully'),
Expand All @@ -70,15 +156,17 @@ public function actionDelete () {
]);
}

public function actionSetPassword () {
public function actionSetPassword()
{
return $this->perform([
'result' => [ ///
'POST pjax' => ['action', ['view', function ($model) { return ['id' => $model->id]; }], 'addFlash' => true]
],
]);
}

public function actionTruncate () {
public function actionTruncate()
{
return $this->perform([
'success' => [
'message' => Yii::t('app', 'DB truncate task has been created successfully'),
Expand Down

0 comments on commit 16b1be8

Please sign in to comment.