2012-10-07 23:35:01 +02:00
|
|
|
<?php
|
|
|
|
|
2013-07-29 00:02:18 +02:00
|
|
|
final class PonderQuestionEditor
|
|
|
|
extends PhabricatorApplicationTransactionEditor {
|
2012-10-07 23:35:01 +02:00
|
|
|
|
2013-07-29 00:02:18 +02:00
|
|
|
public function getTransactionTypes() {
|
|
|
|
$types = parent::getTransactionTypes();
|
2012-10-07 23:35:01 +02:00
|
|
|
|
2013-07-29 00:02:18 +02:00
|
|
|
$types[] = PhabricatorTransactions::TYPE_COMMENT;
|
|
|
|
$types[] = PonderQuestionTransaction::TYPE_TITLE;
|
|
|
|
$types[] = PonderQuestionTransaction::TYPE_CONTENT;
|
|
|
|
|
|
|
|
return $types;
|
2012-10-07 23:35:01 +02:00
|
|
|
}
|
2013-07-29 00:02:18 +02:00
|
|
|
protected function getCustomTransactionOldValue(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
2012-10-07 23:35:01 +02:00
|
|
|
|
2013-07-29 00:02:18 +02:00
|
|
|
switch ($xaction->getTransactionType()) {
|
|
|
|
case PonderQuestionTransaction::TYPE_TITLE:
|
|
|
|
return $object->getTitle();
|
|
|
|
case PonderQuestionTransaction::TYPE_CONTENT:
|
|
|
|
return $object->getContent();
|
|
|
|
}
|
2012-10-08 23:47:21 +02:00
|
|
|
}
|
|
|
|
|
2013-07-29 00:02:18 +02:00
|
|
|
protected function getCustomTransactionNewValue(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
|
|
case PonderQuestionTransaction::TYPE_TITLE:
|
|
|
|
case PonderQuestionTransaction::TYPE_CONTENT:
|
|
|
|
return $xaction->getNewValue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function applyCustomInternalTransaction(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
|
|
|
|
switch ($xaction->getTransactionType()) {
|
|
|
|
case PonderQuestionTransaction::TYPE_TITLE:
|
|
|
|
$object->setTitle($xaction->getNewValue());
|
|
|
|
break;
|
|
|
|
case PonderQuestionTransaction::TYPE_CONTENT:
|
|
|
|
$object->setContent($xaction->getNewValue());
|
|
|
|
break;
|
2012-10-07 23:35:01 +02:00
|
|
|
}
|
2013-07-29 00:02:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function applyCustomExternalTransaction(
|
|
|
|
PhabricatorLiskDAO $object,
|
|
|
|
PhabricatorApplicationTransaction $xaction) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function mergeTransactions(
|
|
|
|
PhabricatorApplicationTransaction $u,
|
|
|
|
PhabricatorApplicationTransaction $v) {
|
2012-10-07 23:35:01 +02:00
|
|
|
|
2013-07-29 00:02:18 +02:00
|
|
|
$type = $u->getTransactionType();
|
|
|
|
switch ($type) {
|
|
|
|
case PonderQuestionTransaction::TYPE_TITLE:
|
|
|
|
case PonderQuestionTransaction::TYPE_CONTENT:
|
|
|
|
return $v;
|
2012-10-08 23:47:21 +02:00
|
|
|
}
|
2013-07-29 00:02:18 +02:00
|
|
|
|
|
|
|
return parent::mergeTransactions($u, $v);
|
2012-10-07 23:35:01 +02:00
|
|
|
}
|
2013-07-29 00:02:18 +02:00
|
|
|
|
|
|
|
// TODO: Feed support
|
|
|
|
// TODO: Mail support
|
|
|
|
// TODO: Add/remove answers
|
|
|
|
|
2012-10-07 23:35:01 +02:00
|
|
|
}
|