| @@ 8-28 (lines=21) @@ | ||
| 5 | * @copyright Copyright © 2003-2015 Shogo |
|
| 6 | * @license http://argilla.ru/LICENSE |
|
| 7 | */ |
|
| 8 | class ImportModelValidateException extends WarningException |
|
| 9 | {
|
|
| 10 | public function __construct(CModel $model, $message = '') |
|
| 11 | {
|
|
| 12 | $fullMessage = empty($message) ? '' : $message.' .'; |
|
| 13 | $fullMessage .= 'Ошибки валидации: '.$this->clearArrayData(print_r($model->errors, true)); |
|
| 14 | //$message .= PHP_EOL.print_r($model->attributes, true); |
|
| 15 | ||
| 16 | parent::__construct($fullMessage, 500); |
|
| 17 | } |
|
| 18 | ||
| 19 | private function clearArrayData($string) |
|
| 20 | {
|
|
| 21 | $string = preg_replace('/\s+/', ' ', $string);
|
|
| 22 | $string = preg_replace('/\n?Array\s\(\s|\)/', '', $string);
|
|
| 23 | $string = preg_replace('/\s=>\s\[\d+\]/', '', $string);
|
|
| 24 | $string = preg_replace('/(\[\w+\])/', "\n\r$1", $string);
|
|
| 25 | $string = preg_replace('/\ +/', ' ', $string);
|
|
| 26 | return $string; |
|
| 27 | } |
|
| 28 | } |
|
| @@ 8-28 (lines=21) @@ | ||
| 5 | * @copyright Copyright © 2003-2015 Shogo |
|
| 6 | * @license http://argilla.ru/LICENSE |
|
| 7 | */ |
|
| 8 | class ModelValidateException extends CException |
|
| 9 | {
|
|
| 10 | public function __construct(CModel $model, $message = '') |
|
| 11 | {
|
|
| 12 | $fullMessage = empty($message) ? '' : $message.' .'; |
|
| 13 | $fullMessage .= 'Ошибки валидации: '.$this->clearArrayData(print_r($model->errors, true)); |
|
| 14 | //$message .= PHP_EOL.print_r($model->attributes, true); |
|
| 15 | ||
| 16 | parent::__construct($fullMessage, 500); |
|
| 17 | } |
|
| 18 | ||
| 19 | private function clearArrayData($string) |
|
| 20 | {
|
|
| 21 | $string = preg_replace('/\s+/', ' ', $string);
|
|
| 22 | $string = preg_replace('/\n?Array\s\(\s|\)/', '', $string);
|
|
| 23 | $string = preg_replace('/\s=>\s\[\d+\]/', '', $string);
|
|
| 24 | $string = preg_replace('/(\[\w+\])/', "\n\r$1", $string);
|
|
| 25 | $string = preg_replace('/\ +/', ' ', $string);
|
|
| 26 | return $string; |
|
| 27 | } |
|
| 28 | } |
|