Skip to content

Commit

Permalink
Issue #33: Add error handling to example dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehaertl committed Jul 2, 2015
1 parent e5eb029 commit 23c32ae
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,16 @@ class LanguageDropdown extends Dropdown
{
private static $_labels;

private $_isError;

public function init()
{
$route = '/'.Yii::$app->controller->route;
$route = Yii::$app->controller->route;
$appLanguage = Yii::$app->language;
$params = $_GET;
$this->_isError = $route === Yii::$app->errroHandler->errorAction;

array_unshift($params, $route);
array_unshift($params, '/'.$route);

foreach (Yii::$app->urlManager->languages as $language) {
$isWildcard = substr($language, -2)==='-*';
Expand All @@ -320,6 +323,16 @@ class LanguageDropdown extends Dropdown
parent::init();
}

public function run()
{
// Only show this widget if we're not on the error page
if ($this->_isError) {
return '';
} else {
return parent::run();
}
}

public static function label($code)
{
if (self::$_labels===null) {
Expand Down

0 comments on commit 23c32ae

Please sign in to comment.