[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class FlagDeleteConduitAPIMethod extends FlagConduitAPIMethod { 4 5 public function getAPIMethodName() { 6 return 'flag.delete'; 7 } 8 9 public function getMethodDescription() { 10 return 'Clear a flag.'; 11 } 12 13 public function defineParamTypes() { 14 return array( 15 'id' => 'optional id', 16 'objectPHID' => 'optional phid', 17 ); 18 } 19 20 public function defineReturnType() { 21 return 'dict | null'; 22 } 23 24 public function defineErrorTypes() { 25 return array( 26 'ERR_NOT_FOUND' => 'Bad flag ID.', 27 'ERR_WRONG_USER' => 'You are not the creator of this flag.', 28 'ERR_NEED_PARAM' => 'Must pass an id or an objectPHID.', 29 ); 30 } 31 32 protected function execute(ConduitAPIRequest $request) { 33 $id = $request->getValue('id'); 34 $object = $request->getValue('objectPHID'); 35 if ($id) { 36 $flag = id(new PhabricatorFlag())->load($id); 37 if (!$flag) { 38 throw new ConduitException('ERR_NOT_FOUND'); 39 } 40 if ($flag->getOwnerPHID() != $request->getUser()->getPHID()) { 41 throw new ConduitException('ERR_WRONG_USER'); 42 } 43 } else if ($object) { 44 $flag = id(new PhabricatorFlag())->loadOneWhere( 45 'objectPHID = %s AND ownerPHID = %s', 46 $object, 47 $request->getUser()->getPHID()); 48 if (!$flag) { 49 return null; 50 } 51 } else { 52 throw new ConduitException('ERR_NEED_PARAM'); 53 } 54 $this->attachHandleToFlag($flag, $request->getUser()); 55 $ret = $this->buildFlagInfoDictionary($flag); 56 $flag->delete(); 57 return $ret; 58 } 59 60 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |