Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / harbormaster / storage / HarbormasterBuildMessage.php
blob34aab3957e2eb2d92edb92dec0a2dce8e23c7742
1 <?php
3 /**
4 * A message sent to an executing build target by an external system. We
5 * capture these messages and process them asynchronously to avoid race
6 * conditions where we receive a message before a build plan is ready to
7 * accept it.
8 */
9 final class HarbormasterBuildMessage
10 extends HarbormasterDAO
11 implements
12 PhabricatorPolicyInterface,
13 PhabricatorDestructibleInterface {
15 protected $authorPHID;
16 protected $receiverPHID;
17 protected $type;
18 protected $isConsumed;
20 private $receiver = self::ATTACHABLE;
22 public static function initializeNewMessage(PhabricatorUser $actor) {
23 $actor_phid = $actor->getPHID();
24 if (!$actor_phid) {
25 $actor_phid = id(new PhabricatorHarbormasterApplication())->getPHID();
28 return id(new HarbormasterBuildMessage())
29 ->setAuthorPHID($actor_phid)
30 ->setIsConsumed(0);
33 protected function getConfiguration() {
34 return array(
35 self::CONFIG_COLUMN_SCHEMA => array(
36 'type' => 'text16',
37 'isConsumed' => 'bool',
39 self::CONFIG_KEY_SCHEMA => array(
40 'key_receiver' => array(
41 'columns' => array('receiverPHID'),
44 ) + parent::getConfiguration();
47 public function getReceiver() {
48 return $this->assertAttached($this->receiver);
51 public function attachReceiver($receiver) {
52 $this->receiver = $receiver;
53 return $this;
57 /* -( PhabricatorPolicyInterface )----------------------------------------- */
60 public function getCapabilities() {
61 return array(
62 PhabricatorPolicyCapability::CAN_VIEW,
66 public function getPolicy($capability) {
67 return $this->getReceiver()->getPolicy($capability);
70 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
71 return $this->getReceiver()->hasAutomaticCapability(
72 $capability,
73 $viewer);
76 public function describeAutomaticCapability($capability) {
77 return pht('Build messages have the same policies as their receivers.');
81 /* -( PhabricatorDestructibleInterface )----------------------------------- */
84 public function destroyObjectPermanently(
85 PhabricatorDestructionEngine $engine) {
86 $this->delete();