Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92363902
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
Tue, Nov 19, 17:27
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Nov 21, 17:27 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22391723
Attached To
rPH Phabricator
AlmanacPropertyDeleteController.php
View Options
<?php
final
class
AlmanacPropertyDeleteController
extends
AlmanacPropertyController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$response
=
$this
->
loadPropertyObject
();
if
(
$response
)
{
return
$response
;
}
$object
=
$this
->
getPropertyObject
();
$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