Commit cc4307d1 by Alexander Makarov

Better Formatter error handler

parent 4a543317
...@@ -131,8 +131,13 @@ class Formatter extends \yii\base\Formatter ...@@ -131,8 +131,13 @@ class Formatter extends \yii\base\Formatter
$formatter = new IntlDateFormatter($this->locale, $this->_dateFormats[$format], IntlDateFormatter::NONE); $formatter = new IntlDateFormatter($this->locale, $this->_dateFormats[$format], IntlDateFormatter::NONE);
} else { } else {
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE); $formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE);
if ($formatter !== null) {
$formatter->setPattern($format); $formatter->setPattern($format);
} }
}
if ($formatter === null) {
throw new InvalidConfigException(intl_get_error_message());
}
return $formatter->format($value); return $formatter->format($value);
} }
...@@ -167,8 +172,13 @@ class Formatter extends \yii\base\Formatter ...@@ -167,8 +172,13 @@ class Formatter extends \yii\base\Formatter
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, $this->_dateFormats[$format]); $formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, $this->_dateFormats[$format]);
} else { } else {
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE); $formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE);
if ($formatter !== null) {
$formatter->setPattern($format); $formatter->setPattern($format);
} }
}
if ($formatter === null) {
throw new InvalidConfigException(intl_get_error_message());
}
return $formatter->format($value); return $formatter->format($value);
} }
...@@ -203,8 +213,13 @@ class Formatter extends \yii\base\Formatter ...@@ -203,8 +213,13 @@ class Formatter extends \yii\base\Formatter
$formatter = new IntlDateFormatter($this->locale, $this->_dateFormats[$format], $this->_dateFormats[$format]); $formatter = new IntlDateFormatter($this->locale, $this->_dateFormats[$format], $this->_dateFormats[$format]);
} else { } else {
$formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE); $formatter = new IntlDateFormatter($this->locale, IntlDateFormatter::NONE, IntlDateFormatter::NONE);
if ($formatter !== null) {
$formatter->setPattern($format); $formatter->setPattern($format);
} }
}
if ($formatter === null) {
throw new InvalidConfigException(intl_get_error_message());
}
return $formatter->format($value); return $formatter->format($value);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment