Beispiel #1
0
 /**
  * Returns the node in an array representation that can be used for serialization
  *
  * @param bool $addChildNodes
  * @return array
  */
 public function toArray($addChildNodes = true)
 {
     $arrayRepresentation = array('serializeClassName' => get_class($this), 'id' => $this->id);
     if ($this->parentNode !== null) {
         $arrayRepresentation['parentNode'] = $this->parentNode->toArray(false);
     } else {
         $arrayRepresentation['parentNode'] = '';
     }
     if ($this->hasChildNodes() && $addChildNodes) {
         $arrayRepresentation['childNodes'] = $this->childNodes->toArray();
     } else {
         $arrayRepresentation['childNodes'] = '';
     }
     return $arrayRepresentation;
 }
 /**
  * Returns the collection in an array representation for e.g. serialization
  *
  * @return array
  */
 public function toArray()
 {
     $arrayRepresentation = parent::toArray();
     unset($arrayRepresentation['serializeClassName']);
     return $arrayRepresentation;
 }
Beispiel #3
0
 /**
  * Adds a node to the internal list in a sorted approach
  *
  * @param \TYPO3\CMS\Backend\Tree\TreeNode $node
  * @return void
  */
 public function append($node)
 {
     parent::append($node);
     $this->asort();
     $this->normalize();
 }
 /**
  * @test
  */
 public function getChildrenOfLevelMaximumSetToTwoWorks()
 {
     $expectedStorage = new TreeNodeCollection();
     $expectedFirstLevelTreeNode = new TreeNode();
     $expectedFirstLevelTreeNode->setId(1);
     $expectedSecondLevelTreeNode = new TreeNode();
     $expectedSecondLevelTreeNode->setId(2);
     $expectedStorageOfSecondLevelChildren = new TreeNodeCollection();
     $expectedStorageOfSecondLevelChildren->append($expectedSecondLevelTreeNode);
     $expectedFirstLevelTreeNode->setChildNodes($expectedStorageOfSecondLevelChildren);
     $expectedStorage->append($expectedFirstLevelTreeNode);
     $this->initializeSubjectMock(array('getRelatedRecords', 'getRootUid'));
     $this->subject->_set('levelMaximum', 2);
     $this->subject->expects($this->at(0))->method('getRelatedRecords')->will($this->returnValue(array(1)));
     $this->subject->expects($this->at(1))->method('getRelatedRecords')->will($this->returnValue(array(2)));
     $storage = $this->subject->_call('getChildrenOf', $this->treeData, 1);
     $this->assertEquals($expectedStorage, $storage);
 }
 /**
  * Adds a node to the internal list in a sorted approach
  *
  * @param \TYPO3\CMS\Backend\Tree\TreeNode $node
  * @return void
  */
 public function append(\TYPO3\CMS\Backend\Tree\TreeNode $node)
 {
     parent::append($node);
     $this->asort();
     $this->normalize();
 }