public function init()
    {
        if ($this->query === null) {
            throw new InvalidConfigException(get_class($this) . '::$query must be set.');
        }

        if ($this->formatData === null) {
            $this->formatData = function ($query, $columns) {
                $rows = [];
                foreach ($query->all() as $obj) {
                    $row = [];
                    foreach ($columns as $column) {
                    	if ($column['data']) {
		                    $value = ArrayHelper::getValue($obj, $column['data'], null);
		                    if (($pos = strrpos($column['data'], '.')) !== false) {
			                    $keys = explode('.', $column['data']);
			                    $a = $value;
			                    foreach (array_reverse($keys) as $key) {
				                    $a = [$key => $a];
			                    }
			                    $row[$keys[0]] = $a[$keys[0]];
		                    } else {
			                    $row[$column['data']] = $value;
		                    }
	                    }
                    }
                    $rows[] = $row;
                }

                return $rows;
            };
        }
    }
public function init()
    {
        if ($this->query === null) {
            throw new InvalidConfigException(get_class($this) . '::$query must be set.');
        }

        if ($this->formatData === null) {
            $this->formatData = function ($query, $columns) {
                $rows = [];
                foreach ($query->all() as $obj) {
                    $row = [];
                    foreach ($columns as $column) {
                    	if ($column['data']) {
		                    $value = ArrayHelper::getValue($obj, $column['data'], null);
		                    if (($pos = strrpos($column['data'], '.')) !== false) {
			                    $keys = explode('.', $column['data']);
			                    $a = $value;
			                    foreach (array_reverse($keys) as $key) {
				                    $a = [$key => $a];
			                    }
			                    $row[$keys[0]] = $a[$keys[0]];
		                    } else {
			                    $row[$column['data']] = $value;
		                    }
	                    }
                    }
                    $rows[] = $row;
                }

                return $rows;
            };
        }
    }
public function init ( ) { if ( $ this -> query === null ) { throw new InvalidConfigException ( get_class ( $ this ) . '::$query must be set.' ) ; } if ( $ this -> formatData === null ) { $ this -> formatData = function ( $ query , $ columns ) { $ rows = [ ] ; foreach ( $ query -> all ( ) as $ obj ) { $ row = [ ] ; foreach ( $ columns as $ column ) { if ( $ column [ 'data' ] ) { $ value = ArrayHelper :: getValue ( $ obj , $ column [ 'data' ] , null ) ; if ( ( $ pos = strrpos ( $ column [ 'data' ] , '.' ) ) !== false ) { $ keys = explode ( '.' , $ column [ 'data' ] ) ; $ a = $ value ; foreach ( array_reverse ( $ keys ) as $ key ) { $ a = [ $ key => $ a ] ; } $ row [ $ keys [ 0 ] ] = $ a [ $ keys [ 0 ] ] ; } else { $ row [ $ column [ 'data' ] ] = $ value ; } } } $ rows [ ] = $ row ; } return $ rows ; } ; } }
Check if query is configured
@throws InvalidConfigException
Check if query is configured