Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78584998
DrydockResourceCloseController.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, Aug 21, 19:22
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Aug 23, 19:22 (2 d)
Engine
blob
Format
Raw Data
Handle
20068141
Attached To
rPH Phabricator
DrydockResourceCloseController.php
View Options
<?php
final
class
DrydockResourceCloseController
extends
DrydockResourceController
{
private
$id
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$resource
=
id
(
new
DrydockResourceQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$this
->
id
))
->
executeOne
();
if
(!
$resource
)
{
return
new
Aphront404Response
();
}
$resource_uri
=
'/resource/'
.
$resource
->
getID
().
'/'
;
$resource_uri
=
$this
->
getApplicationURI
(
$resource_uri
);
if
(
$resource
->
getStatus
()
!=
DrydockResourceStatus
::
STATUS_OPEN
)
{
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$viewer
)
->
setTitle
(
pht
(
'Resource Not Open'
))
->
appendChild
(
phutil_tag
(
'p'
,
array
(),
pht
(
'You can only close "open" resources.'
)))
->
addCancelButton
(
$resource_uri
);
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
if
(
$request
->
isFormPost
())
{
$resource
->
closeResource
();
return
id
(
new
AphrontReloadResponse
())->
setURI
(
$resource_uri
);
}
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$viewer
)
->
setTitle
(
pht
(
'Really close resource?'
))
->
appendChild
(
pht
(
'Closing a resource releases all leases and destroys the '
.
'resource. It can not be undone. Continue?'
))
->
addSubmitButton
(
pht
(
'Close Resource'
))
->
addCancelButton
(
$resource_uri
);
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment