ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
LSTOCBuilder.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
7 
11 class LSTOCBuilder implements TOCBuilder
12 {
16  protected $structure;
17 
21  protected $parent;
22 
26  protected $command;
27 
31  public function __construct($parent, string $command, string $label = '', int $parameter = null, $state = null)
32  {
33  $this->structure = [
34  'label' => $label,
35  'command' => $command,
36  'parameter' => $parameter,
37  'state' => $state,
38  'childs' => []
39  ];
40  $this->parent = $parent;
41  $this->command = $command;
42  }
43 
44  public function toJSON() : string
45  {
46  return json_encode($this->structure);
47  }
48 
52  public function end()
53  {
54  $this->parent->structure['childs'][] = $this->structure;
55  return $this->parent;
56  }
57 
61  public function node($label, int $parameter = null, $lp = null) : TOCBuilder
62  {
63  //build node
64  $toc = new LSTOCBuilder($this, $this->command, $label, $parameter, $lp);
65  return $toc;
66  }
67 
71  public function item(string $label, int $parameter, $state = null) : TOCBuilder
72  {
73  $item = [
74  'label' => $label,
75  'command' => $this->command,
76  'parameter' => $parameter,
77  'state' => $state
78  ];
79  $this->structure['childs'][] = $item;
80  return $this;
81  }
82 }
end()
Finish building the TOC.ControlBuilder|TOCBuilder depending on the nesting level. ...
Build a nested table of contents for the view.
Definition: TOCBuilder.php:11
__construct($parent, string $command, string $label='', int $parameter=null, $state=null)
LSControlBuilder|LSTOCBuilder $parent.
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
Class LSTOCBuilder.
item(string $label, int $parameter, $state=null)
Build an entry in the TOC.The parameter will be appended to the command when updating the state...
node($label, int $parameter=null, $lp=null)
Build a sub tree in the TOC.If a parameter is provided, the node in the TOC can be accessed itself...