3 final class AlmanacPropertyDeleteController
4 extends AlmanacPropertyController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $request->getViewer();
9 $response = $this->loadPropertyObject();
14 $object = $this->getPropertyObject();
16 $key = $request->getStr('key');
18 return new Aphront404Response();
21 $cancel_uri = $object->getURI();
23 $builtins = $object->getAlmanacPropertyFieldSpecifications();
24 $is_builtin = isset($builtins[$key]);
27 $title = pht('Reset Property');
29 'Reset property "%s" to its default value?',
31 $submit_text = pht('Reset Property');
33 $title = pht('Delete Property');
35 'Delete property "%s"?',
37 $submit_text = pht('Delete Property');
40 $validation_exception = null;
41 if ($request->isFormPost()) {
42 $xaction_type = $object->getAlmanacPropertyDeleteTransactionType();
44 $xaction = $object->getApplicationTransactionTemplate()
45 ->setTransactionType($xaction_type)
46 ->setMetadataValue('almanac.property', $key);
48 $editor = $object->getApplicationTransactionEditor()
50 ->setContentSourceFromRequest($request)
51 ->setContinueOnNoEffect(true)
52 ->setContinueOnMissingFields(true);
55 $editor->applyTransactions($object, array($xaction));
56 return id(new AphrontRedirectResponse())->setURI($cancel_uri);
57 } catch (PhabricatorApplicationTransactionValidationException
$ex) {
58 $validation_exception = $ex;
62 return $this->newDialog()
64 ->setValidationException($validation_exception)
65 ->addHiddenInput('objectPHID', $object->getPHID())
66 ->addHiddenInput('key', $key)
67 ->appendParagraph($body)
68 ->addCancelButton($cancel_uri)
69 ->addSubmitButton($submit_text);