[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/ponder/editor/ -> PonderAnswerEditor.php (source)

   1  <?php
   2  
   3  final class PonderAnswerEditor extends PonderEditor {
   4  
   5    public function getEditorObjectsDescription() {
   6      return pht('Ponder Answers');
   7    }
   8  
   9    public function getTransactionTypes() {
  10      $types = parent::getTransactionTypes();
  11  
  12      $types[] = PhabricatorTransactions::TYPE_COMMENT;
  13      $types[] = PonderAnswerTransaction::TYPE_CONTENT;
  14  
  15      return $types;
  16    }
  17  
  18    protected function getCustomTransactionOldValue(
  19      PhabricatorLiskDAO $object,
  20      PhabricatorApplicationTransaction $xaction) {
  21  
  22      switch ($xaction->getTransactionType()) {
  23        case PonderAnswerTransaction::TYPE_CONTENT:
  24          return $object->getContent();
  25      }
  26    }
  27  
  28    protected function getCustomTransactionNewValue(
  29      PhabricatorLiskDAO $object,
  30      PhabricatorApplicationTransaction $xaction) {
  31  
  32      switch ($xaction->getTransactionType()) {
  33        case PonderAnswerTransaction::TYPE_CONTENT:
  34          return $xaction->getNewValue();
  35      }
  36    }
  37  
  38    protected function applyCustomInternalTransaction(
  39      PhabricatorLiskDAO $object,
  40      PhabricatorApplicationTransaction $xaction) {
  41  
  42      switch ($xaction->getTransactionType()) {
  43        case PonderAnswerTransaction::TYPE_CONTENT:
  44          $object->setContent($xaction->getNewValue());
  45          break;
  46      }
  47    }
  48  
  49    protected function applyCustomExternalTransaction(
  50      PhabricatorLiskDAO $object,
  51      PhabricatorApplicationTransaction $xaction) {
  52      return;
  53    }
  54  
  55    protected function mergeTransactions(
  56      PhabricatorApplicationTransaction $u,
  57      PhabricatorApplicationTransaction $v) {
  58  
  59      $type = $u->getTransactionType();
  60      switch ($type) {
  61        case PonderAnswerTransaction::TYPE_CONTENT:
  62          return $v;
  63      }
  64  
  65      return parent::mergeTransactions($u, $v);
  66    }
  67  
  68    protected function shouldSendMail(
  69      PhabricatorLiskDAO $object,
  70      array $xactions) {
  71      return true;
  72    }
  73  
  74    protected function buildReplyHandler(PhabricatorLiskDAO $object) {
  75      $question = $object->getQuestion();
  76      return id(new PonderQuestionReplyHandler())
  77        ->setMailReceiver($question);
  78    }
  79  
  80    protected function buildMailTemplate(PhabricatorLiskDAO $object) {
  81      $question = $object->getQuestion();
  82      return parent::buildMailTemplate($question);
  83    }
  84  
  85  
  86    protected function buildMailBody(
  87      PhabricatorLiskDAO $object,
  88      array $xactions) {
  89  
  90      $body = parent::buildMailBody($object, $xactions);
  91  
  92      // If the user just gave the answer, add the answer text.
  93      foreach ($xactions as $xaction) {
  94        $type = $xaction->getTransactionType();
  95        $new = $xaction->getNewValue();
  96        if ($type == PonderAnswerTransaction::TYPE_CONTENT) {
  97          $body->addRawSection($new);
  98        }
  99      }
 100  
 101      $body->addLinkSection(
 102        pht('ANSWER DETAIL'),
 103        PhabricatorEnv::getProductionURI($object->getURI()));
 104  
 105      return $body;
 106    }
 107  
 108  }


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