src/Models/BitrixModel.php
protected static function internalCreate($fields)
    {
        $model = new static(null, $fields);
        
        if ($model->onBeforeSave() === false || $model->onBeforeCreate() === false) {
            return false;
        }

        $bxObject = static::instantiateObject();
        $id = static::internalDirectCreate($bxObject, $model->fields);
        $model->setId($id);
        
        $result = $id ? true : false;

        $model->setEventErrorsOnFail($result, $bxObject);
        $model->onAfterCreate($result);
        $model->onAfterSave($result);
        $model->resetEventErrors();
        $model->throwExceptionOnFail($result, $bxObject);

        return $model;
    }
protected static function internalCreate($fields)
    {
        $model = new static(null, $fields);
        
        if ($model->onBeforeSave() === false || $model->onBeforeCreate() === false) {
            return false;
        }

        $bxObject = static::instantiateObject();
        $id = static::internalDirectCreate($bxObject, $model->fields);
        $model->setId($id);
        
        $result = $id ? true : false;

        $model->setEventErrorsOnFail($result, $bxObject);
        $model->onAfterCreate($result);
        $model->onAfterSave($result);
        $model->resetEventErrors();
        $model->throwExceptionOnFail($result, $bxObject);

        return $model;
    }
protected static function internalCreate ( $ fields ) { $ model = new static ( null , $ fields ) ; if ( $ model -> onBeforeSave ( ) === false || $ model -> onBeforeCreate ( ) === false ) { return false ; } $ bxObject = static :: instantiateObject ( ) ; $ id = static :: internalDirectCreate ( $ bxObject , $ model -> fields ) ; $ model -> setId ( $ id ) ; $ result = $ id ? true : false ; $ model -> setEventErrorsOnFail ( $ result , $ bxObject ) ; $ model -> onAfterCreate ( $ result ) ; $ model -> onAfterSave ( $ result ) ; $ model -> resetEventErrors ( ) ; $ model -> throwExceptionOnFail ( $ result , $ bxObject ) ; return $ model ; }
Internal part of create to avoid problems with static and inheritance

@param $fields

@throws ExceptionFromBitrix

@return static|bool
Internal part of create to avoid problems with static and inheritance