public function loadConfig() { $cfg = PathResolver::getInstance()->getPath("{APP}/config/application.sdl"); if (file_exists($cfg)) { $this->debug("WebApplication: Reading %s", $cfg); $config = new SdlTag("root"); $config->loadString(file_get_contents($cfg)); $this->config = $config; } else { $this->debug("WebApplication: Could not find %s", $cfg); } }
public function applyTableSdlString($string) { $root = new SdlTag("root"); $root->loadString($string); return $this->applyTableSdl($root->getChild(0)); }
use Cherry\Util\Timer; // Create a new root node, we need this. $root = new SdlTag("cyanogenmod"); $root->setComment("These are the latest three CyanogenMod versions with some info"); // You can create nodes and set attributes manually $cm9 = new SdlTag("version", "9"); $cm9->multiuser = false; $cm9->android = "4.0.x"; $cm9->setComment("Based on AOSP 4.0.x"); $root->addChild($cm9); // Or provide them to the constructor $cm10 = new SdlTag("version", "10", ['multiuser' => false, 'android' => "4.1.x"]); $cm10->setComment("Based on AOSP 4.1.x"); $root->addChild($cm10); // Comments can also go as the 5th argument $cm101 = new SdlTag("version", "10.1", ['multiuser' => true, 'android' => "4.2.x", 'note' => "New and hot!"], null, "Based on AOSP 4.2.x"); $root->addChild($cm101); // And the data can be serialized to SDL $sdl = $root->encode(); echo $sdl; // Read it back out again $test = new SdlTag("root"); $test->loadString($sdl); // Print some info about the various versions. foreach ($test->getChild("cyanogenmod")->getChildren() as $child) { echo "CM{$child[0]}: Based on Android AOSP {$child->android}."; if ($child->multiuser) { echo " Multiple user-profiles supported."; } echo "\n"; }
public function testAttributes() { $test = new SdlTag("root"); $test->setAttribute("name", "bob"); $this->assertEquals("bob", $test->name); $test->name = "joe"; $this->assertEquals("joe", $test->name); unset($test->name); $this->assertEquals(null, $test->name); $test->loadString("pet name=\"bobo\" type=\"dog\" alive=true age=14"); $this->assertEquals("dog", $test->getChild("pet")->type, "String ttribute don't match parsed value"); $this->assertEquals(true, $test->getChild("pet")->alive, "Bool attribute don't match parsed value"); $this->assertEquals(14, $test->getChild("pet")->age, "Numeric attribute don't match parsed value"); $this->assertEquals("bobo", $test->getChild("pet")->name, "String attribute don't match parsed value"); $attr = $test->getChild("pet")->getAttributes(); $match = ['name' => 'bobo', 'type' => 'dog', 'age' => 14, 'alive' => true]; $this->assertEquals($match, $attr, "Unexpected attribute set returned"); }