Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / diffusion / data / DiffusionRepositoryPath.php
blob719bc227018d562ada0797d643b330474d68ab6e
1 <?php
3 final class DiffusionRepositoryPath extends Phobject {
5 private $fullPath;
6 private $path;
7 private $hash;
8 private $fileType;
9 private $fileSize;
10 private $externalURI;
12 private $lastModifiedCommit;
13 private $lastCommitData;
15 public function setFullPath($full_path) {
16 $this->fullPath = $full_path;
17 return $this;
20 public function getFullPath() {
21 return $this->fullPath;
24 public function setPath($path) {
25 $this->path = $path;
26 return $this;
29 public function getPath() {
30 return $this->path;
33 public function setHash($hash) {
34 $this->hash = $hash;
35 return $this;
38 public function getHash() {
39 return $this->hash;
42 public function setLastModifiedCommit(
43 PhabricatorRepositoryCommit $commit) {
44 $this->lastModifiedCommit = $commit;
45 return $this;
48 public function getLastModifiedCommit() {
49 return $this->lastModifiedCommit;
52 public function setLastCommitData(
53 PhabricatorRepositoryCommitData $last_commit_data) {
54 $this->lastCommitData = $last_commit_data;
55 return $this;
58 public function getLastCommitData() {
59 return $this->lastCommitData;
62 public function setFileType($file_type) {
63 $this->fileType = $file_type;
64 return $this;
67 public function getFileType() {
68 return $this->fileType;
71 public function setFileSize($file_size) {
72 $this->fileSize = $file_size;
73 return $this;
76 public function getFileSize() {
77 return $this->fileSize;
80 public function setExternalURI($external_uri) {
81 $this->externalURI = $external_uri;
82 return $this;
85 public function getExternalURI() {
86 return $this->externalURI;
89 public function toDictionary() {
90 $last_modified_commit = $this->getLastModifiedCommit();
91 if ($last_modified_commit) {
92 $last_modified_commit = $last_modified_commit->toDictionary();
94 $last_commit_data = $this->getLastCommitData();
95 if ($last_commit_data) {
96 $last_commit_data = $last_commit_data->toDictionary();
98 return array(
99 'fullPath' => $this->getFullPath(),
100 'path' => $this->getPath(),
101 'hash' => $this->getHash(),
102 'fileType' => $this->getFileType(),
103 'fileSize' => $this->getFileSize(),
104 'externalURI' => $this->getExternalURI(),
105 'lastModifiedCommit' => $last_modified_commit,
106 'lastCommitData' => $last_commit_data,
110 public static function newFromDictionary(array $dict) {
111 $path = id(new DiffusionRepositoryPath())
112 ->setFullPath($dict['fullPath'])
113 ->setPath($dict['path'])
114 ->setHash($dict['hash'])
115 ->setFileType($dict['fileType'])
116 ->setFileSize($dict['fileSize'])
117 ->setExternalURI($dict['externalURI']);
118 if ($dict['lastModifiedCommit']) {
119 $last_modified_commit = PhabricatorRepositoryCommit::newFromDictionary(
120 $dict['lastModifiedCommit']);
121 $path->setLastModifiedCommit($last_modified_commit);
123 if ($dict['lastCommitData']) {
124 $last_commit_data = PhabricatorRepositoryCommitData::newFromDictionary(
125 $dict['lastCommitData']);
126 $path->setLastCommitData($last_commit_data);
128 return $path;