Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / conduit / protocol / ConduitAPIRequest.php
blob78988f2b3b4fd89b6c3f8c7c2aaf933a19130458
1 <?php
3 final class ConduitAPIRequest extends Phobject {
5 protected $params;
6 private $user;
7 private $isClusterRequest = false;
8 private $oauthToken;
9 private $isStrictlyTyped = true;
11 public function __construct(array $params, $strictly_typed) {
12 $this->params = $params;
13 $this->isStrictlyTyped = $strictly_typed;
16 public function getValue($key, $default = null) {
17 return coalesce(idx($this->params, $key), $default);
20 public function getValueExists($key) {
21 return array_key_exists($key, $this->params);
24 public function getAllParameters() {
25 return $this->params;
28 public function setUser(PhabricatorUser $user) {
29 $this->user = $user;
30 return $this;
33 /**
34 * Retrieve the authentic identity of the user making the request. If a
35 * method requires authentication (the default) the user object will always
36 * be available. If a method does not require authentication (i.e., overrides
37 * shouldRequireAuthentication() to return false) the user object will NEVER
38 * be available.
40 * @return PhabricatorUser Authentic user, available ONLY if the method
41 * requires authentication.
43 public function getUser() {
44 if (!$this->user) {
45 throw new Exception(
46 pht(
47 'You can not access the user inside the implementation of a Conduit '.
48 'method which does not require authentication (as per %s).',
49 'shouldRequireAuthentication()'));
51 return $this->user;
54 public function getViewer() {
55 return $this->getUser();
58 public function setOAuthToken(
59 PhabricatorOAuthServerAccessToken $oauth_token) {
60 $this->oauthToken = $oauth_token;
61 return $this;
64 public function getOAuthToken() {
65 return $this->oauthToken;
68 public function setIsClusterRequest($is_cluster_request) {
69 $this->isClusterRequest = $is_cluster_request;
70 return $this;
73 public function getIsClusterRequest() {
74 return $this->isClusterRequest;
77 public function getIsStrictlyTyped() {
78 return $this->isStrictlyTyped;
81 public function newContentSource() {
82 return PhabricatorContentSource::newForSource(
83 PhabricatorConduitContentSource::SOURCECONST);