@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Misc PHPDoc additions to PhabricatorFile

Summary: Add some PHPDoc comments to the `PhabricatorFile` class as I was playing with calling some of its methods.

Test Plan: Call those methods and see what they do and return.

Reviewers: O1 Blessed Committers, avivey

Reviewed By: O1 Blessed Committers, avivey

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D25763

+58 -1
+58 -1
src/applications/files/storage/PhabricatorFile.php
··· 176 176 return true; 177 177 } 178 178 179 + /** 180 + * Get file monogram in the format of "F123" 181 + * @return string 182 + */ 179 183 public function getMonogram() { 180 184 return 'F'.$this->getID(); 181 185 } ··· 821 825 return $iterator; 822 826 } 823 827 828 + /** 829 + * Get file URI in the format of "/F123" 830 + * @return string 831 + */ 824 832 public function getURI() { 825 833 return $this->getInfoURI(); 826 834 } 827 835 836 + /** 837 + * Get file view URI in the format of 838 + * https://phorge.example.com/file/data/foo/PHID-FILE-bar/filename 839 + * @return string 840 + */ 828 841 public function getViewURI() { 829 842 if (!$this->getPHID()) { 830 843 throw new Exception( ··· 834 847 return $this->getCDNURI('data'); 835 848 } 836 849 850 + /** 851 + * Get file view URI in the format of 852 + * https://phorge.example.com/file/data/foo/PHID-FILE-bar/filename or 853 + * https://phorge.example.com/file/download/foo/PHID-FILE-bar/filename 854 + * @return string 855 + */ 837 856 public function getCDNURI($request_kind) { 838 857 if (($request_kind !== 'data') && 839 858 ($request_kind !== 'download')) { ··· 876 895 } 877 896 } 878 897 879 - 898 + /** 899 + * Get file info URI in the format of "/F123" 900 + * @return string 901 + */ 880 902 public function getInfoURI() { 881 903 return '/'.$this->getMonogram(); 882 904 } ··· 889 911 } 890 912 } 891 913 914 + /** 915 + * Get file view URI in the format of 916 + * https://phorge.example.com/file/download/foo/PHID-FILE-bar/filename 917 + * @return string 918 + */ 892 919 public function getDownloadURI() { 893 920 return $this->getCDNURI('download'); 894 921 } ··· 917 944 return PhabricatorEnv::getCDNURI($path); 918 945 } 919 946 947 + /** 948 + * Whether the file can be viewed in a browser 949 + * @return bool True if MIME type of the file is listed in the 950 + * files.viewable-mime-types setting 951 + */ 920 952 public function isViewableInBrowser() { 921 953 return ($this->getViewableMimeType() !== null); 922 954 } 923 955 956 + /** 957 + * Whether the file is an image viewable in the browser 958 + * @return bool True if MIME type of the file is listed in the 959 + * files.image-mime-types setting and file is viewable in the browser 960 + */ 924 961 public function isViewableImage() { 925 962 if (!$this->isViewableInBrowser()) { 926 963 return false; ··· 931 968 return idx($mime_map, $mime_type); 932 969 } 933 970 971 + /** 972 + * Whether the file is an audio file 973 + * @return bool True if MIME type of the file is listed in the 974 + * files.audio-mime-types setting and file is viewable in the browser 975 + */ 934 976 public function isAudio() { 935 977 if (!$this->isViewableInBrowser()) { 936 978 return false; ··· 941 983 return idx($mime_map, $mime_type); 942 984 } 943 985 986 + /** 987 + * Whether the file is a video file 988 + * @return bool True if MIME type of the file is listed in the 989 + * files.video-mime-types setting and file is viewable in the browser 990 + */ 944 991 public function isVideo() { 945 992 if (!$this->isViewableInBrowser()) { 946 993 return false; ··· 951 998 return idx($mime_map, $mime_type); 952 999 } 953 1000 1001 + /** 1002 + * Whether the file is a PDF file 1003 + * @return bool True if MIME type of the file is application/pdf and file is 1004 + * viewable in the browser 1005 + */ 954 1006 public function isPDF() { 955 1007 if (!$this->isViewableInBrowser()) { 956 1008 return false; ··· 1048 1100 ->execute(); 1049 1101 } 1050 1102 1103 + /** 1104 + * Whether the file is listed as a viewable MIME type 1105 + * @return bool True if MIME type of the file is listed in the 1106 + * files.viewable-mime-types setting 1107 + */ 1051 1108 public function getViewableMimeType() { 1052 1109 $mime_map = PhabricatorEnv::getEnvConfig('files.viewable-mime-types'); 1053 1110