Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diviner/storage/DivinerLiveBookTransaction.php
| <?php | <?php | ||||
| final class DivinerLiveBookTransaction | final class DivinerLiveBookTransaction | ||||
| extends PhabricatorApplicationTransaction { | extends PhabricatorApplicationTransaction { | ||||
| const TYPE_ARCHIVED = 'diviner:book:archived'; | |||||
| public function getApplicationName() { | public function getApplicationName() { | ||||
| return 'diviner'; | return 'diviner'; | ||||
| } | } | ||||
| public function getApplicationTransactionType() { | public function getApplicationTransactionType() { | ||||
| return DivinerBookPHIDType::TYPECONST; | return DivinerBookPHIDType::TYPECONST; | ||||
| } | } | ||||
| public function getApplicationTransactionCommentObject() { | public function getApplicationTransactionCommentObject() { | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function getColor() { | |||||
| $old = $this->getOldValue(); | |||||
| $new = $this->getNewValue(); | |||||
| switch ($this->getTransactionType()) { | |||||
| case self::TYPE_ARCHIVED: | |||||
| if ($new) { | |||||
| return 'red'; | |||||
| } else { | |||||
| return 'green'; | |||||
| } | |||||
| default: | |||||
| return parent::getColor(); | |||||
| } | |||||
| } | |||||
| public function getIcon() { | |||||
| $old = $this->getOldValue(); | |||||
| $new = $this->getNewValue(); | |||||
| switch ($this->getTransactionType()) { | |||||
| case self::TYPE_ARCHIVED: | |||||
| if ($new) { | |||||
| return 'fa-ban'; | |||||
| } else { | |||||
| return 'fa-check'; | |||||
| } | |||||
| default: | |||||
| return parent::getIcon(); | |||||
| } | |||||
| } | |||||
| public function getTitle() { | |||||
| $old = $this->getOldValue(); | |||||
| $new = $this->getNewValue(); | |||||
| $author_handle = $this->renderHandleLink($this->getAuthorPHID()); | |||||
| switch ($this->getTransactionType()) { | |||||
| case self::TYPE_ARCHIVED: | |||||
| if ($new) { | |||||
| return pht( | |||||
| '%s archived this book.', | |||||
| $author_handle); | |||||
| } else { | |||||
| return pht( | |||||
| '%s activated this book.', | |||||
| $author_handle); | |||||
| } | |||||
| break; | |||||
| default: | |||||
| return parent::getTitle(); | |||||
| } | |||||
| } | |||||
| public function getTitleForFeed() { | |||||
| $author_phid = $this->getAuthorPHID(); | |||||
| $object_phid = $this->getObjectPHID(); | |||||
| $author_handle = $this->renderHandleLink($author_phid); | |||||
| $object_handle = $this->renderHandleLink($object_phid); | |||||
| $old = $this->getOldValue(); | |||||
| $new = $this->getNewValue(); | |||||
| switch ($this->getTransactionType()) { | |||||
| case self::TYPE_ARCHIVED: | |||||
| if ($new) { | |||||
| return pht( | |||||
| '%s archived %s.', | |||||
| $author_handle, | |||||
| $object_handle); | |||||
| } else { | |||||
| return pht( | |||||
| '%s activated %s.', | |||||
| $author_handle, | |||||
| $object_handle); | |||||
| } | |||||
| default: | |||||
| return parent::getTitleForFeed(); | |||||
| } | |||||
| } | |||||
| } | } | ||||