Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / paste / controller / PhabricatorPasteRawController.php
blob080c5dc8b5455846b5d0776bb1a2cb90765283fb
1 <?php
3 /**
4 * Redirect to the current raw contents of a Paste.
6 * This controller provides a stable URI for getting the current contents of
7 * a paste, and slightly simplifies the view controller.
8 */
9 final class PhabricatorPasteRawController
10 extends PhabricatorPasteController {
12 public function shouldAllowPublic() {
13 return true;
16 public function handleRequest(AphrontRequest $request) {
17 $viewer = $request->getViewer();
18 $id = $request->getURIData('id');
20 $paste = id(new PhabricatorPasteQuery())
21 ->setViewer($viewer)
22 ->withIDs(array($id))
23 ->executeOne();
24 if (!$paste) {
25 return new Aphront404Response();
28 $file = id(new PhabricatorFileQuery())
29 ->setViewer($viewer)
30 ->withPHIDs(array($paste->getFilePHID()))
31 ->executeOne();
32 if (!$file) {
33 return new Aphront400Response();
36 return $file->getRedirectResponse();