public function add_path($path, $grouped = false) { if ($grouped) { // Check there is no parent in the branch being grouped if ($found = $this->grouped_parent_exists($path)) { $a = new stdclass(); $a->path = $path; $a->parent = $found; throw new progressive_parser_exception('xml_grouped_parent_found', $a); } // Check there is no child in the branch being grouped if ($found = $this->grouped_child_exists($path)) { $a = new stdclass(); $a->path = $path; $a->child = $found; throw new progressive_parser_exception('xml_grouped_child_found', $a); } $this->groupedpaths[] = $path; } parent::add_path($path); }
public function add_path($path, $grouped = false) { if ($grouped) { // Check there is no parent in the branch being grouped if ($found = $this->grouped_parent_exists($path)) { $a = new stdclass(); $a->path = $path; $a->parent = $found; throw new progressive_parser_exception('xml_grouped_parent_found', $a); } // Check there is no child in the branch being grouped if ($found = $this->grouped_child_exists($path)) { $a = new stdclass(); $a->path = $path; $a->child = $found; throw new progressive_parser_exception('xml_grouped_child_found', $a); } $this->groupedpaths[$path] = true; // We check earlier in the function if there is a parent that is above the path // to be added so we can be sure no parent exists in the tree. $patharray = explode('/', $path); $currentpos =& $this->groupedparentprefixtree; foreach ($patharray as $item) { if (!isset($currentpos[$item])) { $currentpos[$item] = array(); } // Update the current array position using a reference to allow in-place updates to the array. $currentpos =& $currentpos[$item]; } } parent::add_path($path); }