Blame view

backend/components/base/BaseActiveRecord.php 984 Bytes
693c46cb   Mihail   add base classes ...
1
2
3
4
5
6
7
8
9
10
11
  <?php
  /**
   * Created by PhpStorm.
   * User: Cibermag
   * Date: 31.08.2015
   * Time: 10:02
   */
  
  namespace backend\components\base;
  
  
13ffaf8e   Mihail   add error handler...
12
  use common\components\exceptions\OrdinaryActiveRecordException;
4f3f27e8   Mihail   temp commit - tes...
13
14
15
  
  class BaseActiveRecord extends \yii\db\ActiveRecord {
  
13ffaf8e   Mihail   add error handler...
16
17
18
19
20
      /**
       * @param int $row
       * @throws OrdinaryActiveRecordException
       * выбрасывает специальное исключения, наполняя сообщение с массива ошибок модели (после попытки валидации)
       */
0716cf79   Mihail   fixed testing iss...
21
      public  function throwStringErrorException($row = 0){
4f3f27e8   Mihail   temp commit - tes...
22
          $errors_str = '';
0716cf79   Mihail   fixed testing iss...
23
24
25
          if ($row != 0) {
              $errors_str = "Ошибка в строке {$row} ";
          }
4f3f27e8   Mihail   temp commit - tes...
26
27
28
          foreach ($this->getErrors() as $error) {
              $errors_str .= implode( array_values($error) );
          }
13ffaf8e   Mihail   add error handler...
29
30
31
          $ex = new OrdinaryActiveRecordException( $errors_str );
          $ex->active_record_name = static::formName();
          throw $ex;
4f3f27e8   Mihail   temp commit - tes...
32
33
34
      }
  
  }