[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorRepositoryCommitData extends PhabricatorRepositoryDAO { 4 5 /** 6 * NOTE: We denormalize this into the commit table; make sure the sizes 7 * match up. 8 */ 9 const SUMMARY_MAX_LENGTH = 80; 10 11 protected $commitID; 12 protected $authorName = ''; 13 protected $commitMessage = ''; 14 protected $commitDetails = array(); 15 16 public function getConfiguration() { 17 return array( 18 self::CONFIG_TIMESTAMPS => false, 19 self::CONFIG_SERIALIZATION => array( 20 'commitDetails' => self::SERIALIZATION_JSON, 21 ), 22 self::CONFIG_COLUMN_SCHEMA => array( 23 'authorName' => 'text', 24 'commitMessage' => 'text', 25 ), 26 self::CONFIG_KEY_SCHEMA => array( 27 'commitID' => array( 28 'columns' => array('commitID'), 29 'unique' => true, 30 ), 31 ), 32 ) + parent::getConfiguration(); 33 } 34 35 public function getSummary() { 36 $message = $this->getCommitMessage(); 37 return self::summarizeCommitMessage($message); 38 } 39 40 public static function summarizeCommitMessage($message) { 41 $summary = phutil_split_lines($message, $retain_endings = false); 42 $summary = head($summary); 43 $summary = id(new PhutilUTF8StringTruncator()) 44 ->setMaximumCodepoints(self::SUMMARY_MAX_LENGTH) 45 ->truncateString($summary); 46 47 return $summary; 48 } 49 50 public function getCommitDetail($key, $default = null) { 51 return idx($this->commitDetails, $key, $default); 52 } 53 54 public function setCommitDetail($key, $value) { 55 $this->commitDetails[$key] = $value; 56 return $this; 57 } 58 59 public function toDictionary() { 60 return array( 61 'commitID' => $this->commitID, 62 'authorName' => $this->authorName, 63 'commitMessage' => $this->commitMessage, 64 'commitDetails' => json_encode($this->commitDetails), 65 ); 66 } 67 68 public static function newFromDictionary(array $dict) { 69 return id(new PhabricatorRepositoryCommitData()) 70 ->loadFromArray($dict); 71 } 72 73 }
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 |