[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/config/storage/ -> PhabricatorConfigTransaction.php (source)

   1  <?php
   2  
   3  final class PhabricatorConfigTransaction
   4    extends PhabricatorApplicationTransaction {
   5  
   6    const TYPE_EDIT = 'config:edit';
   7  
   8    public function getApplicationName() {
   9      return 'config';
  10    }
  11  
  12    public function getApplicationTransactionType() {
  13      return PhabricatorConfigConfigPHIDType::TYPECONST;
  14    }
  15  
  16    public function getApplicationTransactionCommentObject() {
  17      return null;
  18    }
  19  
  20    public function getTitle() {
  21      $author_phid = $this->getAuthorPHID();
  22  
  23      $old = $this->getOldValue();
  24      $new = $this->getNewValue();
  25  
  26      switch ($this->getTransactionType()) {
  27        case self::TYPE_EDIT:
  28  
  29          // TODO: After T2213 show the actual values too; for now, we don't
  30          // have the tools to do it without making a bit of a mess of it.
  31  
  32          $old_del = idx($old, 'deleted');
  33          $new_del = idx($new, 'deleted');
  34          if ($old_del && !$new_del) {
  35            return pht(
  36              '%s created this configuration entry.',
  37              $this->renderHandleLink($author_phid));
  38          } else if (!$old_del && $new_del) {
  39            return pht(
  40              '%s deleted this configuration entry.',
  41              $this->renderHandleLink($author_phid));
  42          } else if ($old_del && $new_del) {
  43            // This is a bug.
  44            return pht(
  45              '%s deleted this configuration entry (again?).',
  46              $this->renderHandleLink($author_phid));
  47          } else {
  48            return pht(
  49              '%s edited this configuration entry.',
  50              $this->renderHandleLink($author_phid));
  51          }
  52          break;
  53      }
  54  
  55      return parent::getTitle();
  56    }
  57  
  58  
  59    public function getIcon() {
  60      switch ($this->getTransactionType()) {
  61        case self::TYPE_EDIT:
  62          return 'fa-pencil';
  63      }
  64  
  65      return parent::getIcon();
  66    }
  67  
  68    public function hasChangeDetails() {
  69      switch ($this->getTransactionType()) {
  70        case self::TYPE_EDIT:
  71          return true;
  72      }
  73      return parent::hasChangeDetails();
  74    }
  75  
  76    public function renderChangeDetails(PhabricatorUser $viewer) {
  77      $old = $this->getOldValue();
  78      $new = $this->getNewValue();
  79  
  80      if ($old['deleted']) {
  81        $old_text = '';
  82      } else {
  83        $old_text = PhabricatorConfigJSON::prettyPrintJSON($old['value']);
  84      }
  85  
  86      if ($new['deleted']) {
  87        $new_text = '';
  88      } else {
  89        $new_text = PhabricatorConfigJSON::prettyPrintJSON($new['value']);
  90      }
  91  
  92      return $this->renderTextCorpusChangeDetails(
  93        $viewer,
  94        $old_text,
  95        $new_text);
  96    }
  97  
  98    public function getColor() {
  99      $old = $this->getOldValue();
 100      $new = $this->getNewValue();
 101  
 102      switch ($this->getTransactionType()) {
 103        case self::TYPE_EDIT:
 104          $old_del = idx($old, 'deleted');
 105          $new_del = idx($new, 'deleted');
 106  
 107          if ($old_del && !$new_del) {
 108            return PhabricatorTransactions::COLOR_GREEN;
 109          } else if (!$old_del && $new_del) {
 110            return PhabricatorTransactions::COLOR_RED;
 111          } else {
 112            return PhabricatorTransactions::COLOR_BLUE;
 113          }
 114          break;
 115      }
 116    }
 117  
 118  }


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