[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/conpherence/conduit/ -> ConpherenceCreateThreadConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class ConpherenceCreateThreadConduitAPIMethod
   4    extends ConpherenceConduitAPIMethod {
   5  
   6    public function getAPIMethodName() {
   7      return 'conpherence.createthread';
   8    }
   9  
  10    public function getMethodDescription() {
  11      return pht('Create a new conpherence thread.');
  12    }
  13  
  14    public function defineParamTypes() {
  15      return array(
  16        'title' => 'optional string',
  17        'message' => 'required string',
  18        'participantPHIDs' => 'required list<phids>',
  19      );
  20    }
  21  
  22    public function defineReturnType() {
  23      return 'nonempty dict';
  24    }
  25  
  26    public function defineErrorTypes() {
  27      return array(
  28        'ERR_EMPTY_PARTICIPANT_PHIDS' => pht(
  29          'You must specify participant phids.'),
  30        'ERR_EMPTY_MESSAGE' => pht(
  31          'You must specify a message.'),
  32      );
  33    }
  34  
  35    protected function execute(ConduitAPIRequest $request) {
  36      $participant_phids = $request->getValue('participantPHIDs', array());
  37      $message = $request->getValue('message');
  38      $title = $request->getValue('title');
  39  
  40      list($errors, $conpherence) = ConpherenceEditor::createConpherence(
  41        $request->getUser(),
  42        $participant_phids,
  43        $title,
  44        $message,
  45        PhabricatorContentSource::newFromConduitRequest($request));
  46  
  47      if ($errors) {
  48        foreach ($errors as $error_code) {
  49          switch ($error_code) {
  50            case ConpherenceEditor::ERROR_EMPTY_MESSAGE:
  51              throw new ConduitException('ERR_EMPTY_MESSAGE');
  52              break;
  53            case ConpherenceEditor::ERROR_EMPTY_PARTICIPANTS:
  54              throw new ConduitException('ERR_EMPTY_PARTICIPANT_PHIDS');
  55              break;
  56          }
  57        }
  58      }
  59  
  60      return array(
  61        'conpherenceID' => $conpherence->getID(),
  62        'conpherencePHID' => $conpherence->getPHID(),
  63        'conpherenceURI' => $this->getConpherenceURI($conpherence),
  64      );
  65    }
  66  
  67  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1