Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F117369351
HarbormasterPlanOrderController.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, Jun 13, 07:55
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Jun 15, 07:55 (2 d)
Engine
blob
Format
Raw Data
Handle
26757350
Attached To
rPH Phabricator
HarbormasterPlanOrderController.php
View Options
<?php
final
class
HarbormasterPlanOrderController
extends
HarbormasterController
{
private
$id
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
idx
(
$data
,
'id'
);
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$request
->
validateCSRF
();
$this
->
requireApplicationCapability
(
HarbormasterManagePlansCapability
::
CAPABILITY
);
$plan
=
id
(
new
HarbormasterBuildPlanQuery
())
->
setViewer
(
$user
)
->
withIDs
(
array
(
$this
->
id
))
->
executeOne
();
if
(!
$plan
)
{
return
new
Aphront404Response
();
}
// Load all steps.
$order
=
$request
->
getStrList
(
'order'
);
$steps
=
id
(
new
HarbormasterBuildStepQuery
())
->
setViewer
(
$user
)
->
withIDs
(
$order
)
->
execute
();
$steps
=
array_select_keys
(
$steps
,
$order
);
$reordered_steps
=
array
();
// Apply sequences.
$sequence
=
1
;
foreach
(
$steps
as
$step
)
{
$step
->
setSequence
(
$sequence
++);
$step
->
save
();
$reordered_steps
[]
=
$step
;
}
// NOTE: Reordering steps may invalidate artifacts. This is fine; the UI
// will show that there are ordering issues.
// Force the page to re-render.
return
id
(
new
AphrontRedirectResponse
());
}
}
Event Timeline
Log In to Comment