Differential D19302 Diff 46190 src/applications/files/controller/PhabricatorFileDocumentController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/controller/PhabricatorFileDocumentController.php
<?php | <?php | ||||
final class PhabricatorFileDocumentController | final class PhabricatorFileDocumentController | ||||
extends PhabricatorFileController { | extends PhabricatorFileController { | ||||
public function shouldAllowPublic() { | public function shouldAllowPublic() { | ||||
return true; | return true; | ||||
} | } | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$engine = id(new PhabricatorFileDocumentRenderingEngine()) | |||||
->setRequest($request) | |||||
->setController($this); | |||||
$viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
$file_phid = $request->getURIData('phid'); | $file_phid = $request->getURIData('phid'); | ||||
$file = id(new PhabricatorFileQuery()) | $file = id(new PhabricatorFileQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withPHIDs(array($file_phid)) | ->withPHIDs(array($file_phid)) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$file) { | if (!$file) { | ||||
return $this->newErrorResponse( | return $engine->newErrorResponse( | ||||
pht( | pht( | ||||
'This file ("%s") does not exist or could not be loaded.', | 'This file ("%s") does not exist or could not be loaded.', | ||||
$file_phid)); | $file_phid)); | ||||
} | } | ||||
$ref = id(new PhabricatorDocumentRef()) | $ref = id(new PhabricatorDocumentRef()) | ||||
->setFile($file); | ->setFile($file); | ||||
return id(new PhabricatorFileDocumentRenderingEngine()) | return $engine->newRenderResponse($ref); | ||||
->setRequest($request) | |||||
->setController($this) | |||||
->newRenderResponse($ref); | |||||
} | } | ||||
} | } |