public function itMayWrapAnObject() { $object = mock('stdClass'); $node = new TreeNode(); $node->setObject($object); $this->assertEqual($object, $node->getObject()); }
private function buildParentHierarchy(TreeNode $node, array &$cache_alreaydy_built_parents) { $parent_node = $node; $ancestors = $node->getObject()->getAllAncestors($this->user); foreach ($ancestors as $parent) { $previous = $parent_node; $parent_node = $this->getParentNode($parent, $cache_alreaydy_built_parents); $parent_node->addSingularChild($previous); } return $parent_node; }
/** * Makes a CardPresenterNode out of $node if $node contains an artifact * * TODO something is wrong since we return different types here * When on the left side of the planning, the top node is just * a node holding the other nodes, and we cant use an array of nodes because * there are card-actions available for it... * * @param TreeNode $node * * @return \Tracker_TreeNode_CardPresenterNode or \TreeNode */ public function apply(TreeNode $node) { $artifact = $node->getObject(); if ($artifact) { $planning_item = new Planning_Item($artifact, $this->planning, $artifact->getParent($this->user)); $presenter = new Planning_ItemPresenter($planning_item, $this->card_fields, $this->classname); $presenter_node = new Tracker_TreeNode_CardPresenterNode($node, $presenter); return $presenter_node; } return $node; }
/** * Makes a CardPresenterNode out of $node if $node contains an artifact * * TODO something is wrong since we return different types here * When on the left side of the planning, the top node is just * a node holding the other nodes, and we cant use an array of nodes because * there are card-actions available for it... * * @param TreeNode $node * * @return \Tracker_TreeNode_CardPresenterNode or \TreeNode */ public function apply(TreeNode $node) { $artifact = $node->getObject(); if ($artifact) { $parent = null; try { $parent = $artifact->getParent($this->user); } catch (Tracker_Hierarchy_MoreThanOneParentException $e) { $GLOBALS['Response']->addFeedback('error', $e->getMessage(), CODENDI_PURIFIER_LIGHT); } $planning_item = new Planning_Item($artifact, $this->planning, $parent); $presenter = new Planning_ItemPresenter($planning_item, $this->card_fields, $this->classname); $presenter_node = new Tracker_TreeNode_CardPresenterNode($node, $presenter); return $presenter_node; } return $node; }
public function __construct(TreeNode $node) { parent::__construct($node->getData(), $node->getId()); $this->setChildren($node->getChildren()); $this->setObject($node->getObject()); }