Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / files / format / PhabricatorFileStorageFormat.php
blob2d24aa22075390fa4a268eef8b182283f857a508
1 <?php
3 abstract class PhabricatorFileStorageFormat
4 extends Phobject {
6 private $file;
8 final public function setFile(PhabricatorFile $file) {
9 $this->file = $file;
10 return $this;
13 final public function getFile() {
14 if (!$this->file) {
15 throw new PhutilInvalidStateException('setFile');
17 return $this->file;
20 abstract public function getStorageFormatName();
22 abstract public function newReadIterator($raw_iterator);
23 abstract public function newWriteIterator($raw_iterator);
25 public function newFormatIntegrityHash() {
26 return null;
29 public function newStorageProperties() {
30 return array();
33 public function canGenerateNewKeyMaterial() {
34 return false;
37 public function generateNewKeyMaterial() {
38 throw new PhutilMethodNotImplementedException();
41 public function canCycleMasterKey() {
42 return false;
45 public function cycleStorageProperties() {
46 throw new PhutilMethodNotImplementedException();
49 public function selectMasterKey($key_name) {
50 throw new Exception(
51 pht(
52 'This storage format ("%s") does not support key selection.',
53 $this->getStorageFormatName()));
56 final public function getStorageFormatKey() {
57 return $this->getPhobjectClassConstant('FORMATKEY');
60 final public static function getAllFormats() {
61 return id(new PhutilClassMapQuery())
62 ->setAncestorClass(__CLASS__)
63 ->setUniqueMethod('getStorageFormatKey')
64 ->execute();
67 final public static function getFormat($key) {
68 $formats = self::getAllFormats();
69 return idx($formats, $key);
72 final public static function requireFormat($key) {
73 $format = self::getFormat($key);
75 if (!$format) {
76 throw new Exception(
77 pht(
78 'No file storage format with key "%s" exists.',
79 $key));
82 return $format;