Path: blob/master/src/applications/conduit/protocol/ConduitAPIRequest.php
12262 views
<?php12final class ConduitAPIRequest extends Phobject {34protected $params;5private $user;6private $isClusterRequest = false;7private $oauthToken;8private $isStrictlyTyped = true;910public function __construct(array $params, $strictly_typed) {11$this->params = $params;12$this->isStrictlyTyped = $strictly_typed;13}1415public function getValue($key, $default = null) {16return coalesce(idx($this->params, $key), $default);17}1819public function getValueExists($key) {20return array_key_exists($key, $this->params);21}2223public function getAllParameters() {24return $this->params;25}2627public function setUser(PhabricatorUser $user) {28$this->user = $user;29return $this;30}3132/**33* Retrieve the authentic identity of the user making the request. If a34* method requires authentication (the default) the user object will always35* be available. If a method does not require authentication (i.e., overrides36* shouldRequireAuthentication() to return false) the user object will NEVER37* be available.38*39* @return PhabricatorUser Authentic user, available ONLY if the method40* requires authentication.41*/42public function getUser() {43if (!$this->user) {44throw new Exception(45pht(46'You can not access the user inside the implementation of a Conduit '.47'method which does not require authentication (as per %s).',48'shouldRequireAuthentication()'));49}50return $this->user;51}5253public function getViewer() {54return $this->getUser();55}5657public function setOAuthToken(58PhabricatorOAuthServerAccessToken $oauth_token) {59$this->oauthToken = $oauth_token;60return $this;61}6263public function getOAuthToken() {64return $this->oauthToken;65}6667public function setIsClusterRequest($is_cluster_request) {68$this->isClusterRequest = $is_cluster_request;69return $this;70}7172public function getIsClusterRequest() {73return $this->isClusterRequest;74}7576public function getIsStrictlyTyped() {77return $this->isStrictlyTyped;78}7980public function newContentSource() {81return PhabricatorContentSource::newForSource(82PhabricatorConduitContentSource::SOURCECONST);83}8485}868788