Changeset View
Changeset View
Standalone View
Standalone View
src/applications/chronicle/storage/ChronicleTriggerTransaction.php
- This file was added.
<?php | |||||
final class ChronicleTriggerTransaction | |||||
extends PhabricatorApplicationTransaction { | |||||
const TYPE_CREATE = 'trigger:create'; | |||||
const TYPE_NAME = 'trigger:name'; | |||||
const TYPE_CONFIG = 'trigger:config'; | |||||
public function getApplicationName() { | |||||
return 'chronicle'; | |||||
} | |||||
public function getApplicationTransactionType() { | |||||
return ChroniclePHIDTypeTrigger::TYPECONST; | |||||
} | |||||
public function getTitle() { | |||||
$author_phid = $this->getAuthorPHID(); | |||||
$old = $this->getOldValue(); | |||||
$new = $this->getNewValue(); | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_CREATE: | |||||
return pht( | |||||
'%s created this trigger.', | |||||
$this->renderHandleLink($author_phid)); | |||||
case self::TYPE_NAME: | |||||
if ($old === null) { | |||||
return pht( | |||||
'%s set the name to "%s".', | |||||
$this->renderHandleLink($author_phid), | |||||
$new); | |||||
} else { | |||||
return pht( | |||||
'%s changed the name from "%s" to "%s".', | |||||
$this->renderHandleLink($author_phid), | |||||
$old, | |||||
$new); | |||||
} | |||||
case self::TYPE_CONFIG: | |||||
return pht( | |||||
'%s updated the trigger configuration.', | |||||
$this->renderHandleLink($author_phid)); | |||||
} | |||||
return parent::getTitle(); | |||||
} | |||||
public function getIcon() { | |||||
$author_phid = $this->getAuthorPHID(); | |||||
$old = $this->getOldValue(); | |||||
$new = $this->getNewValue(); | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_CREATE: | |||||
return 'fa-plus'; | |||||
} | |||||
return parent::getIcon(); | |||||
} | |||||
public function getColor() { | |||||
$author_phid = $this->getAuthorPHID(); | |||||
$old = $this->getOldValue(); | |||||
$new = $this->getNewValue(); | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_CREATE: | |||||
return 'green'; | |||||
} | |||||
return parent::getColor(); | |||||
} | |||||
} |