Changeset View
Changeset View
Standalone View
Standalone View
src/applications/nuance/storage/NuanceSourceTransaction.php
| <?php | <?php | ||||
| final class NuanceSourceTransaction | final class NuanceSourceTransaction | ||||
| extends NuanceTransaction { | extends NuanceTransaction { | ||||
| const TYPE_NAME = 'name-source'; | const TYPE_NAME = 'source.name'; | ||||
| const TYPE_DEFAULT_QUEUE = 'source.queue.default'; | |||||
| public function getApplicationTransactionType() { | public function getApplicationTransactionType() { | ||||
| return NuanceSourcePHIDType::TYPECONST; | return NuanceSourcePHIDType::TYPECONST; | ||||
| } | } | ||||
| public function getApplicationTransactionCommentObject() { | public function getApplicationTransactionCommentObject() { | ||||
| return new NuanceSourceTransactionComment(); | return new NuanceSourceTransactionComment(); | ||||
| } | } | ||||
| public function shouldHide() { | |||||
| $old = $this->getOldValue(); | |||||
| $new = $this->getNewValue(); | |||||
| $type = $this->getTransactionType(); | |||||
| switch ($type) { | |||||
| case self::TYPE_DEFAULT_QUEUE: | |||||
| return !$old; | |||||
| case self::TYPE_NAME: | |||||
| return ($old === null); | |||||
| } | |||||
| return parent::shouldHide(); | |||||
| } | |||||
| public function getRequiredHandlePHIDs() { | |||||
| $old = $this->getOldValue(); | |||||
| $new = $this->getNewValue(); | |||||
| $type = $this->getTransactionType(); | |||||
| $phids = parent::getRequiredHandlePHIDs(); | |||||
| switch ($type) { | |||||
| case self::TYPE_DEFAULT_QUEUE: | |||||
| if ($old) { | |||||
| $phids[] = $old; | |||||
| } | |||||
| if ($new) { | |||||
| $phids[] = $new; | |||||
| } | |||||
| break; | |||||
| } | |||||
| return $phids; | |||||
| } | |||||
| public function getTitle() { | public function getTitle() { | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| $type = $this->getTransactionType(); | |||||
| $author_phid = $this->getAuthorPHID(); | $author_phid = $this->getAuthorPHID(); | ||||
| switch ($this->getTransactionType()) { | switch ($type) { | ||||
| case self::TYPE_NAME: | case self::TYPE_DEFAULT_QUEUE: | ||||
| if ($old === null) { | |||||
| return pht( | return pht( | ||||
| '%s created this source.', | '%s changed the default queue from %s to %s.', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid), | ||||
| } else { | $this->renderHandleLink($old), | ||||
| $this->renderHandleLink($new)); | |||||
| case self::TYPE_NAME: | |||||
| return pht( | return pht( | ||||
| '%s renamed this source from "%s" to "%s".', | '%s renamed this source from "%s" to "%s".', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $old, | $old, | ||||
| $new); | $new); | ||||
| } | } | ||||
| break; | |||||
| } | |||||
| return parent::getTitle(); | |||||
| } | } | ||||
| } | } | ||||