portal.mkgtu.ru/common/components/AfterValidateHandler/LoggingAfterValidateHandler...

31 lines
923 B
PHP
Raw Normal View History

2024-03-28 09:51:45 +03:00
<?php
namespace common\components\AfterValidateHandler;
use common\components\AfterValidateHandler\interfaces\IAfterValidateHandler;
class LoggingAfterValidateHandler extends BaseAfterValidateHandler
{
public function invoke(): IAfterValidateHandler
{
if(!$this->isModelValid()) {
$value = \Yii::$app->configurationManager->getOrCreateDebuggingSoapModel()->model_validation_debugging_enable;
if($value) {
$modelClass = get_class($this->getModel());
$text = "Произошли ошибки в время валидации модели {$modelClass}\n\nДанные модели:\n" . print_r($this->getModel()->attributes, true) ."\n\nОшибки:\n" . print_r($this->getModel()->errors, true);
\Yii::error($text, "MODEL_DID_NOT_PASS_VALIDATION({$modelClass})");
}
}
return $this;
}
}