Modernize most somewhat-weird Diffusion controllers

Summary: Ref T4245. This gets everything else except serving HTTP requests (complicated) and lint (quite weird).

Test Plan:
  - Viewed a diff.
  - Viewed externals.
  - Viewed history table to see last modified.
  - Did path completion and validation in Owners.
  - Did tree path search in Diffusion.
  - Viewed a repository.
  - Created a new repository.
  - Looked up symbols.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D14947
This commit is contained in:
epriestley
2016-01-05 10:34:04 -08:00
parent 649f882720
commit 3cbc239bc6
10 changed files with 111 additions and 115 deletions

View File

@@ -2,21 +2,20 @@
final class DiffusionPathCompleteController extends DiffusionController {
protected function shouldLoadDiffusionRequest() {
return false;
protected function getRepositoryIdentifierFromRequest(
AphrontRequest $request) {
return $request->getStr('repositoryPHID');
}
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();
public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContext();
if ($response) {
return $response;
}
$viewer = $this->getViewer();
$drequest = $this->getDiffusionRequest();
$query_path = $request->getStr('q');
if (preg_match('@/$@', $query_path)) {
$query_dir = $query_path;
@@ -25,19 +24,11 @@ final class DiffusionPathCompleteController extends DiffusionController {
}
$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(),
'path' => $query_dir,
'commit' => $drequest->getCommit(),
)));
$paths = $browse_results->getPaths();