[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PassphraseCredentialCreateController extends PassphraseController { 4 5 public function processRequest() { 6 $request = $this->getRequest(); 7 $viewer = $request->getUser(); 8 9 $types = PassphraseCredentialType::getAllCreateableTypes(); 10 $types = mpull($types, null, 'getCredentialType'); 11 $types = msort($types, 'getCredentialTypeName'); 12 13 $errors = array(); 14 $e_type = null; 15 16 if ($request->isFormPost()) { 17 $type = $request->getStr('type'); 18 if (empty($types[$type])) { 19 $errors[] = pht('You must choose a credential type.'); 20 $e_type = pht('Required'); 21 } 22 23 if (!$errors) { 24 $uri = $this->getApplicationURI('edit/?type='.$type); 25 return id(new AphrontRedirectResponse())->setURI($uri); 26 } 27 } 28 29 $types_control = id(new AphrontFormRadioButtonControl()) 30 ->setName('type') 31 ->setLabel(pht('Credential Type')) 32 ->setError($e_type); 33 34 foreach ($types as $type) { 35 $types_control->addButton( 36 $type->getCredentialType(), 37 $type->getCredentialTypeName(), 38 $type->getCredentialTypeDescription()); 39 } 40 41 $form = id(new AphrontFormView()) 42 ->setUser($viewer) 43 ->appendChild($types_control) 44 ->appendChild( 45 id(new AphrontFormSubmitControl()) 46 ->setValue(pht('Continue')) 47 ->addCancelButton($this->getApplicationURI())); 48 49 $title = pht('New Credential'); 50 51 $crumbs = $this->buildApplicationCrumbs(); 52 $crumbs->addTextCrumb(pht('Create')); 53 54 $box = id(new PHUIObjectBoxView()) 55 ->setHeaderText(pht('Create New Credential')) 56 ->setFormErrors($errors) 57 ->setForm($form); 58 59 return $this->buildApplicationPage( 60 array( 61 $crumbs, 62 $box, 63 ), 64 array( 65 'title' => $title, 66 )); 67 } 68 69 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |