Differential D17671 Diff 42514 src/applications/countdown/storage/PhabricatorCountdownTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/countdown/storage/PhabricatorCountdownTransaction.php
<?php | <?php | ||||
final class PhabricatorCountdownTransaction | final class PhabricatorCountdownTransaction | ||||
extends PhabricatorApplicationTransaction { | extends PhabricatorModularTransaction { | ||||
const TYPE_TITLE = 'countdown:title'; | |||||
const TYPE_EPOCH = 'countdown:epoch'; | |||||
const TYPE_DESCRIPTION = 'countdown:description'; | |||||
const MAILTAG_DETAILS = 'countdown:details'; | const MAILTAG_DETAILS = 'countdown:details'; | ||||
const MAILTAG_COMMENT = 'countdown:comment'; | const MAILTAG_COMMENT = 'countdown:comment'; | ||||
const MAILTAG_OTHER = 'countdown:other'; | const MAILTAG_OTHER = 'countdown:other'; | ||||
public function getApplicationName() { | public function getApplicationName() { | ||||
return 'countdown'; | return 'countdown'; | ||||
} | } | ||||
public function getApplicationTransactionType() { | public function getApplicationTransactionType() { | ||||
return PhabricatorCountdownCountdownPHIDType::TYPECONST; | return PhabricatorCountdownCountdownPHIDType::TYPECONST; | ||||
} | } | ||||
public function getApplicationTransactionCommentObject() { | public function getApplicationTransactionCommentObject() { | ||||
return new PhabricatorCountdownTransactionComment(); | return new PhabricatorCountdownTransactionComment(); | ||||
} | } | ||||
public function getTitle() { | public function getBaseTransactionClass() { | ||||
$author_phid = $this->getAuthorPHID(); | return 'PhabricatorCountdownTransactionType'; | ||||
$object_phid = $this->getObjectPHID(); | |||||
$old = $this->getOldValue(); | |||||
$new = $this->getNewValue(); | |||||
$type = $this->getTransactionType(); | |||||
switch ($type) { | |||||
case self::TYPE_TITLE: | |||||
return pht( | |||||
'%s renamed this countdown from "%s" to "%s".', | |||||
$this->renderHandleLink($author_phid), | |||||
$old, | |||||
$new); | |||||
case self::TYPE_DESCRIPTION: | |||||
return pht( | |||||
'%s edited the description of this countdown.', | |||||
$this->renderHandleLink($author_phid)); | |||||
case self::TYPE_EPOCH: | |||||
return pht( | |||||
'%s updated this countdown to end on %s.', | |||||
$this->renderHandleLink($author_phid), | |||||
phabricator_datetime($new, $this->getViewer())); | |||||
} | |||||
return parent::getTitle(); | |||||
} | |||||
public function getTitleForFeed() { | |||||
$author_phid = $this->getAuthorPHID(); | |||||
$object_phid = $this->getObjectPHID(); | |||||
$old = $this->getOldValue(); | |||||
$new = $this->getNewValue(); | |||||
$type = $this->getTransactionType(); | |||||
switch ($type) { | |||||
case self::TYPE_TITLE: | |||||
return pht( | |||||
'%s renamed %s.', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->renderHandleLink($object_phid)); | |||||
case self::TYPE_DESCRIPTION: | |||||
return pht( | |||||
'%s edited the description of %s.', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->renderHandleLink($object_phid)); | |||||
case self::TYPE_EPOCH: | |||||
return pht( | |||||
'%s edited the end date of %s.', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->renderHandleLink($object_phid)); | |||||
} | |||||
return parent::getTitleForFeed(); | |||||
} | } | ||||
public function getMailTags() { | public function getMailTags() { | ||||
$tags = parent::getMailTags(); | $tags = parent::getMailTags(); | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhabricatorTransactions::TYPE_COMMENT: | case PhabricatorTransactions::TYPE_COMMENT: | ||||
$tags[] = self::MAILTAG_COMMENT; | $tags[] = self::MAILTAG_COMMENT; | ||||
break; | break; | ||||
case self::TYPE_TITLE: | case PhabricatorCountdownTitleTransaction::TRANSACTIONTYPE: | ||||
case self::TYPE_EPOCH: | case PhabricatorCountdownEpochTransaction::TRANSACTIONTYPE: | ||||
case self::TYPE_DESCRIPTION: | case PhabricatorCountdownDescriptionTransaction::TRANSACTIONTYPE: | ||||
$tags[] = self::MAILTAG_DETAILS; | $tags[] = self::MAILTAG_DETAILS; | ||||
break; | break; | ||||
default: | default: | ||||
$tags[] = self::MAILTAG_OTHER; | $tags[] = self::MAILTAG_OTHER; | ||||
break; | break; | ||||
} | } | ||||
return $tags; | return $tags; | ||||
} | } | ||||
public function hasChangeDetails() { | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_DESCRIPTION: | |||||
return ($this->getOldValue() !== null); | |||||
} | |||||
return parent::hasChangeDetails(); | |||||
} | |||||
public function renderChangeDetails(PhabricatorUser $viewer) { | |||||
return $this->renderTextCorpusChangeDetails( | |||||
$viewer, | |||||
$this->getOldValue(), | |||||
$this->getNewValue()); | |||||
} | |||||
} | } |