@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 45 lines 1.1 kB view raw
1<?php 2 3final class DiffusionDocumentController extends DiffusionController { 4 5 public function shouldAllowPublic() { 6 return true; 7 } 8 9 public function handleRequest(AphrontRequest $request) { 10 $response = $this->loadDiffusionContext(); 11 if ($response) { 12 return $response; 13 } 14 15 $drequest = $this->getDiffusionRequest(); 16 17 $engine = id(new DiffusionDocumentRenderingEngine()) 18 ->setRequest($request) 19 ->setDiffusionRequest($drequest) 20 ->setController($this); 21 22 $viewer = $this->getViewer(); 23 $request = $this->getRequest(); 24 $repository = $drequest->getRepository(); 25 26 $file_phid = $request->getStr('filePHID'); 27 28 $file = id(new PhabricatorFileQuery()) 29 ->setViewer($viewer) 30 ->withPHIDs(array($file_phid)) 31 ->executeOne(); 32 if (!$file) { 33 return $engine->newErrorResponse( 34 pht( 35 'This file ("%s") does not exist or could not be loaded.', 36 $file_phid)); 37 } 38 39 $ref = id(new PhabricatorDocumentRef()) 40 ->setFile($file); 41 42 return $engine->newRenderResponse($ref); 43 } 44 45}