Changeset View
Changeset View
Standalone View
Standalone View
src/applications/audit/view/PhabricatorAuditTransactionView.php
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | foreach ($group as $xaction) { | ||||
case PhabricatorAuditActionConstants::INLINE: | case PhabricatorAuditActionConstants::INLINE: | ||||
$inlines[] = $xaction; | $inlines[] = $xaction; | ||||
break; | break; | ||||
default: | default: | ||||
throw new Exception(pht('Unknown grouped transaction type!')); | throw new Exception(pht('Unknown grouped transaction type!')); | ||||
} | } | ||||
} | } | ||||
if ($inlines) { | $structs = array(); | ||||
// TODO: This should do something similar to sortAndGroupInlines() to get | |||||
// a stable ordering. | |||||
$inlines_by_path = array(); | |||||
foreach ($inlines as $key => $inline) { | foreach ($inlines as $key => $inline) { | ||||
$comment = $inline->getComment(); | $comment = $inline->getComment(); | ||||
if (!$comment) { | if (!$comment) { | ||||
// TODO: Migrate these away? They probably do not exist on normal | // TODO: Migrate these away? They probably do not exist on normal | ||||
// non-development installs. | // non-development installs. | ||||
unset($inlines[$key]); | unset($inlines[$key]); | ||||
continue; | continue; | ||||
} | } | ||||
$path_id = $comment->getPathID(); | |||||
$inlines_by_path[$path_id][] = $inline; | |||||
} | |||||
$inline_view = new PhabricatorInlineSummaryView(); | $path_id = $comment->getPathID(); | ||||
foreach ($inlines_by_path as $path_id => $group) { | |||||
$path = idx($this->pathMap, $path_id); | $path = idx($this->pathMap, $path_id); | ||||
if ($path === null) { | if ($path === null) { | ||||
continue; | continue; | ||||
} | } | ||||
$structs[] = array( | |||||
'inline' => $inline, | |||||
'path' => $path, | |||||
'sort' => (string)id(new PhutilSortVector()) | |||||
->addString($path) | |||||
->addInt($comment->getLineNumber()) | |||||
->addInt($comment->getLineLength()) | |||||
->addInt($inline->getID()), | |||||
); | |||||
} | |||||
if (!$structs) { | |||||
return $out; | |||||
} | |||||
$structs = isort($structs, 'sort'); | |||||
$structs = igroup($structs, 'path'); | |||||
$inline_view = new PhabricatorInlineSummaryView(); | |||||
foreach ($structs as $path => $group) { | |||||
$inlines = ipull($group, 'inline'); | |||||
$items = array(); | $items = array(); | ||||
foreach ($group as $inline) { | foreach ($inlines as $inline) { | ||||
$comment = $inline->getComment(); | $comment = $inline->getComment(); | ||||
$item = array( | $items[] = array( | ||||
'id' => $comment->getID(), | 'id' => $comment->getID(), | ||||
'line' => $comment->getLineNumber(), | 'line' => $comment->getLineNumber(), | ||||
'length' => $comment->getLineLength(), | 'length' => $comment->getLineLength(), | ||||
'content' => parent::renderTransactionContent($inline), | 'content' => parent::renderTransactionContent($inline), | ||||
); | ); | ||||
$items[] = $item; | |||||
} | } | ||||
$inline_view->addCommentGroup($path, $items); | $inline_view->addCommentGroup($path, $items); | ||||
} | } | ||||
$out[] = $inline_view; | $out[] = $inline_view; | ||||
} | |||||
return $out; | return $out; | ||||
} | } | ||||
} | } |