@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
1<?php
2
3final class PasteInfoConduitAPIMethod extends PasteConduitAPIMethod {
4
5 public function getAPIMethodName() {
6 return 'paste.info';
7 }
8
9 public function getMethodStatus() {
10 return self::METHOD_STATUS_DEPRECATED;
11 }
12
13 public function getMethodStatusDescription() {
14 return pht(
15 'This method has been deprecated since %s in favor of %s.',
16 '08/2012',
17 'paste.query');
18 }
19
20 public function getMethodDescription() {
21 return pht('Retrieve an array of information about a paste.');
22 }
23
24 protected function defineParamTypes() {
25 return array(
26 'paste_id' => 'required id',
27 );
28 }
29
30 protected function defineReturnType() {
31 return 'nonempty dict';
32 }
33
34 protected function defineErrorTypes() {
35 return array(
36 'ERR_BAD_PASTE' => pht('No such paste exists.'),
37 );
38 }
39
40 protected function execute(ConduitAPIRequest $request) {
41 $paste_id = $request->getValue('paste_id');
42 $paste = id(new PhabricatorPasteQuery())
43 ->setViewer($request->getUser())
44 ->withIDs(array($paste_id))
45 ->needRawContent(true)
46 ->executeOne();
47 if (!$paste) {
48 throw new ConduitException('ERR_BAD_PASTE');
49 }
50 return $this->buildPasteInfoDictionary($paste);
51 }
52
53}