models/AbstractModel.php
public static function childClass($asModel = false, $initData = [])
    {
        $data = debug_backtrace();
        $callingClassName = get_class($data[1]['object']);
        $pattern = '#^(.+\\\\)(\w+\\\\\w+)$#';
        $formName = preg_replace($pattern, '$2', get_called_class());
        $result = preg_replace($pattern, '$1'.$formName, $callingClassName);
        return $asModel ? new $result($initData) : $result;
    }
public static function childClass($asModel = false, $initData = [])
    {
        $data = debug_backtrace();
        $callingClassName = get_class($data[1]['object']);
        $pattern = '#^(.+\\\\)(\w+\\\\\w+)$#';
        $formName = preg_replace($pattern, '$2', get_called_class());
        $result = preg_replace($pattern, '$1'.$formName, $callingClassName);
        return $asModel ? new $result($initData) : $result;
    }
public static function childClass ( $ asModel = false , $ initData = [ ] ) { $ data = debug_backtrace ( ) ; $ callingClassName = get_class ( $ data [ 1 ] [ 'object' ] ) ; $ pattern = '#^(.+\\\\)(\w+\\\\\w+)$#' ; $ formName = preg_replace ( $ pattern , '$2' , get_called_class ( ) ) ; $ result = preg_replace ( $ pattern , '$1' . $ formName , $ callingClassName ) ; return $ asModel ? new $ result ( $ initData ) : $ result ; }
Gets class name for a model that inherits current modules model.
CAUTION! This works only when called from inside another module model
@param bool $asModel
@param array $initData
@return string|static
Gets class name for a model that inherits current modules model . CAUTION! This works only when called from inside another module model