1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-13 10:22:42 +01:00
phorge-phorge/src/applications/conduit/method/ConduitQueryConduitAPIMethod.php
epriestley 12dd9ec3ff Have EditEngine API methods provide the correct application to Conduit
Summary:
Fixes T9799. Currently, if you can't see an application like Paste, we fatal when trying to generate a result for `conduit.query`, because the new EditEngine-based `paste.edit` method doesn't "know" that it's a "Paste" method.

Straighten this out, and use policies and queries a little more correctly/consistently.

Test Plan:
  - Called `conduit.query` as a user who does not have permission to use Paste.
  - Before change: fatal.
  - After change: results, excluding "paste.*" methods.

Reviewers: chad

Reviewed By: chad

Subscribers: cburroughs

Maniphest Tasks: T9799

Differential Revision: https://secure.phabricator.com/D14492
2015-11-16 10:02:50 -08:00

38 lines
869 B
PHP

<?php
final class ConduitQueryConduitAPIMethod extends ConduitAPIMethod {
public function getAPIMethodName() {
return 'conduit.query';
}
public function getMethodDescription() {
return pht('Returns the parameters of the Conduit methods.');
}
protected function defineParamTypes() {
return array();
}
protected function defineReturnType() {
return 'dict<dict>';
}
protected function execute(ConduitAPIRequest $request) {
$methods = id(new PhabricatorConduitMethodQuery())
->setViewer($request->getUser())
->execute();
$map = array();
foreach ($methods as $method) {
$map[$method->getAPIMethodName()] = array(
'description' => $method->getMethodDescription(),
'params' => $method->getParamTypes(),
'return' => $method->getReturnType(),
);
}
return $map;
}
}