Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / files / conduit / FileInfoConduitAPIMethod.php
blobf1c8f5941a066efad0ba03db62af74b17140a107
1 <?php
3 final class FileInfoConduitAPIMethod extends FileConduitAPIMethod {
5 public function getAPIMethodName() {
6 return 'file.info';
9 public function getMethodDescription() {
10 return pht('Get information about a file.');
13 public function getMethodStatus() {
14 return self::METHOD_STATUS_FROZEN;
17 public function getMethodStatusDescription() {
18 return pht(
19 'This method is frozen and will eventually be deprecated. New code '.
20 'should use "file.search" instead.');
23 protected function defineParamTypes() {
24 return array(
25 'phid' => 'optional phid',
26 'id' => 'optional id',
30 protected function defineReturnType() {
31 return 'nonempty dict';
34 protected function defineErrorTypes() {
35 return array(
36 'ERR-NOT-FOUND' => pht('No such file exists.'),
40 protected function execute(ConduitAPIRequest $request) {
41 $phid = $request->getValue('phid');
42 $id = $request->getValue('id');
44 $query = id(new PhabricatorFileQuery())
45 ->setViewer($request->getUser());
46 if ($id) {
47 $query->withIDs(array($id));
48 } else {
49 $query->withPHIDs(array($phid));
52 $file = $query->executeOne();
54 if (!$file) {
55 throw new ConduitException('ERR-NOT-FOUND');
58 $uri = $file->getInfoURI();
60 return array(
61 'id' => $file->getID(),
62 'phid' => $file->getPHID(),
63 'objectName' => 'F'.$file->getID(),
64 'name' => $file->getName(),
65 'mimeType' => $file->getMimeType(),
66 'byteSize' => $file->getByteSize(),
67 'authorPHID' => $file->getAuthorPHID(),
68 'dateCreated' => $file->getDateCreated(),
69 'dateModified' => $file->getDateModified(),
70 'uri' => PhabricatorEnv::getProductionURI($uri),