本文整理汇总了PHP中DiffusionRequest::newFromDictionary方法的典型用法代码示例。如果您正苦于以下问题:PHP DiffusionRequest::newFromDictionary方法的具体用法?PHP DiffusionRequest::newFromDictionary怎么用?PHP DiffusionRequest::newFromDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DiffusionRequest
的用法示例。
在下文中一共展示了DiffusionRequest::newFromDictionary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processRequest
public function processRequest()
{
$request = $this->getRequest();
$repository_phid = $request->getStr('repositoryPHID');
$repository = id(new PhabricatorRepository())->loadOneWhere('phid = %s', $repository_phid);
if (!$repository) {
return new Aphront400Response();
}
$query_path = $request->getStr('q');
if (preg_match('@/$@', $query_path)) {
$query_dir = $query_path;
} else {
$query_dir = dirname($query_path) . '/';
}
$query_dir = ltrim($query_dir, '/');
$drequest = DiffusionRequest::newFromDictionary(array('repository' => $repository, 'path' => $query_dir));
$browse_query = DiffusionBrowseQuery::newFromDiffusionRequest($drequest);
$paths = $browse_query->loadPaths();
$output = array();
foreach ($paths as $path) {
$full_path = $query_dir . $path->getPath();
if ($path->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
$full_path .= '/';
}
$output[] = array('/' . $full_path, null, substr(md5($full_path), 0, 7));
}
return id(new AphrontAjaxResponse())->setContent($output);
}
示例2: willProcessRequest
public function willProcessRequest(array $data)
{
// This controller doesn't use blob/path stuff, just pass the dictionary
// in directly instead of using the AphrontRequest parsing mechanism.
$drequest = DiffusionRequest::newFromDictionary($data);
$this->diffusionRequest = $drequest;
}
示例3: processDiffusionRequest
protected function processDiffusionRequest(AphrontRequest $request)
{
$repository_phid = $request->getStr('repositoryPHID');
$repository = id(new PhabricatorRepositoryQuery())->setViewer($request->getUser())->withPHIDs(array($repository_phid))->executeOne();
if (!$repository) {
return new Aphront400Response();
}
$query_path = $request->getStr('q');
if (preg_match('@/$@', $query_path)) {
$query_dir = $query_path;
} else {
$query_dir = dirname($query_path) . '/';
}
$query_dir = ltrim($query_dir, '/');
$drequest = DiffusionRequest::newFromDictionary(array('user' => $request->getUser(), 'repository' => $repository, 'path' => $query_dir));
$this->setDiffusionRequest($drequest);
$browse_results = DiffusionBrowseResultSet::newFromConduit($this->callConduitWithDiffusionRequest('diffusion.browsequery', array('path' => $drequest->getPath(), 'commit' => $drequest->getCommit())));
$paths = $browse_results->getPaths();
$output = array();
foreach ($paths as $path) {
$full_path = $query_dir . $path->getPath();
if ($path->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
$full_path .= '/';
}
$output[] = array('/' . $full_path, null, substr(md5($full_path), 0, 7));
}
return id(new AphrontAjaxResponse())->setContent($output);
}
示例4: loadDiffusionChangesForCommit
private static function loadDiffusionChangesForCommit($commit)
{
$repository = id(new PhabricatorRepository())->load($commit->getRepositoryID());
$data = array('user' => PhabricatorUser::getOmnipotentUser(), 'initFromConduit' => false, 'repository' => $repository, 'commit' => $commit->getCommitIdentifier());
$drequest = DiffusionRequest::newFromDictionary($data);
$change_query = DiffusionPathChangeQuery::newFromDiffusionRequest($drequest);
return $change_query->loadChanges();
}
示例5: getURI
public function getURI()
{
if ($this->isExternal) {
return $this->externalURI;
}
$request = DiffusionRequest::newFromDictionary(array('user' => PhabricatorUser::getOmnipotentUser(), 'repository' => $this->getRepository()));
return $request->generateURI(array('action' => 'browse', 'path' => $this->getPath(), 'line' => $this->getLineNumber()));
}
示例6: parseCommit
protected final function parseCommit(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit)
{
$viewer = PhabricatorUser::getOmnipotentUser();
$refs_raw = DiffusionQuery::callConduitWithDiffusionRequest($viewer, DiffusionRequest::newFromDictionary(array('repository' => $repository, 'user' => $viewer)), 'diffusion.querycommits', array('repositoryPHID' => $repository->getPHID(), 'phids' => array($commit->getPHID()), 'bypassCache' => true, 'needMessages' => true));
if (empty($refs_raw['data'])) {
throw new Exception(pht('Unable to retrieve details for commit "%s"!', $commit->getPHID()));
}
$ref = DiffusionCommitRef::newFromConduitResult(head($refs_raw['data']));
$this->parseCommitWithRef($repository, $commit, $ref);
}
示例7: fromPartial
public function fromPartial($partial_string)
{
$this->objectPHID = null;
// Look for diffs
$matches = array();
if (preg_match('/^D([1-9]\\d*)$/', $partial_string, $matches)) {
$diff_id = $matches[1];
// TOOD: (T603) This is all slated for annihilation.
$diff_rev = id(new DifferentialRevision())->load($diff_id);
if (!$diff_rev) {
throw new ReleephCommitFinderException("{$partial_string} does not refer to an existing diff.");
}
$commit_phids = $diff_rev->loadCommitPHIDs();
if (!$commit_phids) {
throw new ReleephCommitFinderException("{$partial_string} has no commits associated with it yet.");
}
$this->objectPHID = $diff_rev->getPHID();
$commits = id(new PhabricatorRepositoryCommit())->loadAllWhere('phid IN (%Ls) ORDER BY epoch ASC', $commit_phids);
return head($commits);
}
// Look for a raw commit number, or r<callsign><commit-number>.
$repository = $this->releephProject->getRepository();
$dr_data = null;
$matches = array();
if (preg_match('/^r(?P<callsign>[A-Z]+)(?P<commit>\\w+)$/', $partial_string, $matches)) {
$callsign = $matches['callsign'];
if ($callsign != $repository->getCallsign()) {
throw new ReleephCommitFinderException(sprintf('%s is in a different repository to this Releeph project (%s).', $partial_string, $repository->getCallsign()));
} else {
$dr_data = $matches;
}
} else {
$dr_data = array('callsign' => $repository->getCallsign(), 'commit' => $partial_string);
}
try {
$dr_data['user'] = $this->getUser();
$dr = DiffusionRequest::newFromDictionary($dr_data);
} catch (Exception $ex) {
$message = "No commit matches {$partial_string}: " . $ex->getMessage();
throw new ReleephCommitFinderException($message);
}
$phabricator_repository_commit = $dr->loadCommit();
if (!$phabricator_repository_commit) {
throw new ReleephCommitFinderException("The commit {$partial_string} doesn't exist in this repository.");
}
// When requesting a single commit, if it has an associated review we
// imply the review was requested instead. This is always correct for now
// and consistent with the older behavior, although it might not be the
// right rule in the future.
$phids = PhabricatorEdgeQuery::loadDestinationPHIDs($phabricator_repository_commit->getPHID(), PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV);
if ($phids) {
$this->objectPHID = head($phids);
}
return $phabricator_repository_commit;
}
示例8: fromPartial
public function fromPartial($partial_string)
{
$this->objectPHID = null;
// Look for diffs
$matches = array();
if (preg_match('/^D([1-9]\\d*)$/', $partial_string, $matches)) {
$diff_id = $matches[1];
$diff_rev = id(new DifferentialRevisionQuery())->setViewer($this->getUser())->withIDs(array($diff_id))->needCommitPHIDs(true)->executeOne();
if (!$diff_rev) {
throw new ReleephCommitFinderException(pht('%s does not refer to an existing diff.', $partial_string));
}
$commit_phids = $diff_rev->getCommitPHIDs();
if (!$commit_phids) {
throw new ReleephCommitFinderException(pht('%s has no commits associated with it yet.', $partial_string));
}
$this->objectPHID = $diff_rev->getPHID();
$commits = id(new DiffusionCommitQuery())->setViewer($this->getUser())->withPHIDs($commit_phids)->execute();
$commits = msort($commits, 'getEpoch');
return head($commits);
}
// Look for a raw commit number, or r<callsign><commit-number>.
$repository = $this->releephProject->getRepository();
$dr_data = null;
$matches = array();
if (preg_match('/^r(?P<callsign>[A-Z]+)(?P<commit>\\w+)$/', $partial_string, $matches)) {
$callsign = $matches['callsign'];
if ($callsign != $repository->getCallsign()) {
throw new ReleephCommitFinderException(pht('%s is in a different repository to this Releeph project (%s).', $partial_string, $repository->getCallsign()));
} else {
$dr_data = $matches;
}
} else {
$dr_data = array('callsign' => $repository->getCallsign(), 'commit' => $partial_string);
}
try {
$dr_data['user'] = $this->getUser();
$dr = DiffusionRequest::newFromDictionary($dr_data);
} catch (Exception $ex) {
$message = pht('No commit matches %s: %s', $partial_string, $ex->getMessage());
throw new ReleephCommitFinderException($message);
}
$phabricator_repository_commit = $dr->loadCommit();
if (!$phabricator_repository_commit) {
throw new ReleephCommitFinderException(pht("The commit %s doesn't exist in this repository.", $partial_string));
}
// When requesting a single commit, if it has an associated review we
// imply the review was requested instead. This is always correct for now
// and consistent with the older behavior, although it might not be the
// right rule in the future.
$phids = PhabricatorEdgeQuery::loadDestinationPHIDs($phabricator_repository_commit->getPHID(), DiffusionCommitHasRevisionEdgeType::EDGECONST);
if ($phids) {
$this->objectPHID = head($phids);
}
return $phabricator_repository_commit;
}
示例9: execute
protected function execute(ConduitAPIRequest $request)
{
$drequest = DiffusionRequest::newFromDictionary(array('callsign' => $request->getValue('callsign'), 'path' => $request->getValue('path')));
$history = DiffusionHistoryQuery::newFromDiffusionRequest($drequest)->setLimit(self::RESULT_LIMIT)->needDirectChanges(true)->needChildChanges(true)->loadHistory();
$raw_commit_identifiers = mpull($history, 'getCommitIdentifier');
$result = array();
foreach ($raw_commit_identifiers as $id) {
$result[] = 'r' . $request->getValue('callsign') . $id;
}
return $result;
}
示例10: getURI
public function getURI()
{
if (!$this->repository) {
// This symbol is in the index, but we don't know which Repository it's
// part of. Usually this means the Arcanist Project hasn't been linked
// to a Repository. We can't generate a URI, so just fail.
return null;
}
$request = DiffusionRequest::newFromDictionary(array('user' => PhabricatorUser::getOmnipotentUser(), 'repository' => $this->getRepository()));
return $request->generateURI(array('action' => 'browse', 'path' => $this->getPath(), 'line' => $this->getLineNumber()));
}
示例11: loadContext
private function loadContext(array $options)
{
$request = $this->getRequest();
$viewer = $this->getViewer();
$identifier = $this->getRepositoryIdentifierFromRequest($request);
$params = $options + array('repository' => $identifier, 'user' => $viewer, 'blob' => $this->getDiffusionBlobFromRequest($request), 'commit' => $request->getURIData('commit'), 'path' => $request->getURIData('path'), 'line' => $request->getURIData('line'), 'branch' => $request->getURIData('branch'), 'lint' => $request->getStr('lint'));
$drequest = DiffusionRequest::newFromDictionary($params);
if (!$drequest) {
return new Aphront404Response();
}
$this->diffusionRequest = $drequest;
return null;
}
示例12: 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;
}
示例13: parseCommit
protected final function parseCommit(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit)
{
if (!$this->shouldSkipImportStep()) {
$viewer = PhabricatorUser::getOmnipotentUser();
$refs_raw = DiffusionQuery::callConduitWithDiffusionRequest($viewer, DiffusionRequest::newFromDictionary(array('repository' => $repository, 'user' => $viewer)), 'diffusion.querycommits', array('repositoryPHID' => $repository->getPHID(), 'phids' => array($commit->getPHID()), 'bypassCache' => true, 'needMessages' => true));
if (empty($refs_raw['data'])) {
throw new Exception(pht('Unable to retrieve details for commit "%s"!', $commit->getPHID()));
}
$ref = DiffusionCommitRef::newFromConduitResult(head($refs_raw['data']));
$this->updateCommitData($ref);
}
if ($this->shouldQueueFollowupTasks()) {
$this->queueTask($this->getFollowupTaskClass(), array('commitID' => $commit->getID()), array('priority' => PhabricatorWorker::PRIORITY_DEFAULT));
}
}
示例14: loadAffectedPaths
public static function loadAffectedPaths(PhabricatorRepository $repository, PhabricatorRepositoryCommit $commit, PhabricatorUser $user)
{
$drequest = DiffusionRequest::newFromDictionary(array('user' => $user, 'repository' => $repository, 'commit' => $commit->getCommitIdentifier()));
$path_query = DiffusionPathChangeQuery::newFromDiffusionRequest($drequest);
$paths = $path_query->loadChanges();
$result = array();
foreach ($paths as $path) {
$basic_path = '/' . $path->getPath();
if ($path->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
$basic_path = rtrim($basic_path, '/') . '/';
}
$result[] = $basic_path;
}
return $result;
}
示例15: renderResultsList
public function renderResultsList(array $branches, PhabricatorSavedQuery $saved)
{
assert_instances_of($branches, 'ReleephBranch');
$viewer = $this->getRequest()->getUser();
$products = mpull($branches, 'getProduct');
$repo_phids = mpull($products, 'getRepositoryPHID');
$repos = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->withPHIDs($repo_phids)->execute();
$repos = mpull($repos, null, 'getPHID');
$phids = mpull($branches, 'getCreatedByUserPHID');
$this->loadHandles($phids);
$requests = array();
if ($branches) {
$requests = id(new ReleephRequestQuery())->setViewer($viewer)->withBranchIDs(mpull($branches, 'getID'))->withStatus(ReleephRequestQuery::STATUS_OPEN)->execute();
$requests = mgroup($requests, 'getBranchID');
}
$list = id(new PHUIObjectItemListView())->setUser($viewer);
foreach ($branches as $branch) {
$diffusion_href = null;
$repo = idx($repos, $branch->getProduct()->getRepositoryPHID());
if ($repo) {
$drequest = DiffusionRequest::newFromDictionary(array('user' => $viewer, 'repository' => $repo));
$diffusion_href = $drequest->generateURI(array('action' => 'branch', 'branch' => $branch->getName()));
}
$branch_link = $branch->getName();
if ($diffusion_href) {
$branch_link = phutil_tag('a', array('href' => $diffusion_href), $branch_link);
}
$item = id(new PHUIObjectItemView())->setHeader($branch->getDisplayName())->setHref($this->getApplicationURI('branch/' . $branch->getID() . '/'))->addAttribute($branch_link);
if (!$branch->getIsActive()) {
$item->setDisabled(true);
}
$commit = $branch->getCutPointCommit();
if ($commit) {
$item->addIcon('none', phabricator_datetime($commit->getEpoch(), $viewer));
}
$open_count = count(idx($requests, $branch->getID(), array()));
if ($open_count) {
$item->setBarColor('orange');
$item->addIcon('fa-code-fork', pht('%d Open Pull Request(s)', new PhutilNumber($open_count)));
}
$list->addItem($item);
}
return $list;
}