[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/phortune/storage/ -> PhortuneMerchantTransaction.php (source)

   1  <?php
   2  
   3  final class PhortuneMerchantTransaction
   4    extends PhabricatorApplicationTransaction {
   5  
   6    const TYPE_NAME = 'merchant:name';
   7    const TYPE_DESCRIPTION = 'merchant:description';
   8  
   9    public function getApplicationName() {
  10      return 'phortune';
  11    }
  12  
  13    public function getApplicationTransactionType() {
  14      return PhortuneMerchantPHIDType::TYPECONST;
  15    }
  16  
  17    public function getApplicationTransactionCommentObject() {
  18      return null;
  19    }
  20  
  21    public function getTitle() {
  22      $author_phid = $this->getAuthorPHID();
  23  
  24      $old = $this->getOldValue();
  25      $new = $this->getNewValue();
  26  
  27      switch ($this->getTransactionType()) {
  28        case self::TYPE_NAME:
  29          if ($old === null) {
  30            return pht(
  31              '%s created this merchant.',
  32              $this->renderHandleLink($author_phid));
  33          } else {
  34            return pht(
  35              '%s renamed this merchant from "%s" to "%s".',
  36              $this->renderHandleLink($author_phid),
  37              $old,
  38              $new);
  39          }
  40          break;
  41        case self::TYPE_DESCRIPTION:
  42          return pht(
  43            '%s updated the description for this merchant.',
  44              $this->renderHandleLink($author_phid));
  45      }
  46  
  47      return parent::getTitle();
  48    }
  49  
  50    public function shouldHide() {
  51      $old = $this->getOldValue();
  52      switch ($this->getTransactionType()) {
  53        case self::TYPE_DESCRIPTION:
  54          return ($old === null);
  55      }
  56      return parent::shouldHide();
  57    }
  58  
  59    public function hasChangeDetails() {
  60      switch ($this->getTransactionType()) {
  61        case self::TYPE_DESCRIPTION:
  62          return ($this->getOldValue() !== null);
  63      }
  64  
  65      return parent::hasChangeDetails();
  66    }
  67  
  68    public function renderChangeDetails(PhabricatorUser $viewer) {
  69      return $this->renderTextCorpusChangeDetails(
  70        $viewer,
  71        $this->getOldValue(),
  72        $this->getNewValue());
  73    }
  74  
  75  }


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