Path: blob/master/src/view/widget/AphrontStackTraceView.php
12249 views
<?php12final class AphrontStackTraceView extends AphrontView {34private $trace;56public function setTrace($trace) {7$this->trace = $trace;8return $this;9}1011public function render() {12$trace = $this->trace;1314$libraries = PhutilBootloader::getInstance()->getAllLibraries();1516// TODO: Make this configurable?17$path = 'https://secure.phabricator.com/diffusion/%s/browse/master/src/';1819$callsigns = array(20'arcanist' => 'ARC',21'phabricator' => 'P',22);2324$rows = array();25$depth = count($trace);26foreach ($trace as $part) {27$lib = null;28$file = idx($part, 'file');29$relative = $file;30foreach ($libraries as $library) {31$root = phutil_get_library_root($library);32if ($file !== null && Filesystem::isDescendant($file, $root)) {33$lib = $library;34$relative = Filesystem::readablePath($file, $root);35break;36}37}3839$where = '';40if (isset($part['class'])) {41$where .= $part['class'].'::';42}43if (isset($part['function'])) {44$where .= $part['function'].'()';45}4647if ($file) {48if (isset($callsigns[$lib])) {49$attrs = array('title' => $file);50if (empty($attrs['href'])) {51$attrs['href'] = sprintf($path, $callsigns[$lib]).52str_replace(DIRECTORY_SEPARATOR, '/', $relative).53'$'.$part['line'];54$attrs['target'] = '_blank';55}56$file_name = phutil_tag(57'a',58$attrs,59$relative);60} else {61$file_name = phutil_tag(62'span',63array(64'title' => $file,65),66$relative);67}68$file_name = hsprintf('%s : %d', $file_name, $part['line']);69} else {70$file_name = phutil_tag('em', array(), '(Internal)');71}727374$rows[] = array(75$depth--,76$lib,77$file_name,78$where,79);80}81$table = new AphrontTableView($rows);82$table->setHeaders(83array(84pht('Depth'),85pht('Library'),86pht('File'),87pht('Where'),88));89$table->setColumnClasses(90array(91'n',92'',93'',94'wide',95));9697return phutil_tag(98'div',99array(100'class' => 'exception-trace',101),102$table->render());103}104105}106107108