Path: blob/master/src/applications/files/conduit/FileInfoConduitAPIMethod.php
12241 views
<?php12final class FileInfoConduitAPIMethod extends FileConduitAPIMethod {34public function getAPIMethodName() {5return 'file.info';6}78public function getMethodDescription() {9return pht('Get information about a file.');10}1112public function getMethodStatus() {13return self::METHOD_STATUS_FROZEN;14}1516public function getMethodStatusDescription() {17return pht(18'This method is frozen and will eventually be deprecated. New code '.19'should use "file.search" instead.');20}2122protected function defineParamTypes() {23return array(24'phid' => 'optional phid',25'id' => 'optional id',26);27}2829protected function defineReturnType() {30return 'nonempty dict';31}3233protected function defineErrorTypes() {34return array(35'ERR-NOT-FOUND' => pht('No such file exists.'),36);37}3839protected function execute(ConduitAPIRequest $request) {40$phid = $request->getValue('phid');41$id = $request->getValue('id');4243$query = id(new PhabricatorFileQuery())44->setViewer($request->getUser());45if ($id) {46$query->withIDs(array($id));47} else {48$query->withPHIDs(array($phid));49}5051$file = $query->executeOne();5253if (!$file) {54throw new ConduitException('ERR-NOT-FOUND');55}5657$uri = $file->getInfoURI();5859return array(60'id' => $file->getID(),61'phid' => $file->getPHID(),62'objectName' => 'F'.$file->getID(),63'name' => $file->getName(),64'mimeType' => $file->getMimeType(),65'byteSize' => $file->getByteSize(),66'authorPHID' => $file->getAuthorPHID(),67'dateCreated' => $file->getDateCreated(),68'dateModified' => $file->getDateModified(),69'uri' => PhabricatorEnv::getProductionURI($uri),70);71}7273}747576