Skip to content

Commit

Permalink
layerClass param Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
loveorigami committed Mar 26, 2016
1 parent dbdf449 commit 82bf736
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/messages/ru/noty.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

return [
'Info' => 'Информация',
'Warning' => 'Внимание',
'Error' => 'Ошибка',
'Info' => 'Информация',
'layerClass not configurated' => 'Не установлен параметр layerClass',
'Success' => 'Выполнено',
'Warning' => 'Внимание',
];
32 changes: 19 additions & 13 deletions src/widgets/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
namespace lo\modules\noty\widgets;

use Yii;
use yii\base\InvalidConfigException;
use yii\web\View;
use yii\helpers\Json;
use yii\helpers\Html;
use yii\base\InvalidParamException;

/**
* This package comes with a Wrapper widget that can be used to regularly poll the server
Expand Down Expand Up @@ -46,17 +46,17 @@ class Wrapper extends \yii\base\Widget
/** @const type warning */
const TYPE_WARNING = 'warning';

/** @const type wrapper id */
/** @const wrapper id */
const WRAP_ID = 'noty-warap';


/** @var array $types */
public $types = [self::TYPE_INFO, self::TYPE_ERROR, self::TYPE_SUCCESS, self::TYPE_WARNING];

/** @var string $class */
/** @var string $layerClass */
public $layerClass;

/** @var array $options */
/** @var array $layerOptions */
public $layerOptions = [];

/** @var array $options */
Expand All @@ -73,9 +73,11 @@ public function init()
{
parent::init();

if (!isset($this->layerClass)) {
throw new InvalidParamException(Yii::t('noty', 'layerClass not configurated'));
}

$this->url = Yii::$app->getUrlManager()->createUrl(['noty/default/index']);

}

/**
Expand Down Expand Up @@ -116,7 +118,6 @@ public function run()
}
});
", View::POS_END);

}

/**
Expand Down Expand Up @@ -160,15 +161,11 @@ protected function getFlashes($layer)
return $this->view->registerJs(implode("\n", $result));
}

protected function loadLayer()
{
$layer = new $this->layerClass;
return $layer;
}

/**
* Get title
*/
public function getTitle($type)
{

switch ($type) {
case self::TYPE_ERROR:
$t = \Yii::t('noty', 'Error');
Expand All @@ -188,4 +185,13 @@ public function getTitle($type)

return $t;
}

/**
* load layer
*/
protected function loadLayer()
{
$layer = new $this->layerClass;
return $layer;
}
}

0 comments on commit 82bf736

Please sign in to comment.