示例#1
0
 /**
  *
  */
 public function testRead()
 {
     $escape = function ($str) {
         return htmlspecialchars($str, ENT_COMPAT, 'UTF-8');
     };
     $data = ['type' => 'ninja', 'color' => 'black', 'font' => 'sans', 'margin' => ['left' => '15px', 'right' => 'delete-me'], 'small' => ['font' => 'monospace', 'test' => '(a < b)'], 'auto' => new DataObject(['type' => 'auto', 'value' => time()]), 'func' => function () {
         return 'func';
     }];
     $root = new Node($data, ['escape' => $escape]);
     //
     $type = $root->node('type');
     $font = $root->node('small.font');
     $small = $root->node('small');
     $color = $small->node('color', Node::BUBBLE);
     $res1 = $root->resolve('small.test');
     $res2 = $root->render('{{small.test}}');
     $res3 = $root->render('[{{small.font}}]');
     $res4 = $root->render('COLOR {{color}} MARGIN {{margin.left}} END');
     $auto = $root->node('auto.type');
     $func = $root->resolve('func');
     $doe = $root->node('small.johndoe');
     $this->assertEquals($type, 'ninja');
     $this->assertEquals($font, 'monospace');
     $this->assertEquals($color, 'black');
     $this->assertEquals($res1, '(a &lt; b)');
     $this->assertEquals($res2, '(a &lt; b)');
     $this->assertEquals($res3, '[monospace]');
     $this->assertEquals($res4, 'COLOR black MARGIN 15px END');
     $this->assertEquals($auto, 'auto');
     $this->assertEquals($func, 'func');
     $this->assertEquals($doe->exists(), false);
 }
示例#2
0
 /**
  * Renders the list of subitems (without the container [ul])
  *
  * @param Model $model
  * @param int $depth
  */
 protected function buildChildren(Model $model, $depth, $indent)
 {
     $count = 0;
     foreach ($model->node('children') as $child) {
         if (!$this->testItem($model, $depth)) {
             continue;
         }
         $count++;
         $this->buildItem($child, $depth, $indent);
     }
     return $count;
 }
示例#3
0
 /**
  * @param string $key
  * @return bool
  */
 public function __isset($key)
 {
     return $this->data->node($key, Node::BUBBLE)->exists();
 }