mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Give ConduitAPIMethod->getMethodDescription() access to a real Viewer
Summary: Ref T9964. The new `*.search` and `*.edit` methods generate documentation which depends on the viewer. For example, the `*.search` methods show a reference table of the keys for all your saved queries. Give them a real viewer to work with. During normal execution, just populate this viewer with the request's viewer, so `$request->getViewer()` and `$this->getViewer()` both work and mean the same thing. Test Plan: {F1023780} Reviewers: chad Reviewed By: chad Maniphest Tasks: T9964 Differential Revision: https://secure.phabricator.com/D14761
This commit is contained in:
parent
f3b57990bf
commit
d1a1d48001
4 changed files with 18 additions and 7 deletions
|
@ -19,6 +19,8 @@ final class PhabricatorConduitConsoleController
|
|||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$method->setViewer($viewer);
|
||||
|
||||
$call_uri = '/api/'.$method->getAPIMethodName();
|
||||
|
||||
$status = $method->getMethodStatus();
|
||||
|
|
|
@ -9,6 +9,7 @@ abstract class ConduitAPIMethod
|
|||
extends Phobject
|
||||
implements PhabricatorPolicyInterface {
|
||||
|
||||
private $viewer;
|
||||
|
||||
const METHOD_STATUS_STABLE = 'stable';
|
||||
const METHOD_STATUS_UNSTABLE = 'unstable';
|
||||
|
@ -46,8 +47,6 @@ abstract class ConduitAPIMethod
|
|||
abstract protected function execute(ConduitAPIRequest $request);
|
||||
|
||||
|
||||
public function __construct() {}
|
||||
|
||||
public function getParamTypes() {
|
||||
$types = $this->defineParamTypes();
|
||||
|
||||
|
@ -110,6 +109,8 @@ abstract class ConduitAPIMethod
|
|||
}
|
||||
|
||||
public function executeMethod(ConduitAPIRequest $request) {
|
||||
$this->setViewer($request->getUser());
|
||||
|
||||
return $this->execute($request);
|
||||
}
|
||||
|
||||
|
@ -211,6 +212,15 @@ abstract class ConduitAPIMethod
|
|||
return null;
|
||||
}
|
||||
|
||||
final public function setViewer(PhabricatorUser $viewer) {
|
||||
$this->viewer = $viewer;
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function getViewer() {
|
||||
return $this->viewer;
|
||||
}
|
||||
|
||||
/* -( Paging Results )----------------------------------------------------- */
|
||||
|
||||
|
||||
|
|
|
@ -39,8 +39,7 @@ abstract class PhabricatorSearchEngineAPIMethod
|
|||
}
|
||||
|
||||
final public function getMethodDescription() {
|
||||
// TODO: We don't currently have a real viewer in this method.
|
||||
$viewer = PhabricatorUser::getOmnipotentUser();
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$engine = $this->newSearchEngine()
|
||||
->setViewer($viewer);
|
||||
|
@ -76,7 +75,8 @@ it like this:
|
|||
}
|
||||
```
|
||||
|
||||
These builtin and saved queries are available:
|
||||
You can use these keys to select builtin queries and your configured saved
|
||||
queries:
|
||||
EOTEXT
|
||||
);
|
||||
|
||||
|
|
|
@ -38,8 +38,7 @@ abstract class PhabricatorEditEngineAPIMethod
|
|||
}
|
||||
|
||||
final public function getMethodDescription() {
|
||||
// TODO: We don't currently have a real viewer in this method.
|
||||
$viewer = PhabricatorUser::getOmnipotentUser();
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$engine = $this->newEditEngine()
|
||||
->setViewer($viewer);
|
||||
|
|
Loading…
Reference in a new issue