Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99218340
HarbormasterStepAddController.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, Jan 22, 12:15
Size
2 KB
Mime Type
text/x-php
Expires
Fri, Jan 24, 12:15 (2 d)
Engine
blob
Format
Raw Data
Handle
23741709
Attached To
rPH Phabricator
HarbormasterStepAddController.php
View Options
<?php
final
class
HarbormasterStepAddController
extends
HarbormasterController
{
private
$id
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$this
->
requireApplicationCapability
(
HarbormasterCapabilityManagePlans
::
CAPABILITY
);
$id
=
$this
->
id
;
$plan
=
id
(
new
HarbormasterBuildPlanQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
))
->
executeOne
();
if
(
$plan
===
null
)
{
throw
new
Exception
(
"Build plan not found!"
);
}
$implementations
=
BuildStepImplementation
::
getImplementations
();
$cancel_uri
=
$this
->
getApplicationURI
(
'plan/'
.
$plan
->
getID
().
'/'
);
if
(
$request
->
isDialogFormPost
())
{
$class
=
$request
->
getStr
(
'step-type'
);
if
(!
in_array
(
$class
,
$implementations
))
{
return
$this
->
createDialog
(
$implementations
);
}
$step
=
new
HarbormasterBuildStep
();
$step
->
setBuildPlanPHID
(
$plan
->
getPHID
());
$step
->
setClassName
(
$class
);
$step
->
setDetails
(
array
());
$step
->
save
();
$edit_uri
=
$this
->
getApplicationURI
(
"step/edit/"
.
$step
->
getID
().
"/"
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$edit_uri
);
}
return
$this
->
createDialog
(
$implementations
,
$cancel_uri
);
}
function
createDialog
(
array
$implementations
,
$cancel_uri
)
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$control
=
id
(
new
AphrontFormRadioButtonControl
())
->
setName
(
'step-type'
);
foreach
(
$implementations
as
$implementation_name
)
{
$implementation
=
new
$implementation_name
();
$control
->
addButton
(
$implementation_name
,
$implementation
->
getName
(),
$implementation
->
getGenericDescription
());
}
$dialog
=
new
AphrontDialogView
();
$dialog
->
setTitle
(
pht
(
'Add New Step'
))
->
setUser
(
$viewer
)
->
addSubmitButton
(
pht
(
'Add Build Step'
))
->
addCancelButton
(
$cancel_uri
);
$dialog
->
appendChild
(
phutil_tag
(
'p'
,
array
(),
pht
(
'Select what type of build step you want to add: '
)));
$dialog
->
appendChild
(
$control
);
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment