OCA\Richdocuments\Storage::getDocumentById PHP Метод

getDocumentById() публичный статический Метод

public static getDocumentById ( $fileId )
    public static function getDocumentById($fileId)
    {
        $root = \OC::$server->getUserFolder();
        $ret = array();
        // If type of fileId is a string, then it
        // doesn't work for shared documents, lets cast to int everytime
        $document = $root->getById((int) $fileId)[0];
        if ($document === null) {
            error_log('File with file id, ' . $fileId . ', not found');
            return $ret;
        }
        $ret['mimetype'] = $document->getMimeType();
        $ret['path'] = $root->getRelativePath($document->getPath());
        $ret['name'] = $document->getName();
        $ret['fileid'] = $fileId;
        return $ret;
    }

Usage Example

Пример #1
0
 /**
  * @NoAdminRequired
  * Get file information about single document with fileId
  */
 public function get($fileId)
 {
     $documents = array();
     $documents[0] = Storage::getDocumentById($fileId);
     return $this->prepareDocuments($documents);
 }