[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/files/conduit/ -> FileInfoConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class FileInfoConduitAPIMethod extends FileConduitAPIMethod {
   4  
   5    public function getAPIMethodName() {
   6      return 'file.info';
   7    }
   8  
   9    public function getMethodDescription() {
  10      return 'Get information about a file.';
  11    }
  12  
  13    public function defineParamTypes() {
  14      return array(
  15        'phid' => 'optional phid',
  16        'id'   => 'optional id',
  17      );
  18    }
  19  
  20    public function defineReturnType() {
  21      return 'nonempty dict';
  22    }
  23  
  24    public function defineErrorTypes() {
  25      return array(
  26        'ERR-NOT-FOUND'     => 'No such file exists.',
  27      );
  28    }
  29  
  30    protected function execute(ConduitAPIRequest $request) {
  31      $phid = $request->getValue('phid');
  32      $id   = $request->getValue('id');
  33  
  34      $query = id(new PhabricatorFileQuery())
  35        ->setViewer($request->getUser());
  36      if ($id) {
  37        $query->withIDs(array($id));
  38      } else {
  39        $query->withPHIDs(array($phid));
  40      }
  41  
  42      $file = $query->executeOne();
  43  
  44      if (!$file) {
  45        throw new ConduitException('ERR-NOT-FOUND');
  46      }
  47  
  48      $uri = $file->getBestURI();
  49  
  50      return array(
  51        'id'            => $file->getID(),
  52        'phid'          => $file->getPHID(),
  53        'objectName'    => 'F'.$file->getID(),
  54        'name'          => $file->getName(),
  55        'mimeType'      => $file->getMimeType(),
  56        'byteSize'      => $file->getByteSize(),
  57        'authorPHID'    => $file->getAuthorPHID(),
  58        'dateCreated'   => $file->getDateCreated(),
  59        'dateModified'  => $file->getDateModified(),
  60        'uri'           => PhabricatorEnv::getProductionURI($uri),
  61      );
  62    }
  63  
  64  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1