public function getBodyForFeed(PhabricatorFeedStory $story) { $new = $this->getNewValue(); $old = $this->getOldValue(); $body = null; switch ($this->getTransactionType()) { case self::TYPE_TITLE: if ($old === null) { $question = $story->getObject($this->getObjectPHID()); return phutil_escape_html_newlines(id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(128)->truncateString($question->getContent())); } break; case self::TYPE_ANSWERS: $answer = $this->getNewAnswerObject($story); if ($answer) { return phutil_escape_html_newlines(id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(128)->truncateString($answer->getContent())); } break; } return parent::getBodyForFeed($story); }
/** * Generally, the answer object is only available if the transaction * type is self::TYPE_ANSWERS. * * Some stories - notably ones made before D7027 - will be of the more * generic @{class:PhabricatorApplicationTransactionFeedStory}. These * poor stories won't have the PonderAnswer loaded, and thus will have * less cool information. */ private function getNewAnswerObject(PhabricatorFeedStory $story) { if ($story instanceof PonderTransactionFeedStory) { $answer_phid = $this->getNewAnswerPHID(); if ($answer_phid) { return $story->getObject($answer_phid); } } return null; }