コード例 #1
0
ファイル: Tree.php プロジェクト: Konafets/oelib
 /**
  * Builds the node tree from the given structure.
  *
  * @param array $treeStructure
  *        the tree structure as array, may be empty
  * @param tx_oelib_Visibility_Node $parentNode
  *        the parent node for the current key
  *
  * @return void
  */
 private function buildTreeFromArray(array $treeStructure, tx_oelib_Visibility_Node $parentNode)
 {
     foreach ($treeStructure as $nodeKey => $nodeContents) {
         /** @var tx_oelib_Visibility_Node $childNode */
         $childNode = t3lib_div::makeInstance('tx_oelib_Visibility_Node');
         $parentNode->addChild($childNode);
         if (is_array($nodeContents)) {
             $this->buildTreeFromArray($nodeContents, $childNode);
         } elseif ($nodeContents === TRUE) {
             $childNode->markAsVisible();
         }
         $this->nodes[$nodeKey] = $childNode;
     }
 }
コード例 #2
0
ファイル: NodeTest.php プロジェクト: Konafets/oelib
 /**
  * @test
  */
 public function markAsVisibleForNodeWithParentAndGrandparentMarksGrandparentNodeAsVisible()
 {
     $childNode = new tx_oelib_Visibility_Node();
     $grandChildNode = new tx_oelib_Visibility_Node();
     $childNode->setParent($this->subject);
     $grandChildNode->setParent($childNode);
     $grandChildNode->markAsVisible();
     self::assertTrue($this->subject->isVisible());
 }
コード例 #3
0
ファイル: Node.php プロジェクト: Konafets/oelib
 /**
  * Adds a child to this node.
  *
  * @param tx_oelib_Visibility_Node $child the child to add to this node
  *
  * @return void
  */
 public function addChild(tx_oelib_Visibility_Node $child)
 {
     $this->children[] = $child;
     $child->setParent($this);
 }