Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96313271
DrydockBlueprintCreateController.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
Wed, Dec 25, 03:07
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Dec 27, 03:07 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23146221
Attached To
rPH Phabricator
DrydockBlueprintCreateController.php
View Options
<?php
final
class
DrydockBlueprintCreateController
extends
DrydockController
{
public
function
willProcessRequest
(
array
$data
)
{
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$implementations
=
DrydockBlueprintImplementation
::
getAllBlueprintImplementations
();
if
(
$request
->
isFormPost
())
{
$class
=
$request
->
getStr
(
'blueprint-type'
);
if
(!
isset
(
$implementations
[
$class
]))
{
return
$this
->
createDialog
(
$implementations
);
}
$blueprint
=
new
DrydockBlueprint
();
$blueprint
->
setClassName
(
$class
);
$blueprint
->
setDetails
(
array
());
$blueprint
->
setViewPolicy
(
PhabricatorPolicies
::
POLICY_ADMIN
);
$blueprint
->
setEditPolicy
(
PhabricatorPolicies
::
POLICY_ADMIN
);
$blueprint
->
save
();
$edit_uri
=
$this
->
getApplicationURI
(
"blueprint/edit/"
.
$blueprint
->
getID
().
"/"
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$edit_uri
);
}
return
$this
->
createDialog
(
$implementations
);
}
function
createDialog
(
array
$implementations
)
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$control
=
id
(
new
AphrontFormRadioButtonControl
())
->
setName
(
'blueprint-type'
);
foreach
(
$implementations
as
$implementation_name
=>
$implementation
)
{
$control
->
addButton
(
$implementation_name
,
$implementation
->
getBlueprintClass
(),
$implementation
->
getDescription
());
}
$dialog
=
new
AphrontDialogView
();
$dialog
->
setTitle
(
pht
(
'Create New Blueprint'
))
->
setUser
(
$viewer
)
->
addSubmitButton
(
pht
(
'Create Blueprint'
))
->
addCancelButton
(
$this
->
getApplicationURI
(
'blueprint/'
));
$dialog
->
appendChild
(
phutil_tag
(
'p'
,
array
(),
pht
(
'Select what type of blueprint you want to create: '
)));
$dialog
->
appendChild
(
$control
);
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment