Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conduit/method/ConduitAPIMethod.php
<?php | <?php | ||||
/** | /** | ||||
* @task status Method Status | * @task status Method Status | ||||
* @task pager Paging Results | * @task pager Paging Results | ||||
*/ | */ | ||||
abstract class ConduitAPIMethod | abstract class ConduitAPIMethod | ||||
extends Phobject | extends Phobject | ||||
implements PhabricatorPolicyInterface { | implements PhabricatorPolicyInterface { | ||||
const METHOD_STATUS_STABLE = 'stable'; | const METHOD_STATUS_STABLE = 'stable'; | ||||
const METHOD_STATUS_UNSTABLE = 'unstable'; | const METHOD_STATUS_UNSTABLE = 'unstable'; | ||||
const METHOD_STATUS_DEPRECATED = 'deprecated'; | const METHOD_STATUS_DEPRECATED = 'deprecated'; | ||||
abstract public function getMethodDescription(); | abstract public function getMethodDescription(); | ||||
abstract public function defineParamTypes(); | abstract protected function defineParamTypes(); | ||||
abstract public function defineReturnType(); | abstract protected function defineReturnType(); | ||||
abstract public function defineErrorTypes(); | |||||
protected function defineErrorTypes() { | |||||
return array(); | |||||
} | |||||
abstract protected function execute(ConduitAPIRequest $request); | abstract protected function execute(ConduitAPIRequest $request); | ||||
public function __construct() {} | public function __construct() {} | ||||
public function getParamTypes() { | |||||
return $this->defineParamTypes(); | |||||
} | |||||
public function getReturnType() { | |||||
return $this->defineReturnType(); | |||||
} | |||||
public function getErrorTypes() { | |||||
return $this->defineErrorTypes(); | |||||
} | |||||
/** | /** | ||||
* This is mostly for compatibility with | * This is mostly for compatibility with | ||||
* @{class:PhabricatorCursorPagedPolicyAwareQuery}. | * @{class:PhabricatorCursorPagedPolicyAwareQuery}. | ||||
*/ | */ | ||||
public function getID() { | public function getID() { | ||||
return $this->getAPIMethodName(); | return $this->getAPIMethodName(); | ||||
} | } | ||||
Show All 17 Lines | abstract class ConduitAPIMethod | ||||
* @return string|null Description of the method status, if available. | * @return string|null Description of the method status, if available. | ||||
* @task status | * @task status | ||||
*/ | */ | ||||
public function getMethodStatusDescription() { | public function getMethodStatusDescription() { | ||||
return null; | return null; | ||||
} | } | ||||
public function getErrorDescription($error_code) { | public function getErrorDescription($error_code) { | ||||
return idx($this->defineErrorTypes(), $error_code, 'Unknown Error'); | return idx($this->getErrorTypes(), $error_code, 'Unknown Error'); | ||||
} | } | ||||
public function getRequiredScope() { | public function getRequiredScope() { | ||||
// by default, conduit methods are not accessible via OAuth | // by default, conduit methods are not accessible via OAuth | ||||
return PhabricatorOAuthServerScope::SCOPE_NOT_ACCESSIBLE; | return PhabricatorOAuthServerScope::SCOPE_NOT_ACCESSIBLE; | ||||
} | } | ||||
public function executeMethod(ConduitAPIRequest $request) { | public function executeMethod(ConduitAPIRequest $request) { | ||||
▲ Show 20 Lines • Show All 244 Lines • Show Last 20 Lines |