Whups_Query::insertBranch PHP Method

insertBranch() public method

public insertBranch ( $pathstring, $type )
    public function insertBranch($pathstring, $type)
    {
        $path = Whups_Query::stringToPath($pathstring);
        $qobj =& $this->query;
        $newbranch = array('type' => $type, 'children' => array());
        $count = count($path);
        for ($i = 0; $i < $count; $i++) {
            $qobj =& $qobj['children'][$path[$i]];
        }
        if (!isset($qobj['children']) || !is_array($qobj['children'])) {
            $qobj['children'] = array();
        }
        $qobj['children'][] = $newbranch;
        $path[] = count($qobj['children']) - 1;
        return Whups_Query::pathToString($path);
    }