Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13979671
D17811.id42828.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
16 KB
Referenced Files
None
Subscribers
None
D17811.id42828.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4551,18 +4551,22 @@
'PonderAddAnswerView' => 'applications/ponder/view/PonderAddAnswerView.php',
'PonderAnswer' => 'applications/ponder/storage/PonderAnswer.php',
'PonderAnswerCommentController' => 'applications/ponder/controller/PonderAnswerCommentController.php',
+ 'PonderAnswerContentTransaction' => 'applications/ponder/xaction/PonderAnswerContentTransaction.php',
'PonderAnswerEditController' => 'applications/ponder/controller/PonderAnswerEditController.php',
'PonderAnswerEditor' => 'applications/ponder/editor/PonderAnswerEditor.php',
'PonderAnswerHistoryController' => 'applications/ponder/controller/PonderAnswerHistoryController.php',
'PonderAnswerMailReceiver' => 'applications/ponder/mail/PonderAnswerMailReceiver.php',
'PonderAnswerPHIDType' => 'applications/ponder/phid/PonderAnswerPHIDType.php',
'PonderAnswerQuery' => 'applications/ponder/query/PonderAnswerQuery.php',
+ 'PonderAnswerQuestionIDTransaction' => 'applications/ponder/xaction/PonderAnswerQuestionIDTransaction.php',
'PonderAnswerReplyHandler' => 'applications/ponder/mail/PonderAnswerReplyHandler.php',
'PonderAnswerSaveController' => 'applications/ponder/controller/PonderAnswerSaveController.php',
'PonderAnswerStatus' => 'applications/ponder/constants/PonderAnswerStatus.php',
+ 'PonderAnswerStatusTransaction' => 'applications/ponder/xaction/PonderAnswerStatusTransaction.php',
'PonderAnswerTransaction' => 'applications/ponder/storage/PonderAnswerTransaction.php',
'PonderAnswerTransactionComment' => 'applications/ponder/storage/PonderAnswerTransactionComment.php',
'PonderAnswerTransactionQuery' => 'applications/ponder/query/PonderAnswerTransactionQuery.php',
+ 'PonderAnswerTransactionType' => 'applications/ponder/xaction/PonderAnswerTransactionType.php',
'PonderAnswerView' => 'applications/ponder/view/PonderAnswerView.php',
'PonderConstants' => 'applications/ponder/constants/PonderConstants.php',
'PonderController' => 'applications/ponder/controller/PonderController.php',
@@ -10099,18 +10103,22 @@
'PhabricatorDestructibleInterface',
),
'PonderAnswerCommentController' => 'PonderController',
+ 'PonderAnswerContentTransaction' => 'PonderAnswerTransactionType',
'PonderAnswerEditController' => 'PonderController',
'PonderAnswerEditor' => 'PonderEditor',
'PonderAnswerHistoryController' => 'PonderController',
'PonderAnswerMailReceiver' => 'PhabricatorObjectMailReceiver',
'PonderAnswerPHIDType' => 'PhabricatorPHIDType',
'PonderAnswerQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PonderAnswerQuestionIDTransaction' => 'PonderAnswerTransactionType',
'PonderAnswerReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
'PonderAnswerSaveController' => 'PonderController',
'PonderAnswerStatus' => 'PonderConstants',
- 'PonderAnswerTransaction' => 'PhabricatorApplicationTransaction',
+ 'PonderAnswerStatusTransaction' => 'PonderAnswerTransactionType',
+ 'PonderAnswerTransaction' => 'PhabricatorModularTransaction',
'PonderAnswerTransactionComment' => 'PhabricatorApplicationTransactionComment',
'PonderAnswerTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
+ 'PonderAnswerTransactionType' => 'PhabricatorModularTransactionType',
'PonderAnswerView' => 'AphrontTagView',
'PonderConstants' => 'Phobject',
'PonderController' => 'PhabricatorController',
diff --git a/src/applications/ponder/controller/PonderAnswerEditController.php b/src/applications/ponder/controller/PonderAnswerEditController.php
--- a/src/applications/ponder/controller/PonderAnswerEditController.php
+++ b/src/applications/ponder/controller/PonderAnswerEditController.php
@@ -42,11 +42,11 @@
if (!$errors) {
$xactions = array();
$xactions[] = id(new PonderAnswerTransaction())
- ->setTransactionType(PonderAnswerTransaction::TYPE_CONTENT)
+ ->setTransactionType(PonderAnswerContentTransaction::TRANSACTIONTYPE)
->setNewValue($v_content);
$xactions[] = id(new PonderAnswerTransaction())
- ->setTransactionType(PonderAnswerTransaction::TYPE_STATUS)
+ ->setTransactionType(PonderAnswerStatusTransaction::TRANSACTIONTYPE)
->setNewValue($v_status);
$editor = id(new PonderAnswerEditor())
diff --git a/src/applications/ponder/controller/PonderAnswerSaveController.php b/src/applications/ponder/controller/PonderAnswerSaveController.php
--- a/src/applications/ponder/controller/PonderAnswerSaveController.php
+++ b/src/applications/ponder/controller/PonderAnswerSaveController.php
@@ -58,11 +58,11 @@
$xactions = array();
$xactions[] = id(clone $template)
- ->setTransactionType(PonderAnswerTransaction::TYPE_QUESTION_ID)
+ ->setTransactionType(PonderAnswerQuestionIDTransaction::TRANSACTIONTYPE)
->setNewValue($question->getID());
$xactions[] = id(clone $template)
- ->setTransactionType(PonderAnswerTransaction::TYPE_CONTENT)
+ ->setTransactionType(PonderAnswerContentTransaction::TRANSACTIONTYPE)
->setNewValue($content);
$editor = id(new PonderAnswerEditor())
diff --git a/src/applications/ponder/editor/PonderAnswerEditor.php b/src/applications/ponder/editor/PonderAnswerEditor.php
--- a/src/applications/ponder/editor/PonderAnswerEditor.php
+++ b/src/applications/ponder/editor/PonderAnswerEditor.php
@@ -8,78 +8,11 @@
public function getTransactionTypes() {
$types = parent::getTransactionTypes();
-
$types[] = PhabricatorTransactions::TYPE_COMMENT;
- $types[] = PhabricatorTransactions::TYPE_EDGE;
-
- $types[] = PonderAnswerTransaction::TYPE_CONTENT;
- $types[] = PonderAnswerTransaction::TYPE_STATUS;
- $types[] = PonderAnswerTransaction::TYPE_QUESTION_ID;
return $types;
}
- protected function getCustomTransactionOldValue(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case PonderAnswerTransaction::TYPE_CONTENT:
- case PonderAnswerTransaction::TYPE_STATUS:
- return $object->getContent();
- case PonderAnswerTransaction::TYPE_QUESTION_ID:
- return $object->getQuestionID();
- }
- }
-
- protected function getCustomTransactionNewValue(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case PonderAnswerTransaction::TYPE_CONTENT:
- case PonderAnswerTransaction::TYPE_STATUS:
- case PonderAnswerTransaction::TYPE_QUESTION_ID:
- return $xaction->getNewValue();
- }
- }
-
- protected function applyCustomInternalTransaction(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
-
- switch ($xaction->getTransactionType()) {
- case PonderAnswerTransaction::TYPE_CONTENT:
- $object->setContent($xaction->getNewValue());
- break;
- case PonderAnswerTransaction::TYPE_STATUS:
- $object->setStatus($xaction->getNewValue());
- break;
- case PonderAnswerTransaction::TYPE_QUESTION_ID:
- $object->setQuestionID($xaction->getNewValue());
- break;
- }
- }
-
- protected function applyCustomExternalTransaction(
- PhabricatorLiskDAO $object,
- PhabricatorApplicationTransaction $xaction) {
- return;
- }
-
- protected function mergeTransactions(
- PhabricatorApplicationTransaction $u,
- PhabricatorApplicationTransaction $v) {
-
- $type = $u->getTransactionType();
- switch ($type) {
- case PonderAnswerTransaction::TYPE_CONTENT:
- return $v;
- }
-
- return parent::mergeTransactions($u, $v);
- }
-
protected function shouldSendMail(
PhabricatorLiskDAO $object,
array $xactions) {
diff --git a/src/applications/ponder/storage/PonderAnswerTransaction.php b/src/applications/ponder/storage/PonderAnswerTransaction.php
--- a/src/applications/ponder/storage/PonderAnswerTransaction.php
+++ b/src/applications/ponder/storage/PonderAnswerTransaction.php
@@ -1,11 +1,7 @@
<?php
final class PonderAnswerTransaction
- extends PhabricatorApplicationTransaction {
-
- const TYPE_CONTENT = 'ponder.answer:content';
- const TYPE_STATUS = 'ponder.answer:status';
- const TYPE_QUESTION_ID = 'ponder.answer:question-id';
+ extends PhabricatorModularTransaction {
public function getApplicationName() {
return 'ponder';
@@ -23,141 +19,8 @@
return new PonderAnswerTransactionComment();
}
- public function getRequiredHandlePHIDs() {
- $phids = parent::getRequiredHandlePHIDs();
-
- switch ($this->getTransactionType()) {
- case self::TYPE_CONTENT:
- case self::TYPE_STATUS:
- $phids[] = $this->getObjectPHID();
- break;
- }
-
- return $phids;
- }
-
- public function getRemarkupBlocks() {
- $blocks = parent::getRemarkupBlocks();
- switch ($this->getTransactionType()) {
- case self::TYPE_CONTENT:
- $blocks[] = $this->getNewValue();
- break;
- }
- return $blocks;
- }
-
- public function shouldHide() {
- switch ($this->getTransactionType()) {
- case self::TYPE_QUESTION_ID:
- return true;
- }
- return parent::shouldHide();
- }
-
- public function getTitle() {
- $author_phid = $this->getAuthorPHID();
- $object_phid = $this->getObjectPHID();
-
- $old = $this->getOldValue();
- $new = $this->getNewValue();
-
- switch ($this->getTransactionType()) {
- case self::TYPE_CONTENT:
- if ($old === '') {
- return pht(
- '%s added %s.',
- $this->renderHandleLink($author_phid),
- $this->renderHandleLink($object_phid));
- } else {
- return pht(
- '%s edited %s.',
- $this->renderHandleLink($author_phid),
- $this->renderHandleLink($object_phid));
- }
- break;
- case self::TYPE_STATUS:
- if ($new == PonderAnswerStatus::ANSWER_STATUS_VISIBLE) {
- return pht(
- '%s marked %s as visible.',
- $this->renderHandleLink($author_phid),
- $this->renderHandleLink($object_phid));
- } else if ($new == PonderAnswerStatus::ANSWER_STATUS_HIDDEN) {
- return pht(
- '%s marked %s as hidden.',
- $this->renderHandleLink($author_phid),
- $this->renderHandleLink($object_phid));
- }
- break;
- }
-
- return parent::getTitle();
- }
-
- public function getTitleForFeed() {
- $author_phid = $this->getAuthorPHID();
- $object_phid = $this->getObjectPHID();
-
- $old = $this->getOldValue();
- $new = $this->getNewValue();
-
- switch ($this->getTransactionType()) {
- case self::TYPE_CONTENT:
- if ($old === '') {
- return pht(
- '%s added %s.',
- $this->renderHandleLink($author_phid),
- $this->renderHandleLink($object_phid));
- } else {
- return pht(
- '%s updated %s.',
- $this->renderHandleLink($author_phid),
- $this->renderHandleLink($object_phid));
- }
- break;
- case self::TYPE_STATUS:
- if ($new == PonderAnswerStatus::ANSWER_STATUS_VISIBLE) {
- return pht(
- '%s marked %s as visible.',
- $this->renderHandleLink($author_phid),
- $this->renderHandleLink($object_phid));
- } else if ($new == PonderAnswerStatus::ANSWER_STATUS_HIDDEN) {
- return pht(
- '%s marked %s as hidden.',
- $this->renderHandleLink($author_phid),
- $this->renderHandleLink($object_phid));
- }
- break;
- }
-
- return parent::getTitleForFeed();
- }
-
- public function getRemarkupBodyForFeed(PhabricatorFeedStory $story) {
- $text = null;
- switch ($this->getTransactionType()) {
- case self::TYPE_CONTENT:
- $text = $this->getNewValue();
- break;
- }
- return $text;
- }
-
-
- public function hasChangeDetails() {
- $old = $this->getOldValue();
-
- switch ($this->getTransactionType()) {
- case self::TYPE_CONTENT:
- return $old !== null;
- }
- return parent::hasChangeDetails();
- }
-
- public function renderChangeDetails(PhabricatorUser $viewer) {
- return $this->renderTextCorpusChangeDetails(
- $viewer,
- $this->getOldValue(),
- $this->getNewValue());
+ public function getBaseTransactionClass() {
+ return 'PonderAnswerTransactionType';
}
}
diff --git a/src/applications/ponder/xaction/PonderAnswerContentTransaction.php b/src/applications/ponder/xaction/PonderAnswerContentTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/ponder/xaction/PonderAnswerContentTransaction.php
@@ -0,0 +1,56 @@
+<?php
+
+final class PonderAnswerContentTransaction
+ extends PonderAnswerTransactionType {
+
+ const TRANSACTIONTYPE = 'ponder.answer:content';
+
+ public function generateOldValue($object) {
+ return $object->getContent();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setContent($value);
+ }
+
+ public function getTitle() {
+ return pht(
+ '%s updated the answer details.',
+ $this->renderAuthor());
+ }
+
+ public function getTitleForFeed() {
+ return pht(
+ '%s updated the answer details for %s.',
+ $this->renderAuthor(),
+ $this->renderObject());
+ }
+
+ public function hasChangeDetailView() {
+ return true;
+ }
+
+ public function getMailDiffSectionHeader() {
+ return pht('CHANGES TO ANSWER DETAILS');
+ }
+
+ public function newChangeDetailView() {
+ $viewer = $this->getViewer();
+
+ return id(new PhabricatorApplicationTransactionTextDiffDetailView())
+ ->setViewer($viewer)
+ ->setOldText($this->getOldValue())
+ ->setNewText($this->getNewValue());
+ }
+
+ public function newRemarkupChanges() {
+ $changes = array();
+
+ $changes[] = $this->newRemarkupChange()
+ ->setOldValue($this->getOldValue())
+ ->setNewValue($this->getNewValue());
+
+ return $changes;
+ }
+
+}
diff --git a/src/applications/ponder/xaction/PonderAnswerQuestionIDTransaction.php b/src/applications/ponder/xaction/PonderAnswerQuestionIDTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/ponder/xaction/PonderAnswerQuestionIDTransaction.php
@@ -0,0 +1,16 @@
+<?php
+
+final class PonderAnswerQuestionIDTransaction
+ extends PonderAnswerTransactionType {
+
+ const TRANSACTIONTYPE = 'ponder.answer:question-id';
+
+ public function generateOldValue($object) {
+ return $object->getQuestionID();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setQuestionID($value);
+ }
+
+}
diff --git a/src/applications/ponder/xaction/PonderAnswerStatusTransaction.php b/src/applications/ponder/xaction/PonderAnswerStatusTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/ponder/xaction/PonderAnswerStatusTransaction.php
@@ -0,0 +1,62 @@
+<?php
+
+final class PonderAnswerStatusTransaction
+ extends PonderAnswerTransactionType {
+
+ const TRANSACTIONTYPE = 'ponder.answer:status';
+
+ public function generateOldValue($object) {
+ return $object->getStatus();
+ }
+
+ public function applyInternalEffects($object, $value) {
+ $object->setStatus($value);
+ }
+
+ public function getTitle() {
+ $new = $this->getNewValue();
+ if ($new == PonderAnswerStatus::ANSWER_STATUS_VISIBLE) {
+ return pht(
+ '%s marked this answer as visible.',
+ $this->renderAuthor());
+ } else if ($new == PonderAnswerStatus::ANSWER_STATUS_HIDDEN) {
+ return pht(
+ '%s marked this answer as hidden.',
+ $this->renderAuthor());
+ }
+ }
+
+ public function getTitleForFeed() {
+ $new = $this->getNewValue();
+ if ($new == PonderAnswerStatus::ANSWER_STATUS_VISIBLE) {
+ return pht(
+ '%s marked %s as visible.',
+ $this->renderAuthor(),
+ $this->renderObject());
+ } else if ($new == PonderAnswerStatus::ANSWER_STATUS_HIDDEN) {
+ return pht(
+ '%s marked %s as hidden.',
+ $this->renderAuthor(),
+ $this->renderObject());
+ }
+ }
+
+ public function getIcon() {
+ $new = $this->getNewValue();
+ if ($new == PonderAnswerStatus::ANSWER_STATUS_VISIBLE) {
+ return 'fa-ban';
+ } else if ($new == PonderAnswerStatus::ANSWER_STATUS_HIDDEN) {
+ return 'fa-check';
+ }
+ }
+
+ public function getColor() {
+ $new = $this->getNewValue();
+ if ($new == PonderAnswerStatus::ANSWER_STATUS_VISIBLE) {
+ return 'green';
+ } else if ($new == PonderAnswerStatus::ANSWER_STATUS_HIDDEN) {
+ return 'indigo';
+ }
+ }
+
+}
diff --git a/src/applications/ponder/xaction/PonderAnswerTransactionType.php b/src/applications/ponder/xaction/PonderAnswerTransactionType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/ponder/xaction/PonderAnswerTransactionType.php
@@ -0,0 +1,4 @@
+<?php
+
+abstract class PonderAnswerTransactionType
+ extends PhabricatorModularTransactionType {}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 20, 5:47 AM (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6735323
Default Alt Text
D17811.id42828.diff (16 KB)
Attached To
Mode
D17811: Convert PonderAnswer to modular transactions
Attached
Detach File
Event Timeline
Log In to Comment