tao.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. class projectreleaseTao extends projectreleaseModel
  3. {
  4. /**
  5. * 处理项目发布信息,包括分支名称、版本信息等。
  6. * Process release.
  7. *
  8. * @param object $release
  9. * @param array $branchGroup
  10. * @param array $builds
  11. * @access protected
  12. * @return void
  13. */
  14. protected function processRelease($release, $branchGroup, $builds)
  15. {
  16. $release->project = trim($release->project, ',');
  17. $release->branch = trim($release->branch, ',');
  18. $release->build = trim($release->build, ',');
  19. $release->branchName = $this->getBranchName($release->product, $release->branch, $branchGroup);
  20. $release->buildInfos = array();
  21. foreach(explode(',', $release->build) as $buildID)
  22. {
  23. if(empty($buildID)) continue;
  24. if(!isset($builds[$buildID])) continue;
  25. $build = $builds[$buildID];
  26. $build->branchName = $this->getBranchName($build->product, $build->branch, $branchGroup);
  27. $release->buildInfos[$buildID] = $build;
  28. }
  29. }
  30. /**
  31. * 获取分支名称。
  32. * Get branch name.
  33. *
  34. * @param int $productID
  35. * @param string $branch
  36. * @param array $branchGroup
  37. * @access private
  38. * @return string
  39. */
  40. private function getBranchName($productID, $branch, $branchGroup)
  41. {
  42. $branchName = '';
  43. if(!isset($branchGroup[$productID])) return $branchName;
  44. $branches = $branchGroup[$productID];
  45. foreach(explode(',', $branch) as $branchID)
  46. {
  47. if($branchID == '') continue;
  48. $branchName .= zget($branches, $branchID, '');
  49. $branchName .= ',';
  50. }
  51. return trim($branchName, ',');
  52. }
  53. }