code/ViewableWrapper.php
protected function wrapObject($obj)
    {
        if (is_object($obj)) {
            // if it's an object, just check the type and wrap if needed
            if ($obj instanceof ViewableWrapper) {
                return $obj;
            } else {
                return new ViewableWrapper($obj);
            }
        } elseif (is_array($obj)) {
            // if it's an assoc array just wrap it, otherwise make a dataobjectset
            if (ArrayLib::is_associative($obj)) {
                return new ViewableWrapper($obj);
            } else {
                $set = new ArrayList();
        
                foreach ($obj as $i => $item) {
                    $wrap = $this->wrapObject($item);
                    $set->push($wrap);
                }
        
                return $set;
            }
        } else {
            // it's a simple type, just return it
            return $obj;
        }
    }
protected function wrapObject($obj)
    {
        if (is_object($obj)) {
            // if it's an object, just check the type and wrap if needed
            if ($obj instanceof ViewableWrapper) {
                return $obj;
            } else {
                return new ViewableWrapper($obj);
            }
        } elseif (is_array($obj)) {
            // if it's an assoc array just wrap it, otherwise make a dataobjectset
            if (ArrayLib::is_associative($obj)) {
                return new ViewableWrapper($obj);
            } else {
                $set = new ArrayList();
        
                foreach ($obj as $i => $item) {
                    $wrap = $this->wrapObject($item);
                    $set->push($wrap);
                }
        
                return $set;
            }
        } else {
            // it's a simple type, just return it
            return $obj;
        }
    }
if an object isn't already wrapped in Silverstripe's stuff,
wrap it appropriately either in a viewableWrapper or dataobject set