Differential D17115 Diff 41172 src/applications/differential/xaction/DifferentialRevisionCloseTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/xaction/DifferentialRevisionCloseTransaction.php
| Show All 16 Lines | final class DifferentialRevisionCloseTransaction | ||||
| public function getIcon() { | public function getIcon() { | ||||
| return 'fa-check'; | return 'fa-check'; | ||||
| } | } | ||||
| public function getColor() { | public function getColor() { | ||||
| return 'indigo'; | return 'indigo'; | ||||
| } | } | ||||
| protected function getRevisionActionOrder() { | |||||
| return 300; | |||||
| } | |||||
| public function generateOldValue($object) { | public function generateOldValue($object) { | ||||
| return $object->isClosed(); | return $object->isClosed(); | ||||
| } | } | ||||
| public function applyInternalEffects($object, $value) { | public function applyInternalEffects($object, $value) { | ||||
| $status_closed = ArcanistDifferentialRevisionStatus::CLOSED; | $status_closed = ArcanistDifferentialRevisionStatus::CLOSED; | ||||
| $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED; | $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED; | ||||
| Show All 11 Lines | final class DifferentialRevisionCloseTransaction | ||||
| protected function validateAction($object, PhabricatorUser $viewer) { | protected function validateAction($object, PhabricatorUser $viewer) { | ||||
| if ($object->isClosed()) { | if ($object->isClosed()) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'You can not close this revision because it has already been '. | 'You can not close this revision because it has already been '. | ||||
| 'closed. Only open revisions can be closed.')); | 'closed. Only open revisions can be closed.')); | ||||
| } | } | ||||
| if (!$object->isAccepted()) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'You can not close this revision because it has not been accepted. '. | |||||
| 'Revisions must be accepted before they can be closed.')); | |||||
| } | |||||
| $config_key = 'differential.always-allow-close'; | $config_key = 'differential.always-allow-close'; | ||||
| if (!PhabricatorEnv::getEnvConfig($config_key)) { | if (!PhabricatorEnv::getEnvConfig($config_key)) { | ||||
| if (!$this->isViewerRevisionAuthor($object, $viewer)) { | if (!$this->isViewerRevisionAuthor($object, $viewer)) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'You can not close this revision because you are not the '. | 'You can not close this revision because you are not the '. | ||||
| 'author. You can only close revisions you own. You can change '. | 'author. You can only close revisions you own. You can change '. | ||||
| 'this behavior by adjusting the "%s" setting in Config.', | 'this behavior by adjusting the "%s" setting in Config.', | ||||
| Show All 19 Lines | |||||