[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PonderQuestionStatusController 4 extends PonderController { 5 6 private $status; 7 private $id; 8 9 public function willProcessRequest(array $data) { 10 $this->status = idx($data, 'status'); 11 $this->id = idx($data, 'id'); 12 } 13 14 public function processRequest() { 15 $request = $this->getRequest(); 16 $viewer = $request->getUser(); 17 18 $question = id(new PonderQuestionQuery()) 19 ->setViewer($viewer) 20 ->withIDs(array($this->id)) 21 ->requireCapabilities( 22 array( 23 PhabricatorPolicyCapability::CAN_VIEW, 24 PhabricatorPolicyCapability::CAN_EDIT, 25 )) 26 ->executeOne(); 27 if (!$question) { 28 return new Aphront404Response(); 29 } 30 31 switch ($this->status) { 32 case 'open': 33 $status = PonderQuestionStatus::STATUS_OPEN; 34 break; 35 case 'close': 36 $status = PonderQuestionStatus::STATUS_CLOSED; 37 break; 38 default: 39 return new Aphront400Response(); 40 } 41 42 $xactions = array(); 43 $xactions[] = id(new PonderQuestionTransaction()) 44 ->setTransactionType(PonderQuestionTransaction::TYPE_STATUS) 45 ->setNewValue($status); 46 47 $editor = id(new PonderQuestionEditor()) 48 ->setActor($viewer) 49 ->setContentSourceFromRequest($request); 50 51 $editor->applyTransactions($question, $xactions); 52 53 return id(new AphrontRedirectResponse())->setURI('/Q'.$question->getID()); 54 } 55 56 }
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 |