Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F461481
HarbormasterStepAddController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
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
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 5, 4:51 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
72286
Default Alt Text
HarbormasterStepAddController.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment