Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101089585
AlmanacPropertyDeleteController.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, Feb 5, 15:44
Size
2 KB
Mime Type
text/x-php
Expires
Fri, Feb 7, 15:44 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24085783
Attached To
rPH Phabricator
AlmanacPropertyDeleteController.php
View Options
<?php
final
class
AlmanacPropertyDeleteController
extends
AlmanacDeviceController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$object
=
id
(
new
PhabricatorObjectQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$request
->
getStr
(
'objectPHID'
)))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$object
)
{
return
new
Aphront404Response
();
}
if
(!(
$object
instanceof
AlmanacPropertyInterface
))
{
return
new
Aphront404Response
();
}
$key
=
$request
->
getStr
(
'key'
);
if
(!
strlen
(
$key
))
{
return
new
Aphront404Response
();
}
$cancel_uri
=
$object
->
getURI
();
$builtins
=
$object
->
getAlmanacPropertyFieldSpecifications
();
$is_builtin
=
isset
(
$builtins
[
$key
]);
if
(
$is_builtin
)
{
$title
=
pht
(
'Reset Property'
);
$body
=
pht
(
'Reset property "%s" to its default value?'
,
$key
);
$submit_text
=
pht
(
'Reset Property'
);
}
else
{
$title
=
pht
(
'Delete Property'
);
$body
=
pht
(
'Delete property "%s"?'
,
$key
);
$submit_text
=
pht
(
'Delete Property'
);
}
$validation_exception
=
null
;
if
(
$request
->
isFormPost
())
{
$xaction
=
$object
->
getApplicationTransactionTemplate
()
->
setTransactionType
(
AlmanacTransaction
::
TYPE_PROPERTY_REMOVE
)
->
setMetadataValue
(
'almanac.property'
,
$key
);
$editor
=
$object
->
getApplicationTransactionEditor
()
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
);
try
{
$editor
->
applyTransactions
(
$object
,
array
(
$xaction
));
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$cancel_uri
);
}
catch
(
PhabricatorApplicationTransactionValidationException
$ex
)
{
$validation_exception
=
$ex
;
}
}
return
$this
->
newDialog
()
->
setTitle
(
$title
)
->
setValidationException
(
$validation_exception
)
->
addHiddenInput
(
'objectPHID'
,
$object
->
getPHID
())
->
addHiddenInput
(
'key'
,
$key
)
->
appendParagraph
(
$body
)
->
addCancelButton
(
$cancel_uri
)
->
addSubmitButton
(
$submit_text
);
}
}
Event Timeline
Log In to Comment