ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\StudyProgramme\Assignment\Node Class Reference
+ Inheritance diagram for ILIAS\StudyProgramme\Assignment\Node:
+ Collaboration diagram for ILIAS\StudyProgramme\Assignment\Node:

Public Member Functions

 __construct ($id)
 
 setSubnodes (array $subnodes)
 
 withContainer (Node $node)
 this is only used internally - do not use apart from constructing the tree! More...
 
 withSubnode ($node)
 
 getSubnodes ()
 
 getSubnode (string $id)
 
 getPath ()
 
 findSubnodePath (string $id, ?Node $node=null)
 
 getId ()
 

Protected Member Functions

 getContainer ()
 

Protected Attributes

array $subnodes = []
 
Node $container = null
 
string $id
 
int $current_points = 0
 

Detailed Description

Definition at line 23 of file Node.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\StudyProgramme\Assignment\Node::__construct (   $id)

Definition at line 32 of file Node.php.

33 {
34 $this->id = $id;
35 }

References ILIAS\StudyProgramme\Assignment\Node\$id.

Member Function Documentation

◆ findSubnodePath()

ILIAS\StudyProgramme\Assignment\Node::findSubnodePath ( string  $id,
?Node  $node = null 
)

Definition at line 89 of file Node.php.

89 : ?array
90 {
91 if (!$node) {
92 $node = $this;
93 }
94 if ($node->getId() == $id) {
95 return $node->getPath();
96 }
97 foreach ($node->getSubnodes() as $subnode) {
98 $result = $this->findSubnodePath($id, $subnode);
99 if ($result) {
100 return $result;
101 }
102 }
103
104 return null;
105 }
findSubnodePath(string $id, ?Node $node=null)
Definition: Node.php:89

References ILIAS\StudyProgramme\Assignment\Node\$id, and ILIAS\StudyProgramme\Assignment\Node\findSubnodePath().

Referenced by ILIAS\StudyProgramme\Assignment\Node\findSubnodePath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContainer()

ILIAS\StudyProgramme\Assignment\Node::getContainer ( )
protected

◆ getId()

ILIAS\StudyProgramme\Assignment\Node::getId ( )

◆ getPath()

ILIAS\StudyProgramme\Assignment\Node::getPath ( )

Definition at line 79 of file Node.php.

79 : array
80 {
81 $ret = [$this->getId()];
82 $node = $this;
83 while ($node = $node->getContainer()) {
84 $ret[] = $node->getId();
85 }
86 return array_reverse($ret);
87 }

References ILIAS\StudyProgramme\Assignment\Node\getId().

Referenced by updatePlanFromRepository().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSubnode()

ILIAS\StudyProgramme\Assignment\Node::getSubnode ( string  $id)

Definition at line 74 of file Node.php.

74 : ?Node
75 {
76 return $this->subnodes[$id];
77 }

References ILIAS\StudyProgramme\Assignment\Node\$id.

◆ getSubnodes()

ILIAS\StudyProgramme\Assignment\Node::getSubnodes ( )

Definition at line 69 of file Node.php.

69 : array
70 {
71 return array_values($this->subnodes);
72 }

Referenced by ilStudyProgrammeUserTable\completionByToCollection(), and updatePlanFromRepository().

+ Here is the caller graph for this function:

◆ setSubnodes()

ILIAS\StudyProgramme\Assignment\Node::setSubnodes ( array  $subnodes)

Definition at line 37 of file Node.php.

38 {
39 if ($this->subnodes !== []) {
40 throw new \Exception("Use 'setSubnodes' during construction only", 1);
41 }
42 foreach ($subnodes as $subnode) {
43 $this->subnodes[$subnode->getId()] = $subnode->withContainer($this);
44 }
45 return $this;
46 }

References ILIAS\StudyProgramme\Assignment\Node\$subnodes.

◆ withContainer()

ILIAS\StudyProgramme\Assignment\Node::withContainer ( Node  $node)

this is only used internally - do not use apart from constructing the tree!

Definition at line 51 of file Node.php.

51 : self
52 {
53 $this->container = $node;
54 return $this;
55 }

◆ withSubnode()

ILIAS\StudyProgramme\Assignment\Node::withSubnode (   $node)

Definition at line 62 of file Node.php.

63 {
64 $clone = clone $this;
65 $clone->subnodes[$node->getId()] = $node->withContainer($this);
66 return $clone;
67 }

Field Documentation

◆ $container

Node ILIAS\StudyProgramme\Assignment\Node::$container = null
protected

Definition at line 26 of file Node.php.

Referenced by ILIAS\StudyProgramme\Assignment\Node\getContainer().

◆ $current_points

int ILIAS\StudyProgramme\Assignment\Node::$current_points = 0
protected

Definition at line 30 of file Node.php.

◆ $id

◆ $subnodes

array ILIAS\StudyProgramme\Assignment\Node::$subnodes = []
protected

Definition at line 25 of file Node.php.

Referenced by ILIAS\StudyProgramme\Assignment\Node\setSubnodes().


The documentation for this class was generated from the following file: