本文整理匯總了PHP中Branch::getParentBranch方法的典型用法代碼示例。如果您正苦於以下問題:PHP Branch::getParentBranch方法的具體用法?PHP Branch::getParentBranch怎麽用?PHP Branch::getParentBranch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Branch
的用法示例。
在下文中一共展示了Branch::getParentBranch方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addLeaf
/**
* Adds a leaf to the branch tree
*
* @param Branch $branch
*/
public function addLeaf(Branch $branch)
{
if (isset($this->branchMap[$branch->getUniqueId()])) {
$branchNode = $this->branchMap[$branch->getUniqueId()];
} else {
$branchNode = new BranchGraphNode($branch);
}
$branchNode->increase();
$tempBranch = $branch->getParentBranch();
while ($tempBranch) {
if (isset($this->branchMap[$tempBranch->getUniqueId()])) {
$parentBranchNode = $this->branchMap[$tempBranch->getUniqueId()];
} else {
$parentBranchNode = new BranchGraphNode($tempBranch);
$this->branchMap[$tempBranch->getUniqueId()] = $parentBranchNode;
}
$parentBranchNode->insert($branchNode);
$branchNode = $parentBranchNode;
$tempBranch = $tempBranch->getParentBranch();
if (!$tempBranch) {
$this->root = $parentBranchNode;
}
}
}
示例2: removeBranch
/**
* Removes a branch from the branch manager
*
* @param Branch $branch
*/
public function removeBranch(Branch $branch)
{
$parentBranch = $branch->getParentBranch();
$this->currentBranch = $parentBranch;
$this->level--;
}