[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class DifferentialTransactionComment 4 extends PhabricatorApplicationTransactionComment { 5 6 protected $revisionPHID; 7 protected $changesetID; 8 protected $isNewFile = 0; 9 protected $lineNumber = 0; 10 protected $lineLength = 0; 11 protected $fixedState; 12 protected $hasReplies = 0; 13 protected $replyToCommentPHID; 14 15 public function getApplicationTransactionObject() { 16 return new DifferentialTransaction(); 17 } 18 19 public function getConfiguration() { 20 $config = parent::getConfiguration(); 21 $config[self::CONFIG_COLUMN_SCHEMA] = array( 22 'revisionPHID' => 'phid?', 23 'changesetID' => 'id?', 24 'isNewFile' => 'bool', 25 'lineNumber' => 'uint32', 26 'lineLength' => 'uint32', 27 'fixedState' => 'text12?', 28 'hasReplies' => 'bool', 29 'replyToCommentPHID' => 'phid?', 30 ) + $config[self::CONFIG_COLUMN_SCHEMA]; 31 $config[self::CONFIG_KEY_SCHEMA] = array( 32 'key_draft' => array( 33 'columns' => array('authorPHID', 'transactionPHID'), 34 ), 35 'key_changeset' => array( 36 'columns' => array('changesetID'), 37 ), 38 'key_revision' => array( 39 'columns' => array('revisionPHID'), 40 ), 41 ) + $config[self::CONFIG_KEY_SCHEMA]; 42 return $config; 43 } 44 45 public function shouldUseMarkupCache($field) { 46 // Only cache submitted comments. 47 return ($this->getTransactionPHID() != null); 48 } 49 50 public static function sortAndGroupInlines( 51 array $inlines, 52 array $changesets) { 53 assert_instances_of($inlines, 'DifferentialTransaction'); 54 assert_instances_of($changesets, 'DifferentialChangeset'); 55 56 $changesets = mpull($changesets, null, 'getID'); 57 $changesets = msort($changesets, 'getFilename'); 58 59 // Group the changesets by file and reorder them by display order. 60 $inline_groups = array(); 61 foreach ($inlines as $inline) { 62 $changeset_id = $inline->getComment()->getChangesetID(); 63 $inline_groups[$changeset_id][] = $inline; 64 } 65 $inline_groups = array_select_keys($inline_groups, array_keys($changesets)); 66 67 foreach ($inline_groups as $changeset_id => $group) { 68 // Sort the group of inlines by line number. 69 $items = array(); 70 foreach ($group as $inline) { 71 $comment = $inline->getComment(); 72 $num = $comment->getLineNumber(); 73 $len = $comment->getLineLength(); 74 $id = $comment->getID(); 75 76 $items[] = array( 77 'inline' => $inline, 78 'sort' => sprintf('~%010d%010d%010d', $num, $len, $id), 79 ); 80 } 81 82 $items = isort($items, 'sort'); 83 $items = ipull($items, 'inline'); 84 $inline_groups[$changeset_id] = $items; 85 } 86 87 return $inline_groups; 88 } 89 90 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |