* Add void return for buildCreateForm, unifies judge code to a new method.

This commit is contained in:
songchenxuan
2023-05-15 09:48:34 +08:00
committed by 刘刚
parent 6ae63123f6
commit 754e75f24d
2 changed files with 24 additions and 9 deletions
+2
View File
@@ -236,6 +236,8 @@ class bug extends control
$fields = array('productID' => $productID, 'branch' => $branch, 'title' => ($from == 'sonarqube' ? $_COOKIE['sonarqubeIssue'] : ''), 'assignedTo' => (isset($currentProduct->QD) ? $currentProduct->QD : ''));
$bug = $this->bugZen->initBug($fields);
$bug = $this->bugZen->setOptionMenu($bug, $currentProduct);
/* 处理复制bug,从用例、测试单、日志转bug。 */
/* Handle copy bug, bug from case, testtask, todo. */
$bug = $this->bugZen->extractObjectFromExtras($bug, $output);
+22 -9
View File
@@ -715,6 +715,26 @@ class bugZen extends bug
return $bug;
}
/**
* 获取模块下拉菜单,如果是空的,则返回到模块维护页面。
* Get moduleOptionMenu, if moduleOptionMenu is empty, return tree-browse.
*
* @param object $bug
* @param object $currentProduct
* @return object
*/
protected function setOptionMenu(object $bug, object $currentProduct): object
{
$bug = $this->getBranches4Create($bug, $currentProduct);
$moduleOptionMenu = $this->tree->getOptionMenu($bug->productID, 'bug', 0, ($bug->branch === 'all' or !isset($bug->branches[$bug->branch])) ? 0 : $bug->branch);
if(empty($moduleOptionMenu)) return print(js::locate(helper::createLink('tree', 'browse', "productID={$bug->productID}&view=story")));
$this->view->moduleOptionMenu = $moduleOptionMenu;
return $bug;
}
/**
* 解析extras,如果bug来源于某个对象 (bug, case, testtask, todo) ,使用对象的一些属性对bug赋值。
* Extract extras, if bug come from an object(bug, case, testtask, todo), get some value from object.
@@ -783,16 +803,10 @@ class bugZen extends bug
* @param string $from
* @return void
*/
protected function buildCreateForm(object $bug, array $output, string $from)
protected function buildCreateForm(object $bug, array $output, string $from): void
{
extract($output);
$currentProduct = $this->product->getById($bug->productID);
/* 获取分支,如果模块菜单是空的,则返回到模块维护页面。 */
/* Get branches, if moduleOptionMenu is empty, return. */
$bug = $this->getBranches4Create($bug, $currentProduct);
$moduleOptionMenu = $this->tree->getOptionMenu($bug->productID, 'bug', 0, ($bug->branch === 'all' or !isset($bug->branches[$bug->branch])) ? 0 : $bug->branch);
if(empty($moduleOptionMenu)) return print(js::locate(helper::createLink('tree', 'browse', "productID={$bug->productID}&view=story")));
$currentProduct = $this->product->getByID($bug->productID);
/* 获得版本下拉和需求下拉列表。 */
/* Get builds and stroies. */
@@ -822,7 +836,6 @@ class bugZen extends bug
$this->view->productMembers = $this->getProductMembers4Create($bug);
$this->view->gobackLink = (isset($output['from']) and $output['from'] == 'global') ? $this->createLink('bug', 'browse', "productID=$bug->productID") : '';
$this->view->productName = isset($this->products[$bug->productID]) ? $this->products[$bug->productID] : '';
$this->view->moduleOptionMenu = $moduleOptionMenu;
$this->view->projectExecutionPairs = $this->loadModel('project')->getProjectExecutionPairs();
$this->view->releasedBuilds = $this->loadModel('release')->getReleasedBuilds($bug->productID, $bug->branch);
$this->view->resultFiles = (!empty($resultID) and !empty($stepIdList)) ? $this->loadModel('file')->getByObject('stepResult', $resultID, str_replace('_', ',', $stepIdList)) : array();