Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / repository / storage / PhabricatorRepositorySyncEvent.php
blobdd5765985eb40fb618b753526f315f5101ad7c26
1 <?php
3 final class PhabricatorRepositorySyncEvent
4 extends PhabricatorRepositoryDAO
5 implements PhabricatorPolicyInterface {
7 protected $repositoryPHID;
8 protected $epoch;
9 protected $devicePHID;
10 protected $fromDevicePHID;
11 protected $deviceVersion;
12 protected $fromDeviceVersion;
13 protected $resultType;
14 protected $resultCode;
15 protected $syncWait;
16 protected $properties = array();
18 private $repository = self::ATTACHABLE;
20 const RESULT_SYNC = 'sync';
21 const RESULT_ERROR = 'error';
22 const RESULT_TIMEOUT = 'timeout';
23 const RESULT_EXCEPTION = 'exception';
25 public static function initializeNewEvent() {
26 return new self();
29 protected function getConfiguration() {
30 return array(
31 self::CONFIG_AUX_PHID => true,
32 self::CONFIG_TIMESTAMPS => false,
33 self::CONFIG_SERIALIZATION => array(
34 'properties' => self::SERIALIZATION_JSON,
36 self::CONFIG_COLUMN_SCHEMA => array(
37 'deviceVersion' => 'uint32?',
38 'fromDeviceVersion' => 'uint32?',
39 'resultType' => 'text32',
40 'resultCode' => 'uint32',
41 'syncWait' => 'uint64',
43 self::CONFIG_KEY_SCHEMA => array(
44 'key_repository' => array(
45 'columns' => array('repositoryPHID'),
47 'key_epoch' => array(
48 'columns' => array('epoch'),
51 ) + parent::getConfiguration();
54 public function getPHIDType() {
55 return PhabricatorRepositorySyncEventPHIDType::TYPECONST;
58 public function attachRepository(PhabricatorRepository $repository) {
59 $this->repository = $repository;
60 return $this;
63 public function getRepository() {
64 return $this->assertAttached($this->repository);
67 public function setProperty($key, $value) {
68 $this->properties[$key] = $value;
69 return $this;
72 public function getProperty($key, $default = null) {
73 return idx($this->properties, $key, $default);
76 /* -( PhabricatorPolicyInterface )----------------------------------------- */
79 public function getCapabilities() {
80 return array(
81 PhabricatorPolicyCapability::CAN_VIEW,
85 public function getPolicy($capability) {
86 return $this->getRepository()->getPolicy($capability);
89 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
90 return $this->getRepository()->hasAutomaticCapability($capability, $viewer);
93 public function describeAutomaticCapability($capability) {
94 return pht(
95 "A repository's sync events are visible to users who can see the ".
96 "repository.");