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 testNamespacesWithName() { $test = new SdlTag("foo:test"); $this->assertEquals("test", $test->getName()); $this->assertEquals("foo", $test->getNamespace()); $this->assertEquals("foo:test", $test->getNameNs()); $test->setNamespace("bar"); $this->assertEquals("bar", $test->getNamespace()); $this->assertEquals("bar:test", $test->getNameNs()); $test->setName("arf"); $this->assertEquals("bar", $test->getNamespace()); $this->assertEquals("bar:arf", $test->getNameNs()); $test->setNamespace(null); $this->assertEquals(null, $test->getNamespace()); $this->assertEquals(":arf", $test->getNameNs()); }