Path: blob/master/src/applications/passphrase/controller/PassphraseCredentialCreateController.php
12256 views
<?php12final class PassphraseCredentialCreateController extends PassphraseController {34public function handleRequest(AphrontRequest $request) {5$viewer = $request->getViewer();67$types = PassphraseCredentialType::getAllCreateableTypes();8$types = mpull($types, null, 'getCredentialType');9$types = msort($types, 'getCredentialTypeName');1011$errors = array();12$e_type = null;1314if ($request->isFormPost()) {15$type = $request->getStr('type');16if (empty($types[$type])) {17$errors[] = pht('You must choose a credential type.');18$e_type = pht('Required');19}2021if (!$errors) {22$uri = $this->getApplicationURI('edit/?type='.$type);23return id(new AphrontRedirectResponse())->setURI($uri);24}25}2627$types_control = id(new AphrontFormRadioButtonControl())28->setName('type')29->setLabel(pht('Credential Type'))30->setError($e_type);3132foreach ($types as $type) {33$types_control->addButton(34$type->getCredentialType(),35$type->getCredentialTypeName(),36$type->getCredentialTypeDescription());37}3839$form = id(new AphrontFormView())40->setUser($viewer)41->appendChild($types_control)42->appendChild(43id(new AphrontFormSubmitControl())44->setValue(pht('Continue'))45->addCancelButton($this->getApplicationURI()));4647$title = pht('New Credential');4849$crumbs = $this->buildApplicationCrumbs();50$crumbs->addTextCrumb(pht('Create'));51$crumbs->setBorder(true);5253$box = id(new PHUIObjectBoxView())54->setHeaderText($title)55->setFormErrors($errors)56->setBackground(PHUIObjectBoxView::WHITE_CONFIG)57->setForm($form);5859$view = id(new PHUITwoColumnView())60->setFooter($box);6162return $this->newPage()63->setTitle($title)64->setCrumbs($crumbs)65->appendChild($view);66}6768}697071