Path: blob/master/src/applications/differential/controller/DifferentialRevisionAffectedPathsController.php
12256 views
<?php12final class DifferentialRevisionAffectedPathsController3extends DifferentialController {45public function handleRequest(AphrontRequest $request) {6$viewer = $this->getViewer();7$id = $request->getURIData('id');89$revision = id(new DifferentialRevisionQuery())10->withIDs(array($id))11->setViewer($viewer)12->executeOne();13if (!$revision) {14return new Aphront404Response();15}1617$table = new DifferentialAffectedPath();18$conn = $table->establishConnection('r');1920$paths = queryfx_all(21$conn,22'SELECT * FROM %R WHERE revisionID = %d',23$table,24$revision->getID());2526$repository_ids = array();27$path_ids = array();2829foreach ($paths as $path) {30$repository_id = $path['repositoryID'];31$path_id = $path['pathID'];3233$repository_ids[] = $repository_id;34$path_ids[] = $path_id;35}3637$repository_ids = array_fuse($repository_ids);3839if ($repository_ids) {40$repositories = id(new PhabricatorRepositoryQuery())41->setViewer($viewer)42->withIDs($repository_ids)43->execute();44$repositories = mpull($repositories, null, 'getID');45} else {46$repositories = array();47}4849$handles = $viewer->loadHandles(mpull($repositories, 'getPHID'));5051$path_ids = array_fuse($path_ids);52if ($path_ids) {53$path_names = id(new DiffusionPathQuery())54->withPathIDs($path_ids)55->execute();56} else {57$path_names = array();58}5960$rows = array();61foreach ($paths as $path) {62$repository_id = $path['repositoryID'];63$path_id = $path['pathID'];6465$repository = idx($repositories, $repository_id);66if ($repository) {67$repository_phid = $repository->getPHID();68$repository_link = $handles[$repository_phid]->renderLink();69} else {70$repository_link = null;71}7273$path_name = idx($path_names, $path_id);74if ($path_name !== null) {75$path_view = $path_name['path'];76} else {77$path_view = null;78}7980$rows[] = array(81$repository_id,82$repository_link,83$path_id,84$path_view,85);86}8788// Sort rows by path name.89$rows = isort($rows, 3);9091$table_view = id(new AphrontTableView($rows))92->setNoDataString(pht('This revision has no indexed affected paths.'))93->setHeaders(94array(95pht('Repository ID'),96pht('Repository'),97pht('Path ID'),98pht('Path'),99))100->setColumnClasses(101array(102null,103null,104null,105'wide',106));107108$box_view = id(new PHUIObjectBoxView())109->setHeaderText(pht('Affected Path Index'))110->setTable($table_view);111112$crumbs = $this->buildApplicationCrumbs()113->addTextCrumb($revision->getMonogram(), $revision->getURI())114->addTextCrumb(pht('Affected Path Index'));115116return $this->newPage()117->setCrumbs($crumbs)118->setTitle(119array(120$revision->getMonogram(),121pht('Affected Path Index'),122))123->appendChild($box_view);124}125126}127128129