/** * @param tx_caretaker_AbstractNode $node * @param int $depth * @return array */ protected function nodeToArray($node, $depth = 1) { // show node and icon $result = array(); $uid = $node->getUid(); $title = $node->getTitle(); $hidden = $node->getHidden(); $id = $node->getCaretakerNodeId(); $testResult = $node->getTestResult(); $resultClass = 'caretaker-state-' . strtolower($testResult->getStateInfo()); $typeClass = 'caretaker-type-' . strtolower($node->getType()); $result['type'] = strtolower($node->getType()); $result['id'] = $id; $result['uid'] = $uid; $result['disabled'] = $hidden; $result['text'] = $title ? $title : '[no title]'; $result['cls'] = $resultClass . ' ' . $typeClass; $result['iconCls'] = 'icon-' . $typeClass . ($hidden ? '-hidden' : ''); if (strtolower($node->getType()) == 'instance' && $node instanceof tx_caretaker_InstanceNode) { $result['url'] = $node->getUrl(); } else { $result['url'] = false; } // show subitems of tx_caretaker_AggregatorNodes if ($node instanceof tx_caretaker_AggregatorNode) { $children = $node->getChildren(true); $result['leaf'] = count($children) == 0 ? true : false; if ($depth > 0) { $result['children'] = array(); foreach ($children as $child) { $result['children'][] = $this->nodeToArray($child, $depth - 1); } } } else { $result['leaf'] = TRUE; } return $result; }
/** * Constructor * * @param integer $uid * @param string $title * @param tx_caretaker_AbstractNode $parent * @param string $storageTable * @param string $type * @param string|boolean $hidden */ public function __construct($uid, $title, $parent, $storageTable, $type = '', $hidden = FALSE) { $this->uid = $uid; $this->title = $title; $this->parent = $parent; $this->type = $type; $this->storageTable = $storageTable; if ($parent && $parent->getHidden()) { $this->hidden = TRUE; } else { $this->hidden = (bool) $hidden; } }