private function buildNodeTree(SdlTag $node) { $tag = strtolower($node->getName()); $attr = ""; foreach ($node->getAttributes() as $name => $value) { $attr .= " {$name}=\"{$value}\""; } $out = ""; if ($node->hasChildren()) { if ($tag) { $out .= "<{$tag}{$attr}>"; } foreach ($node->getChildren() as $child) { $out .= $this->buildNodeTree($child); } if ($tag) { $out .= "</{$tag}>"; } } else { if (count($node) > 0) { if (!$tag) { $out .= $node[0]; } else { $out .= "<{$tag}{$attr}>" . $node[0] . "</{$tag}>"; } } else { $out .= "<{$tag}{$attr}>"; } } return $out; }
public function applySdlTag(\Cherry\Data\Ddl\SdlTag $node) { if ($node->getName() == 'table') { if ($node->getValue() != $this->name) { \App::app()->warn("Not applying SDL node to table as names differ: " . $node->getValue()); return false; } $cur = $this->getSdlTag(); foreach ($node->getChildren('column') as $col) { $curcol = $cur->getChild('column', $col->getValue()); // Check if the node if ($curcol == null || $curcol != $col) { echo "Column " . $col->getName() . " needs creating/applying!\n"; } } } }
public function testNumericValueLists() { $sdl = "root { 1 2 3 4 5 6 }"; $test = new SdlTag("root"); $test->loadString($sdl); $this->assertEquals(1, count($test->getChildren())); }