Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/paste/controller/PhabricatorPasteRawController.php
12242 views
1
<?php
2
3
/**
4
* Redirect to the current raw contents of a Paste.
5
*
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 {
11
12
public function shouldAllowPublic() {
13
return true;
14
}
15
16
public function handleRequest(AphrontRequest $request) {
17
$viewer = $request->getViewer();
18
$id = $request->getURIData('id');
19
20
$paste = id(new PhabricatorPasteQuery())
21
->setViewer($viewer)
22
->withIDs(array($id))
23
->executeOne();
24
if (!$paste) {
25
return new Aphront404Response();
26
}
27
28
$file = id(new PhabricatorFileQuery())
29
->setViewer($viewer)
30
->withPHIDs(array($paste->getFilePHID()))
31
->executeOne();
32
if (!$file) {
33
return new Aphront400Response();
34
}
35
36
return $file->getRedirectResponse();
37
}
38
39
}
40
41