Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102517156
HarbormasterPlanExecuteController.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
Fri, Feb 21, 13:39
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Feb 23, 13:39 (2 d)
Engine
blob
Format
Raw Data
Handle
24338771
Attached To
rPH Phabricator
HarbormasterPlanExecuteController.php
View Options
<?php
final
class
HarbormasterPlanExecuteController
extends
HarbormasterPlanController
{
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
)
{
return
new
Aphront404Response
();
}
$cancel_uri
=
$this
->
getApplicationURI
(
"plan/{$id}/"
);
$v_buildable
=
null
;
$e_buildable
=
null
;
$errors
=
array
();
if
(
$request
->
isFormPost
())
{
$v_buildable
=
$request
->
getStr
(
'buildable'
);
if
(
$v_buildable
)
{
$buildable
=
id
(
new
HarbormasterBuildableQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
trim
(
$v_buildable
,
'B'
)))
->
executeOne
();
if
(!
$buildable
)
{
$e_buildable
=
pht
(
'Invalid'
);
}
}
else
{
$e_buildable
=
pht
(
'Required'
);
$errors
[]
=
pht
(
'You must provide a buildable.'
);
}
if
(!
$errors
)
{
$build_plan
=
HarbormasterBuild
::
initializeNewBuild
(
$viewer
)
->
setBuildablePHID
(
$buildable
->
getPHID
())
->
setBuildPlanPHID
(
$plan
->
getPHID
())
->
save
();
$buildable_id
=
$buildable
->
getID
();
return
id
(
new
AphrontRedirectResponse
())
->
setURI
(
"/B{$buildable_id}"
);
}
}
if
(
$errors
)
{
$errors
=
id
(
new
AphrontErrorView
())->
setErrors
(
$errors
);
}
$form
=
id
(
new
PHUIFormLayoutView
())
->
appendChild
(
id
(
new
AphrontFormTextControl
())
->
setLabel
(
pht
(
'Buildable'
))
->
setName
(
'buildable'
)
->
setValue
(
$v_buildable
)
->
setError
(
$e_buildable
));
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$viewer
)
->
setTitle
(
pht
(
'Execute Build Plan'
))
->
setWidth
(
AphrontDialogView
::
WIDTH_FORM
)
->
appendChild
(
$errors
)
->
appendChild
(
$form
)
->
addSubmitButton
(
pht
(
'Execute Build Plan'
))
->
addCancelButton
(
$cancel_uri
);
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment