Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/storage/PhabricatorConfigTransaction.php
<?php | <?php | ||||
final class PhabricatorConfigTransaction | final class PhabricatorConfigTransaction | ||||
extends PhabricatorApplicationTransaction { | extends PhabricatorApplicationTransaction { | ||||
private $displayKeys = false; | |||||
const TYPE_EDIT = 'config:edit'; | const TYPE_EDIT = 'config:edit'; | ||||
public function getApplicationName() { | public function getApplicationName() { | ||||
return 'config'; | return 'config'; | ||||
} | } | ||||
public function getApplicationTransactionType() { | public function getApplicationTransactionType() { | ||||
return PhabricatorConfigConfigPHIDType::TYPECONST; | return PhabricatorConfigConfigPHIDType::TYPECONST; | ||||
} | } | ||||
public function getApplicationTransactionCommentObject() { | public function getApplicationTransactionCommentObject() { | ||||
return null; | return null; | ||||
} | } | ||||
public function setDisplayKeys($display_keys = false) { | |||||
$this->displayKeys = $display_keys; | |||||
return $this; | |||||
} | |||||
public function getTitle() { | public function getTitle() { | ||||
$author_phid = $this->getAuthorPHID(); | $author_phid = $this->getAuthorPHID(); | ||||
$old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case self::TYPE_EDIT: | case self::TYPE_EDIT: | ||||
// TODO: After T2213 show the actual values too; for now, we don't | // TODO: After T2213 show the actual values too; for now, we don't | ||||
// have the tools to do it without making a bit of a mess of it. | // have the tools to do it without making a bit of a mess of it. | ||||
$old_del = idx($old, 'deleted'); | $old_del = idx($old, 'deleted'); | ||||
$new_del = idx($new, 'deleted'); | $new_del = idx($new, 'deleted'); | ||||
if ($this->displayKeys) { | |||||
if ($old_del && !$new_del) { | |||||
return pht( | |||||
'%s created %s.', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->getObject()->getConfigKey()); | |||||
} else if (!$old_del && $new_del) { | |||||
return pht( | |||||
'%s deleted %s.', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->getObject()->getConfigKey()); | |||||
} else if ($old_del && $new_del) { | |||||
// This is a bug. | |||||
return pht( | |||||
'%s deleted %s (again?).', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->getObject()->getConfigKey()); | |||||
} else { | |||||
return pht( | |||||
'%s edited %s.', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->getObject()->getConfigKey()); | |||||
} | |||||
} else { | |||||
if ($old_del && !$new_del) { | if ($old_del && !$new_del) { | ||||
return pht( | return pht( | ||||
'%s created this configuration entry.', | '%s created this configuration entry.', | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
} else if (!$old_del && $new_del) { | } else if (!$old_del && $new_del) { | ||||
return pht( | return pht( | ||||
'%s deleted this configuration entry.', | '%s deleted this configuration entry.', | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
} else if ($old_del && $new_del) { | } else if ($old_del && $new_del) { | ||||
// This is a bug. | // This is a bug. | ||||
return pht( | return pht( | ||||
'%s deleted this configuration entry (again?).', | '%s deleted this configuration entry (again?).', | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
} else { | } else { | ||||
return pht( | return pht( | ||||
'%s edited this configuration entry.', | '%s edited this configuration entry.', | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
} | } | ||||
} | |||||
break; | break; | ||||
} | } | ||||
return parent::getTitle(); | return parent::getTitle(); | ||||
} | } | ||||
public function getIcon() { | public function getIcon() { | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |