Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / harbormaster / view / HarbormasterLintPropertyView.php
blobabfaa7e22283c7b1077fbd0cb49d0cd44cfb747a
1 <?php
3 final class HarbormasterLintPropertyView extends AphrontView {
5 private $pathURIMap = array();
6 private $lintMessages = array();
7 private $limit;
9 public function setPathURIMap(array $map) {
10 $this->pathURIMap = $map;
11 return $this;
14 public function setLintMessages(array $messages) {
15 assert_instances_of($messages, 'HarbormasterBuildLintMessage');
16 $this->lintMessages = $messages;
17 return $this;
20 public function setLimit($limit) {
21 $this->limit = $limit;
22 return $this;
25 public function render() {
26 $messages = $this->lintMessages;
27 $messages = msort($messages, 'getSortKey');
29 if ($this->limit) {
30 $messages = array_slice($messages, 0, $this->limit);
33 $rows = array();
34 foreach ($messages as $message) {
35 $path = $message->getPath();
36 $line = $message->getLine();
38 $href = null;
39 if (strlen(idx($this->pathURIMap, $path))) {
40 $href = $this->pathURIMap[$path].max($line, 1);
43 $severity = $this->renderSeverity($message->getSeverity());
45 $location = $path.':'.$line;
46 if (strlen($href)) {
47 $location = phutil_tag(
48 'a',
49 array(
50 'href' => $href,
52 $location);
55 $rows[] = array(
56 $severity,
57 $location,
58 $message->getCode(),
59 $message->getName(),
63 $table = id(new AphrontTableView($rows))
64 ->setHeaders(
65 array(
66 pht('Severity'),
67 pht('Location'),
68 pht('Code'),
69 pht('Message'),
71 ->setColumnClasses(
72 array(
73 null,
74 'pri',
75 null,
76 'wide',
77 ));
79 return $table;
82 private function renderSeverity($severity) {
83 $names = ArcanistLintSeverity::getLintSeverities();
84 $name = idx($names, $severity, $severity);
86 // TODO: Add some color here?
88 return $name;