Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96186318
PassphraseCredentialCreateController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 23, 14:20
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 14:20 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23140899
Attached To
rPH Phabricator
PassphraseCredentialCreateController.php
View Options
<?php
final
class
PassphraseCredentialCreateController
extends
PassphraseController
{
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$types
=
PassphraseCredentialType
::
getAllTypes
();
$types
=
mpull
(
$types
,
null
,
'getCredentialType'
);
$types
=
msort
(
$types
,
'getCredentialTypeName'
);
$errors
=
array
();
$e_type
=
null
;
if
(
$request
->
isFormPost
())
{
$type
=
$request
->
getStr
(
'type'
);
if
(
empty
(
$types
[
$type
]))
{
$errors
[]
=
pht
(
'You must choose a credential type.'
);
$e_type
=
pht
(
'Required'
);
}
if
(!
$errors
)
{
$uri
=
$this
->
getApplicationURI
(
'edit/?type='
.
$type
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$uri
);
}
}
$error_view
=
null
;
if
(
$errors
)
{
$error_view
=
id
(
new
AphrontErrorView
())
->
setErrors
(
$errors
);
}
$types_control
=
id
(
new
AphrontFormRadioButtonControl
())
->
setName
(
'type'
)
->
setLabel
(
pht
(
'Credential Type'
))
->
setError
(
$e_type
);
foreach
(
$types
as
$type
)
{
$types_control
->
addButton
(
$type
->
getCredentialType
(),
$type
->
getCredentialTypeName
(),
$type
->
getCredentialTypeDescription
());
}
$form
=
id
(
new
AphrontFormView
())
->
setUser
(
$viewer
)
->
appendChild
(
$types_control
)
->
appendChild
(
id
(
new
AphrontFormSubmitControl
())
->
setValue
(
pht
(
'Continue'
))
->
addCancelButton
(
$this
->
getApplicationURI
()));
$title
=
pht
(
'New Credential'
);
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
addTextCrumb
(
pht
(
'Create'
));
$box
=
id
(
new
PHUIObjectBoxView
())
->
setHeaderText
(
pht
(
'Create New Credential'
))
->
setFormError
(
$error_view
)
->
setForm
(
$form
);
return
$this
->
buildApplicationPage
(
array
(
$crumbs
,
$box
,
),
array
(
'title'
=>
$title
,
'device'
=>
true
,
));
}
}
Event Timeline
Log In to Comment