[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/harbormaster/conduit/ -> HarbormasterSendMessageConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class HarbormasterSendMessageConduitAPIMethod
   4    extends HarbormasterConduitAPIMethod {
   5  
   6    public function getAPIMethodName() {
   7      return 'harbormaster.sendmessage';
   8    }
   9  
  10    public function getMethodDescription() {
  11      return pht(
  12        'Send a message to a build target, notifying it of results in an '.
  13        'external system.');
  14    }
  15  
  16    public function defineParamTypes() {
  17      $type_const = $this->formatStringConstants(array('pass', 'fail'));
  18  
  19      return array(
  20        'buildTargetPHID' => 'required phid',
  21        'type'            => 'required '.$type_const,
  22      );
  23    }
  24  
  25    public function defineReturnType() {
  26      return 'void';
  27    }
  28  
  29    public function defineErrorTypes() {
  30      return array();
  31    }
  32  
  33    protected function execute(ConduitAPIRequest $request) {
  34      $viewer = $request->getUser();
  35  
  36      $build_target_phid = $request->getValue('buildTargetPHID');
  37      $message_type = $request->getValue('type');
  38  
  39      $build_target = id(new HarbormasterBuildTargetQuery())
  40        ->setViewer($viewer)
  41        ->withPHIDs(array($build_target_phid))
  42        ->executeOne();
  43      if (!$build_target) {
  44        throw new Exception(pht('No such build target!'));
  45      }
  46  
  47      $message = HarbormasterBuildMessage::initializeNewMessage($viewer)
  48        ->setBuildTargetPHID($build_target->getPHID())
  49        ->setType($message_type)
  50        ->save();
  51  
  52      // If the build has completely paused because all steps are blocked on
  53      // waiting targets, this will resume it.
  54      PhabricatorWorker::scheduleTask(
  55        'HarbormasterBuildWorker',
  56        array(
  57          'buildID' => $build_target->getBuild()->getID(),
  58        ));
  59  
  60      return null;
  61    }
  62  
  63  }


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