[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/ponder/storage/ -> PonderAnswerTransaction.php (source)

   1  <?php
   2  
   3  final class PonderAnswerTransaction
   4    extends PhabricatorApplicationTransaction {
   5  
   6    const TYPE_CONTENT = 'ponder.answer:content';
   7  
   8    public function getApplicationName() {
   9      return 'ponder';
  10    }
  11  
  12    public function getTableName() {
  13      return 'ponder_answertransaction';
  14    }
  15  
  16    public function getApplicationTransactionType() {
  17      return PonderAnswerPHIDType::TYPECONST;
  18    }
  19  
  20    public function getApplicationTransactionCommentObject() {
  21      return new PonderAnswerTransactionComment();
  22    }
  23  
  24    public function getRequiredHandlePHIDs() {
  25      $phids = parent::getRequiredHandlePHIDs();
  26  
  27      switch ($this->getTransactionType()) {
  28        case self::TYPE_CONTENT:
  29          $phids[] = $this->getObjectPHID();
  30          break;
  31      }
  32  
  33      return $phids;
  34    }
  35  
  36    public function getRemarkupBlocks() {
  37      $blocks = parent::getRemarkupBlocks();
  38  
  39      switch ($this->getTransactionType()) {
  40        case self::TYPE_CONTENT:
  41          $blocks[] = $this->getNewValue();
  42          break;
  43      }
  44  
  45      return $blocks;
  46    }
  47  
  48    public function getTitle() {
  49      $author_phid = $this->getAuthorPHID();
  50      $object_phid = $this->getObjectPHID();
  51  
  52      switch ($this->getTransactionType()) {
  53        case self::TYPE_CONTENT:
  54          return pht(
  55            '%s edited %s.',
  56            $this->renderHandleLink($author_phid),
  57            $this->renderHandleLink($object_phid));
  58      }
  59  
  60      return parent::getTitle();
  61    }
  62  
  63    public function getTitleForFeed(PhabricatorFeedStory $story) {
  64      $author_phid = $this->getAuthorPHID();
  65      $object_phid = $this->getObjectPHID();
  66  
  67      switch ($this->getTransactionType()) {
  68        case self::TYPE_CONTENT:
  69          return pht(
  70            '%s updated %s.',
  71            $this->renderHandleLink($author_phid),
  72            $this->renderHandleLink($object_phid));
  73      }
  74  
  75      return parent::getTitleForFeed($story);
  76    }
  77  
  78    public function getBodyForFeed(PhabricatorFeedStory $story) {
  79      $new = $this->getNewValue();
  80  
  81      $body = null;
  82  
  83      switch ($this->getTransactionType()) {
  84        case self::TYPE_CONTENT:
  85          return phutil_escape_html_newlines(
  86            id(new PhutilUTF8StringTruncator())
  87            ->setMaximumGlyphs(128)
  88            ->truncateString($new));
  89          break;
  90      }
  91      return parent::getBodyForFeed($story);
  92    }
  93  
  94  
  95    public function hasChangeDetails() {
  96      $old = $this->getOldValue();
  97  
  98      switch ($this->getTransactionType()) {
  99        case self::TYPE_CONTENT:
 100          return $old !== null;
 101      }
 102      return parent::hasChangeDetails();
 103    }
 104  
 105    public function renderChangeDetails(PhabricatorUser $viewer) {
 106      return $this->renderTextCorpusChangeDetails(
 107        $viewer,
 108        $this->getOldValue(),
 109        $this->getNewValue());
 110    }
 111  
 112  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1