Path: blob/master/src/applications/harbormaster/storage/HarbormasterBuildMessage.php
12256 views
<?php12/**3* A message sent to an executing build target by an external system. We4* capture these messages and process them asynchronously to avoid race5* conditions where we receive a message before a build plan is ready to6* accept it.7*/8final class HarbormasterBuildMessage9extends HarbormasterDAO10implements11PhabricatorPolicyInterface,12PhabricatorDestructibleInterface {1314protected $authorPHID;15protected $receiverPHID;16protected $type;17protected $isConsumed;1819private $receiver = self::ATTACHABLE;2021public static function initializeNewMessage(PhabricatorUser $actor) {22$actor_phid = $actor->getPHID();23if (!$actor_phid) {24$actor_phid = id(new PhabricatorHarbormasterApplication())->getPHID();25}2627return id(new HarbormasterBuildMessage())28->setAuthorPHID($actor_phid)29->setIsConsumed(0);30}3132protected function getConfiguration() {33return array(34self::CONFIG_COLUMN_SCHEMA => array(35'type' => 'text16',36'isConsumed' => 'bool',37),38self::CONFIG_KEY_SCHEMA => array(39'key_receiver' => array(40'columns' => array('receiverPHID'),41),42),43) + parent::getConfiguration();44}4546public function getReceiver() {47return $this->assertAttached($this->receiver);48}4950public function attachReceiver($receiver) {51$this->receiver = $receiver;52return $this;53}545556/* -( PhabricatorPolicyInterface )----------------------------------------- */575859public function getCapabilities() {60return array(61PhabricatorPolicyCapability::CAN_VIEW,62);63}6465public function getPolicy($capability) {66return $this->getReceiver()->getPolicy($capability);67}6869public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {70return $this->getReceiver()->hasAutomaticCapability(71$capability,72$viewer);73}7475public function describeAutomaticCapability($capability) {76return pht('Build messages have the same policies as their receivers.');77}787980/* -( PhabricatorDestructibleInterface )----------------------------------- */818283public function destroyObjectPermanently(84PhabricatorDestructionEngine $engine) {85$this->delete();86}8788}899091