Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conduit/call/ConduitCall.php
| Show All 12 Lines | final class ConduitCall { | ||||
| private $method; | private $method; | ||||
| private $request; | private $request; | ||||
| private $user; | private $user; | ||||
| public function __construct($method, array $params) { | public function __construct($method, array $params) { | ||||
| $this->method = $method; | $this->method = $method; | ||||
| $this->handler = $this->buildMethodHandler($method); | $this->handler = $this->buildMethodHandler($method); | ||||
| $invalid_params = array_diff_key( | $param_types = $this->handler->defineParamTypes(); | ||||
| $params, | |||||
| $this->handler->defineParamTypes()); | foreach ($param_types as $key => $spec) { | ||||
| if (ConduitAPIMethod::getParameterMetadataKey($key) !== null) { | |||||
| throw new ConduitException( | |||||
| pht( | |||||
| 'API Method "%s" defines a disallowed parameter, "%s". This '. | |||||
| 'parameter name is reserved.', | |||||
| $method, | |||||
| $key)); | |||||
| } | |||||
| } | |||||
| $invalid_params = array_diff_key($params, $param_types); | |||||
| if ($invalid_params) { | if ($invalid_params) { | ||||
| throw new ConduitException( | throw new ConduitException( | ||||
| "Method '{$method}' doesn't define these parameters: '". | pht( | ||||
| implode("', '", array_keys($invalid_params))."'."); | 'API Method "%s" does not define these parameters: %s.', | ||||
| $method, | |||||
| "'".implode("', '", array_keys($invalid_params))."'")); | |||||
| } | } | ||||
| $this->request = new ConduitAPIRequest($params); | $this->request = new ConduitAPIRequest($params); | ||||
| } | } | ||||
| public function setUser(PhabricatorUser $user) { | public function setUser(PhabricatorUser $user) { | ||||
| $this->user = $user; | $this->user = $user; | ||||
| return $this; | return $this; | ||||
| ▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines | |||||