Extend MsgViewHelper. Add MsgViewHelper.getTypeToClass()
This commit is contained in:
@ -18,6 +18,13 @@ class MsgViewHelper extends ViewHelper
|
||||
|
||||
const WARNING = 'warning';
|
||||
|
||||
private static $type_to_class = array(
|
||||
self::SUCCESS => 'success',
|
||||
self::ERROR => 'error',
|
||||
self::INFO => 'info',
|
||||
self::WARNING => 'warning',
|
||||
);
|
||||
|
||||
protected $css_prefix = '';
|
||||
|
||||
public function msg($msg = null, $type = null)
|
||||
@ -67,8 +74,14 @@ class MsgViewHelper extends ViewHelper
|
||||
$msg = Session::get(__CLASS__, false);
|
||||
if ($msg) {
|
||||
Session::del(__CLASS__);
|
||||
return '<div class="' . $this->css_prefix . $msg['type'] . '">' . $this->view->escape($msg['message']) . '</div>';
|
||||
$type_to_class = static::getTypeToClass();
|
||||
return '<div class="' . $this->css_prefix . $type_to_class[$msg['type']] . '">' . $this->view->escape($msg['message']) . '</div>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
protected static function getTypeToClass()
|
||||
{
|
||||
return self::$type_to_class;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user