Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / harbormaster / controller / HarbormasterStepAddController.php
blob94471d7f0de338b7d7c4586969ff81f965fcf2ba
1 <?php
3 final class HarbormasterStepAddController
4 extends HarbormasterPlanController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
9 $plan = id(new HarbormasterBuildPlanQuery())
10 ->setViewer($viewer)
11 ->withIDs(array($request->getURIData('id')))
12 ->requireCapabilities(
13 array(
14 PhabricatorPolicyCapability::CAN_VIEW,
15 PhabricatorPolicyCapability::CAN_EDIT,
17 ->executeOne();
18 if (!$plan) {
19 return new Aphront404Response();
22 $plan_id = $plan->getID();
23 $cancel_uri = $this->getApplicationURI("plan/{$plan_id}/");
24 $plan_title = pht('Plan %d', $plan_id);
26 $all = HarbormasterBuildStepImplementation::getImplementations();
27 $all = msort($all, 'getName');
29 $all_groups = HarbormasterBuildStepGroup::getAllGroups();
30 foreach ($all as $impl) {
31 $group_key = $impl->getBuildStepGroupKey();
32 if (empty($all_groups[$group_key])) {
33 throw new Exception(
34 pht(
35 'Build step "%s" has step group key "%s", but no step group '.
36 'with that key exists.',
37 get_class($impl),
38 $group_key));
42 $groups = mgroup($all, 'getBuildStepGroupKey');
43 $boxes = array();
45 $enabled_groups = HarbormasterBuildStepGroup::getAllEnabledGroups();
46 foreach ($enabled_groups as $group) {
47 $list = id(new PHUIObjectItemListView())
48 ->setNoDataString(
49 pht('This group has no available build steps.'));
51 $steps = idx($groups, $group->getGroupKey(), array());
53 foreach ($steps as $key => $impl) {
54 if ($impl->shouldRequireAutotargeting()) {
55 unset($steps[$key]);
56 continue;
60 if (!$steps && !$group->shouldShowIfEmpty()) {
61 continue;
64 foreach ($steps as $key => $impl) {
65 $class = get_class($impl);
67 $new_uri = $this->getApplicationURI("step/new/{$plan_id}/{$class}/");
69 $item = id(new PHUIObjectItemView())
70 ->setHeader($impl->getName())
71 ->setHref($new_uri)
72 ->addAttribute($impl->getGenericDescription());
74 $list->addItem($item);
77 $box = id(new PHUIObjectBoxView())
78 ->setHeaderText($group->getGroupName())
79 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
80 ->appendChild($list);
82 $boxes[] = $box;
85 $crumbs = $this->buildApplicationCrumbs()
86 ->addTextCrumb($plan_title, $cancel_uri)
87 ->addTextCrumb(pht('Add Build Step'))
88 ->setBorder(true);
90 $title = array($plan_title, pht('Add Build Step'));
92 $header = id(new PHUIHeaderView())
93 ->setHeader(pht('Add Build Step'))
94 ->setHeaderIcon('fa-plus-square');
96 $view = id(new PHUITwoColumnView())
97 ->setHeader($header)
98 ->setFooter(array(
99 $boxes,
102 return $this->newPage()
103 ->setTitle($title)
104 ->setCrumbs($crumbs)
105 ->appendChild($view);