3 final class DrydockBlueprintEditController
extends DrydockBlueprintController
{
5 public function handleRequest(AphrontRequest
$request) {
6 $engine = id(new DrydockBlueprintEditEngine())
7 ->setController($this);
9 $id = $request->getURIData('id');
11 $this->requireApplicationCapability(
12 DrydockCreateBlueprintsCapability
::CAPABILITY
);
14 $type = $request->getStr('blueprintType');
16 $impl = DrydockBlueprintImplementation
::getNamedImplementation($type);
17 if (!$impl ||
!$impl->isEnabled()) {
18 return $this->buildTypeSelectionResponse();
22 ->addContextParameter('blueprintType', $type)
23 ->setBlueprintImplementation($impl);
26 return $engine->buildResponse();
29 private function buildTypeSelectionResponse() {
30 $request = $this->getRequest();
31 $viewer = $this->getViewer();
34 DrydockBlueprintImplementation
::getAllBlueprintImplementations();
39 if ($request->isFormPost()) {
40 $class = $request->getStr('blueprintType');
41 if (!isset($implementations[$class])) {
42 $e_blueprint = pht('Required');
43 $errors[] = pht('You must choose a blueprint type.');
47 $control = id(new AphrontFormRadioButtonControl())
48 ->setName('blueprintType')
49 ->setLabel(pht('Blueprint Type'))
50 ->setError($e_blueprint);
52 foreach ($implementations as $implementation_name => $implementation) {
53 $disabled = !$implementation->isEnabled();
55 $impl_icon = $implementation->getBlueprintIcon();
56 $impl_name = $implementation->getBlueprintName();
58 $impl_icon = id(new PHUIIconView())
59 ->setIcon($impl_icon, 'lightgreytext');
63 array($impl_icon, ' ', $impl_name),
65 pht('Provides: %s', $implementation->getType()),
68 $implementation->getDescription(),
70 $disabled ?
'disabled' : null,
74 $title = pht('Create New Blueprint');
75 $crumbs = $this->buildApplicationCrumbs();
76 $crumbs->addTextCrumb(pht('New Blueprint'));
77 $crumbs->setBorder(true);
79 $form = id(new AphrontFormView())
81 ->appendChild($control)
83 id(new AphrontFormSubmitControl())
84 ->addCancelButton($this->getApplicationURI('blueprint/'))
85 ->setValue(pht('Continue')));
87 $box = id(new PHUIObjectBoxView())
88 ->setFormErrors($errors)
89 ->setHeaderText($title)
90 ->setBackground(PHUIObjectBoxView
::WHITE_CONFIG
)
93 $view = id(new PHUITwoColumnView())
96 return $this->newPage()