Path: blob/master/src/applications/maniphest/controller/ManiphestTaskGraphController.php
12256 views
<?php12final class ManiphestTaskGraphController3extends ManiphestController {45public function shouldAllowPublic() {6return true;7}89public function handleRequest(AphrontRequest $request) {10$viewer = $this->getViewer();11$id = $request->getURIData('id');1213$task = id(new ManiphestTaskQuery())14->setViewer($viewer)15->withIDs(array($id))16->executeOne();17if (!$task) {18return new Aphront404Response();19}2021$crumbs = $this->buildApplicationCrumbs()22->addTextCrumb($task->getMonogram(), $task->getURI())23->addTextCrumb(pht('Graph'))24->setBorder(true);2526$graph_limit = 2000;27$overflow_message = null;28$task_graph = id(new ManiphestTaskGraph())29->setViewer($viewer)30->setSeedPHID($task->getPHID())31->setLimit($graph_limit)32->setIsStandalone(true)33->loadGraph();34if (!$task_graph->isEmpty()) {35$parent_type = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST;36$subtask_type = ManiphestTaskDependsOnTaskEdgeType::EDGECONST;37$parent_map = $task_graph->getEdges($parent_type);38$subtask_map = $task_graph->getEdges($subtask_type);39$parent_list = idx($parent_map, $task->getPHID(), array());40$subtask_list = idx($subtask_map, $task->getPHID(), array());41$has_parents = (bool)$parent_list;42$has_subtasks = (bool)$subtask_list;4344// First, get a count of direct parent tasks and subtasks. If there45// are too many of these, we just don't draw anything. You can use46// the search button to browse tasks with the search UI instead.47$direct_count = count($parent_list) + count($subtask_list);4849if ($direct_count > $graph_limit) {50$overflow_message = pht(51'This task is directly connected to more than %s other tasks, '.52'which is too many tasks to display. Use %s to browse parents '.53'or subtasks.',54new PhutilNumber($graph_limit),55phutil_tag('strong', array(), pht('Search...')));5657$graph_table = null;58} else {59// If there aren't too many direct tasks, but there are too many total60// tasks, we'll only render directly connected tasks.61if ($task_graph->isOverLimit()) {62$task_graph->setRenderOnlyAdjacentNodes(true);6364$overflow_message = pht(65'This task is connected to more than %s other tasks. '.66'Only direct parents and subtasks are shown here.',67new PhutilNumber($graph_limit));68}6970$graph_table = $task_graph->newGraphTable();71}7273$graph_menu = $this->newTaskGraphDropdownMenu(74$task,75$has_parents,76$has_subtasks,77false);78} else {79$graph_menu = null;80$graph_table = null;8182$overflow_message = pht(83'This task has no parent tasks and no subtasks, so there is no '.84'graph to draw.');85}8687if ($overflow_message) {88$overflow_view = $this->newTaskGraphOverflowView(89$task,90$overflow_message,91false);9293$graph_table = array(94$overflow_view,95$graph_table,96);97}9899$header = id(new PHUIHeaderView())100->setHeader(pht('Task Graph'));101102if ($graph_menu) {103$header->addActionLink($graph_menu);104}105106$tab_view = id(new PHUIObjectBoxView())107->setHeader($header)108->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)109->appendChild($graph_table);110111$view = id(new PHUITwoColumnView())112->setFooter($tab_view);113114return $this->newPage()115->setTitle(116array(117$task->getMonogram(),118pht('Graph'),119))120->setCrumbs($crumbs)121->appendChild($view);122}123124125}126127128