Skip to content

Commit

Permalink
fix returnUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
noumo committed May 11, 2015
1 parent 7e57211 commit ac36f2d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions components/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
namespace yii\easyii\components;

use Yii;
use \yii\easyii\models;
use yii\easyii\models;
use yii\helpers\Url;

class Controller extends \yii\web\Controller
{
Expand Down Expand Up @@ -47,14 +48,12 @@ public function back()

public function setReturnUrl($url = null)
{
Yii::$app->getSession()->set($this->module->id.'_return', $url ? $url : Yii::$app->request->url);
Yii::$app->getSession()->set($this->module->id.'_return', $url ? Url::to($url) : Url::current());
}

public function getReturnUrl($defaultUrl = null)
{
$url = Yii::$app->getSession()->get($this->module->id.'_return', $defaultUrl);

return $url === null ? Yii::$app->getHomeUrl() : $url;
return Yii::$app->getSession()->get($this->module->id.'_return', $defaultUrl ? Url::to($defaultUrl) : Url::to('/admin/'.$this->module->id));
}

public function formatResponse($success = '', $back = true)
Expand Down Expand Up @@ -89,4 +88,4 @@ public function formatResponse($success = '', $back = true)
return $back ? $this->back() : $this->refresh();
}
}
}
}

0 comments on commit ac36f2d

Please sign in to comment.