本文整理汇总了PHP中ConduitAPIRequest::getUser方法的典型用法代码示例。如果您正苦于以下问题:PHP ConduitAPIRequest::getUser方法的具体用法?PHP ConduitAPIRequest::getUser怎么用?PHP ConduitAPIRequest::getUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConduitAPIRequest
的用法示例。
在下文中一共展示了ConduitAPIRequest::getUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(ConduitAPIRequest $request)
{
$paths = $request->getValue('paths');
$fragments = id(new PhragmentFragmentQuery())->setViewer($request->getUser())->withPaths($paths)->execute();
$fragments = mpull($fragments, null, 'getPath');
foreach ($paths as $path) {
if (!array_key_exists($path, $fragments)) {
throw new ConduitException('ERR_BAD_FRAGMENT');
}
}
$results = array();
foreach ($fragments as $path => $fragment) {
$mappings = $fragment->getFragmentMappings($request->getUser(), $fragment->getPath());
$file_phids = mpull(mpull($mappings, 'getLatestVersion'), 'getFilePHID');
$files = id(new PhabricatorFileQuery())->setViewer($request->getUser())->withPHIDs($file_phids)->execute();
$files = mpull($files, null, 'getPHID');
$result = array();
foreach ($mappings as $cpath => $child) {
$file_phid = $child->getLatestVersion()->getFilePHID();
if (!isset($files[$file_phid])) {
// Skip any files we don't have permission to access.
continue;
}
$file = $files[$file_phid];
$cpath = substr($child->getPath(), strlen($fragment->getPath()) + 1);
$result[] = array('phid' => $child->getPHID(), 'phidVersion' => $child->getLatestVersionPHID(), 'path' => $cpath, 'hash' => $file->getContentHash(), 'version' => $child->getLatestVersion()->getSequence(), 'uri' => $file->getViewURI());
}
$results[$path] = $result;
}
return $results;
}
示例2: execute
protected function execute(ConduitAPIRequest $request)
{
$user = $request->getUser()->getPHID();
$phid = $request->getValue('objectPHID');
$new = false;
$flag = id(new PhabricatorFlag())->loadOneWhere('objectPHID = %s AND ownerPHID = %s', $phid, $user);
if ($flag) {
$params = $request->getAllParameters();
if (isset($params['color'])) {
$flag->setColor($params['color']);
}
if (isset($params['note'])) {
$flag->setNote($params['note']);
}
} else {
$default_color = PhabricatorFlagColor::COLOR_BLUE;
$flag = id(new PhabricatorFlag())->setOwnerPHID($user)->setType(phid_get_type($phid))->setObjectPHID($phid)->setReasonPHID($user)->setColor($request->getValue('color', $default_color))->setNote($request->getValue('note', ''));
$new = true;
}
$this->attachHandleToFlag($flag, $request->getUser());
$flag->save();
$ret = $this->buildFlagInfoDictionary($flag);
$ret['new'] = $new;
return $ret;
}
示例3: execute
protected function execute(ConduitAPIRequest $request)
{
$commit_phid = $request->getValue('phid');
$commit = id(new DiffusionCommitQuery())->setViewer($request->getUser())->withPHIDs(array($commit_phid))->needAuditRequests(true)->executeOne();
if (!$commit) {
throw new ConduitException('ERR_BAD_COMMIT');
}
$message = trim($request->getValue('message'));
if (!$message) {
throw new ConduitException('ERR_MISSING_MESSAGE');
}
$action = $request->getValue('action');
if (!$action) {
$action = PhabricatorAuditActionConstants::COMMENT;
}
// Disallow ADD_CCS, ADD_AUDITORS forever.
if (!in_array($action, array(PhabricatorAuditActionConstants::CONCERN, PhabricatorAuditActionConstants::ACCEPT, PhabricatorAuditActionConstants::COMMENT, PhabricatorAuditActionConstants::RESIGN, PhabricatorAuditActionConstants::CLOSE))) {
throw new ConduitException('ERR_BAD_ACTION');
}
$xactions = array();
if ($action != PhabricatorAuditActionConstants::COMMENT) {
$xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorAuditActionConstants::ACTION)->setNewValue($action);
}
if (strlen($message)) {
$xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)->attachComment(id(new PhabricatorAuditTransactionComment())->setCommitPHID($commit->getPHID())->setContent($message));
}
id(new PhabricatorAuditEditor())->setActor($request->getUser())->setContentSource($request->newContentSource())->setDisableEmail($request->getValue('silent'))->setContinueOnMissingFields(true)->applyTransactions($commit, $xactions);
return true;
}
示例4: execute
protected function execute(ConduitAPIRequest $request)
{
$results = array();
$task_ids = $request->getValue('ids');
if (!$task_ids) {
return $results;
}
$tasks = id(new ManiphestTaskQuery())->setViewer($request->getUser())->withIDs($task_ids)->execute();
$tasks = mpull($tasks, null, 'getPHID');
$transactions = array();
if ($tasks) {
$transactions = id(new ManiphestTransactionQuery())->setViewer($request->getUser())->withObjectPHIDs(mpull($tasks, 'getPHID'))->needComments(true)->execute();
}
foreach ($transactions as $transaction) {
$task_phid = $transaction->getObjectPHID();
if (empty($tasks[$task_phid])) {
continue;
}
$task_id = $tasks[$task_phid]->getID();
$comments = null;
if ($transaction->hasComment()) {
$comments = $transaction->getComment()->getContent();
}
$results[$task_id][] = array('taskID' => $task_id, 'transactionPHID' => $transaction->getPHID(), 'transactionType' => $transaction->getTransactionType(), 'oldValue' => $transaction->getOldValue(), 'newValue' => $transaction->getNewValue(), 'comments' => $comments, 'authorPHID' => $transaction->getAuthorPHID(), 'dateCreated' => $transaction->getDateCreated());
}
return $results;
}
示例5: execute
protected function execute(ConduitAPIRequest $request)
{
$id = $request->getValue('id');
$object = $request->getValue('objectPHID');
if ($id) {
$flag = id(new PhabricatorFlag())->load($id);
if (!$flag) {
throw new ConduitException('ERR_NOT_FOUND');
}
if ($flag->getOwnerPHID() != $request->getUser()->getPHID()) {
throw new ConduitException('ERR_WRONG_USER');
}
} else {
if ($object) {
$flag = id(new PhabricatorFlag())->loadOneWhere('objectPHID = %s AND ownerPHID = %s', $object, $request->getUser()->getPHID());
if (!$flag) {
return null;
}
} else {
throw new ConduitException('ERR_NEED_PARAM');
}
}
$this->attachHandleToFlag($flag, $request->getUser());
$ret = $this->buildFlagInfoDictionary($flag);
$flag->delete();
return $ret;
}
示例6: execute
protected function execute(ConduitAPIRequest $request)
{
$need_messages = $request->getValue('needMessages');
$bypass_cache = $request->getValue('bypassCache');
$query = id(new DiffusionCommitQuery())->setViewer($request->getUser())->needCommitData(true);
$repository_phid = $request->getValue('repositoryPHID');
if ($repository_phid) {
$repository = id(new PhabricatorRepositoryQuery())->setViewer($request->getUser())->withPHIDs(array($repository_phid))->executeOne();
if ($repository) {
$query->withRepository($repository);
}
}
$names = $request->getValue('names');
if ($names) {
$query->withIdentifiers($names);
}
$ids = $request->getValue('ids');
if ($ids) {
$query->withIDs($ids);
}
$phids = $request->getValue('phids');
if ($phids) {
$query->withPHIDs($phids);
}
$pager = $this->newPager($request);
$commits = $query->executeWithCursorPager($pager);
$map = $query->getIdentifierMap();
$map = mpull($map, 'getPHID');
$data = array();
foreach ($commits as $commit) {
$commit_data = $commit->getCommitData();
$callsign = $commit->getRepository()->getCallsign();
$identifier = $commit->getCommitIdentifier();
$uri = '/r' . $callsign . $identifier;
$uri = PhabricatorEnv::getProductionURI($uri);
$dict = array('id' => $commit->getID(), 'phid' => $commit->getPHID(), 'repositoryPHID' => $commit->getRepository()->getPHID(), 'identifier' => $identifier, 'epoch' => $commit->getEpoch(), 'uri' => $uri, 'isImporting' => !$commit->isImported(), 'summary' => $commit->getSummary(), 'authorPHID' => $commit->getAuthorPHID(), 'committerPHID' => $commit_data->getCommitDetail('committerPHID'), 'author' => $commit_data->getAuthorName(), 'authorName' => $commit_data->getCommitDetail('authorName'), 'authorEmail' => $commit_data->getCommitDetail('authorEmail'), 'committer' => $commit_data->getCommitDetail('committer'), 'committerName' => $commit_data->getCommitDetail('committerName'), 'committerEmail' => $commit_data->getCommitDetail('committerEmail'), 'hashes' => array());
if ($bypass_cache) {
$lowlevel_commitref = id(new DiffusionLowLevelCommitQuery())->setRepository($commit->getRepository())->withIdentifier($commit->getCommitIdentifier())->execute();
$dict['author'] = $lowlevel_commitref->getAuthor();
$dict['authorName'] = $lowlevel_commitref->getAuthorName();
$dict['authorEmail'] = $lowlevel_commitref->getAuthorEmail();
$dict['committer'] = $lowlevel_commitref->getCommitter();
$dict['committerName'] = $lowlevel_commitref->getCommitterName();
$dict['committerEmail'] = $lowlevel_commitref->getCommitterEmail();
if ($need_messages) {
$dict['message'] = $lowlevel_commitref->getMessage();
}
foreach ($lowlevel_commitref->getHashes() as $hash) {
$dict['hashes'][] = array('type' => $hash->getHashType(), 'value' => $hash->getHashValue());
}
}
if ($need_messages && !$bypass_cache) {
$dict['message'] = $commit_data->getCommitMessage();
}
$data[$commit->getPHID()] = $dict;
}
$result = array('data' => $data, 'identifierMap' => nonempty($map, (object) array()));
return $this->addPagerResults($result, $pager);
}
示例7: execute
protected function execute(ConduitAPIRequest $request)
{
$diff_id = $request->getValue('diffID');
$linter_map = $request->getValue('linters');
$diff = id(new DifferentialDiffQuery())->setViewer($request->getUser())->withIDs(array($diff_id))->executeOne();
if (!$diff) {
throw new ConduitException('ERR-BAD-DIFF');
}
// Extract the finished linters and messages from the linter map.
$finished_linters = array_keys($linter_map);
$new_messages = array();
foreach ($linter_map as $linter => $messages) {
$new_messages = array_merge($new_messages, $messages);
}
// Load the postponed linters attached to this diff.
$postponed_linters_property = id(new DifferentialDiffProperty())->loadOneWhere('diffID = %d AND name = %s', $diff_id, 'arc:lint-postponed');
if ($postponed_linters_property) {
$postponed_linters = $postponed_linters_property->getData();
} else {
$postponed_linters = array();
}
foreach ($finished_linters as $linter) {
if (!in_array($linter, $postponed_linters)) {
throw new ConduitException('ERR-BAD-LINTER');
}
}
foreach ($postponed_linters as $idx => $linter) {
if (in_array($linter, $finished_linters)) {
unset($postponed_linters[$idx]);
}
}
// Load the lint messages currenty attached to the diff. If this
// diff property doesn't exist, create it.
$messages_property = id(new DifferentialDiffProperty())->loadOneWhere('diffID = %d AND name = %s', $diff_id, 'arc:lint');
if ($messages_property) {
$messages = $messages_property->getData();
} else {
$messages = array();
}
// Add new lint messages, removing duplicates.
foreach ($new_messages as $new_message) {
if (!in_array($new_message, $messages)) {
$messages[] = $new_message;
}
}
// Use setdiffproperty to update the postponed linters and messages,
// as these will also update the lint status correctly.
$call = new ConduitCall('differential.setdiffproperty', array('diff_id' => $diff_id, 'name' => 'arc:lint', 'data' => json_encode($messages)));
$call->setForceLocal(true);
$call->setUser($request->getUser());
$call->execute();
$call = new ConduitCall('differential.setdiffproperty', array('diff_id' => $diff_id, 'name' => 'arc:lint-postponed', 'data' => json_encode($postponed_linters)));
$call->setForceLocal(true);
$call->setUser($request->getUser());
$call->execute();
}
示例8: execute
protected function execute(ConduitAPIRequest $request)
{
$slug = $request->getValue('slug');
$doc = id(new PhrictionDocumentQuery())->setViewer($request->getUser())->withSlugs(array(PhabricatorSlug::normalize($slug)))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
if (!$doc) {
throw new Exception(pht('No such document.'));
}
$editor = id(PhrictionDocumentEditor::newForSlug($slug))->setActor($request->getUser())->setTitle($request->getValue('title'))->setContent($request->getValue('content'))->setDescription($request->getvalue('description'))->save();
return $this->buildDocumentInfoDictionary($editor->getDocument());
}
示例9: execute
protected function execute(ConduitAPIRequest $request)
{
$branch = id(new ReleephBranchQuery())->setViewer($request->getUser())->withPHIDs(array($request->getValue('branchPHID')))->needCutPointCommits(true)->executeOne();
$cut_phid = $branch->getCutPointCommitPHID();
$phids = array($cut_phid);
$handles = id(new PhabricatorHandleQuery())->setViewer($request->getUser())->withPHIDs($phids)->execute();
$project = $branch->getProject();
$repo = $project->getRepository();
$commit = $branch->getCutPointCommit();
return array('branchName' => $branch->getName(), 'branchPHID' => $branch->getPHID(), 'vcsType' => $repo->getVersionControlSystem(), 'cutCommitID' => $commit->getCommitIdentifier(), 'cutCommitName' => $handles[$cut_phid]->getName(), 'creatorPHID' => $branch->getCreatedByUserPHID(), 'trunk' => $project->getTrunkBranch());
}
示例10: execute
protected function execute(ConduitAPIRequest $request)
{
$rid = $request->getValue('revisionID');
$did = $request->getValue('diffID');
if ($rid) {
// Given both a revision and a diff, check that they match.
// Given only a revision, find the active diff.
$revision = id(new DifferentialRevisionQuery())->setViewer($request->getUser())->withIDs(array($rid))->executeOne();
if (!$revision) {
throw new ConduitException('ERR-BAD-REVISION');
}
if (!$did) {
// did not!
$diff = $revision->loadActiveDiff();
$did = $diff->getID();
} else {
// did too!
$diff = id(new DifferentialDiff())->load($did);
if (!$diff || $diff->getRevisionID() != $rid) {
throw new ConduitException('ERR-BAD-DIFF');
}
}
} else {
if ($did) {
// Given only a diff, find the parent revision.
$diff = id(new DifferentialDiff())->load($did);
if (!$diff) {
throw new ConduitException('ERR-BAD-DIFF');
}
$rid = $diff->getRevisionID();
} else {
// Given neither, bail.
throw new ConduitException('ERR-NEED-DIFF');
}
}
$file = $request->getValue('filePath');
if (!$file) {
throw new ConduitException('ERR-NEED-FILE');
}
$changes = id(new DifferentialChangeset())->loadAllWhere('diffID = %d', $did);
$cid = null;
foreach ($changes as $id => $change) {
if ($file == $change->getFilename()) {
$cid = $id;
}
}
if ($cid == null) {
throw new ConduitException('ERR-BAD-FILE');
}
$inline = id(new DifferentialInlineComment())->setRevisionID($rid)->setChangesetID($cid)->setAuthorPHID($request->getUser()->getPHID())->setContent($request->getValue('content'))->setIsNewFile($request->getValue('isNewFile'))->setLineNumber($request->getValue('lineNumber'))->setLineLength($request->getValue('lineLength', 0))->save();
// Load everything again, just to be safe.
$changeset = id(new DifferentialChangeset())->load($inline->getChangesetID());
return $this->buildInlineInfoDictionary($inline, $changeset);
}
示例11: execute
protected function execute(ConduitAPIRequest $request)
{
$drequest = DiffusionRequest::newFromDictionary(array('user' => $request->getUser(), 'callsign' => $request->getValue('callsign'), 'path' => $request->getValue('path'), 'branch' => $request->getValue('branch')));
$limit = nonempty($request->getValue('limit'), self::DEFAULT_LIMIT);
$history_result = DiffusionQuery::callConduitWithDiffusionRequest($request->getUser(), $drequest, 'diffusion.historyquery', array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath(), 'offset' => 0, 'limit' => $limit, 'needDirectChanges' => true, 'needChildChanges' => true));
$history = DiffusionPathChange::newFromConduit($history_result['pathChanges']);
$raw_commit_identifiers = mpull($history, 'getCommitIdentifier');
$result = array();
foreach ($raw_commit_identifiers as $id) {
$result[] = 'r' . $request->getValue('callsign') . $id;
}
return $result;
}
示例12: execute
protected function execute(ConduitAPIRequest $request)
{
$names = $request->getValue('names');
$query = id(new PhabricatorObjectQuery())->setViewer($request->getUser())->withNames($names);
$query->execute();
$name_map = $query->getNamedResults();
$handles = id(new PhabricatorHandleQuery())->setViewer($request->getUser())->withPHIDs(mpull($name_map, 'getPHID'))->execute();
$result = array();
foreach ($name_map as $name => $object) {
$phid = $object->getPHID();
$handle = $handles[$phid];
$result[$name] = $this->buildHandleInformationDictionary($handle);
}
return $result;
}
示例13: execute
protected function execute(ConduitAPIRequest $request)
{
$viewer = $request->getUser();
$query = id(new ReleephBranchQuery())->setViewer($viewer);
$ids = $request->getValue('ids');
if ($ids !== null) {
$query->withIDs($ids);
}
$phids = $request->getValue('phids');
if ($phids !== null) {
$query->withPHIDs($phids);
}
$product_phids = $request->getValue('productPHIDs');
if ($product_phids !== null) {
$query->withProductPHIDs($product_phids);
}
$pager = $this->newPager($request);
$branches = $query->executeWithCursorPager($pager);
$data = array();
foreach ($branches as $branch) {
$id = $branch->getID();
$uri = '/releeph/branch/' . $id . '/';
$uri = PhabricatorEnv::getProductionURI($uri);
$data[] = array('id' => $id, 'phid' => $branch->getPHID(), 'uri' => $uri, 'name' => $branch->getName(), 'productPHID' => $branch->getProduct()->getPHID());
}
return $this->addPagerResults(array('data' => $data), $pager);
}
示例14: execute
protected function execute(ConduitAPIRequest $request)
{
$query = id(new DiffusionCommitQuery())->setViewer($request->getUser())->needAuditRequests(true);
$auditor_phids = $request->getValue('auditorPHIDs', array());
if ($auditor_phids) {
$query->withAuditorPHIDs($auditor_phids);
}
$commit_phids = $request->getValue('commitPHIDs', array());
if ($commit_phids) {
$query->withPHIDs($commit_phids);
}
$status = $request->getValue('status', DiffusionCommitQuery::AUDIT_STATUS_ANY);
$query->withAuditStatus($status);
// NOTE: These affect the number of commits identified, which is sort of
// reasonable but means the method may return an arbitrary number of
// actual audit requests.
$query->setOffset($request->getValue('offset', 0));
$query->setLimit($request->getValue('limit', 100));
$commits = $query->execute();
$auditor_map = array_fuse($auditor_phids);
$results = array();
foreach ($commits as $commit) {
$requests = $commit->getAudits();
foreach ($requests as $request) {
// If this audit isn't triggered for one of the requested PHIDs,
// skip it.
if ($auditor_map && empty($auditor_map[$request->getAuditorPHID()])) {
continue;
}
$results[] = array('id' => $request->getID(), 'commitPHID' => $request->getCommitPHID(), 'auditorPHID' => $request->getAuditorPHID(), 'reasons' => $request->getAuditReasons(), 'status' => $request->getAuditStatus());
}
}
return $results;
}
示例15: execute
protected function execute(ConduitAPIRequest $request)
{
$diff = id(new DifferentialDiff())->load($request->getValue('diffid'));
if (!$diff) {
throw new ConduitException('ERR_BAD_DIFF');
}
$revision = id(new DifferentialRevision())->load($request->getValue('id'));
if (!$revision) {
throw new ConduitException('ERR_BAD_REVISION');
}
if ($request->getUser()->getPHID() !== $revision->getAuthorPHID()) {
throw new ConduitException('ERR_WRONG_USER');
}
if ($revision->getStatus() == ArcanistDifferentialRevisionStatus::CLOSED) {
throw new ConduitException('ERR_CLOSED');
}
$content_source = PhabricatorContentSource::newForSource(PhabricatorContentSource::SOURCE_CONDUIT, array());
$editor = new DifferentialRevisionEditor($revision, $revision->getAuthorPHID());
$editor->setContentSource($content_source);
$fields = $request->getValue('fields');
$editor->copyFieldsFromConduit($fields);
$editor->addDiff($diff, $request->getValue('message'));
$editor->save();
return array('revisionid' => $revision->getID(), 'uri' => PhabricatorEnv::getURI('/D' . $revision->getID()));
}