Differential D17133 Diff 41202 src/applications/differential/command/DifferentialActionEmailCommand.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/command/DifferentialActionEmailCommand.php
| Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | public function setCommandDescription($command_description) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getCommandDescription() { | public function getCommandDescription() { | ||||
| return $this->commandDescription; | return $this->commandDescription; | ||||
| } | } | ||||
| public function getCommandObjects() { | public function getCommandObjects() { | ||||
| $actions = array( | $actions = DifferentialRevisionActionTransaction::loadAllActions(); | ||||
| DifferentialAction::ACTION_REJECT => 'request', | $actions = msort($actions, 'getRevisionActionOrderVector'); | ||||
| DifferentialAction::ACTION_ABANDON => 'abandon', | |||||
| DifferentialAction::ACTION_RECLAIM => 'reclaim', | |||||
| DifferentialAction::ACTION_RESIGN => 'resign', | |||||
| DifferentialAction::ACTION_RETHINK => 'planchanges', | |||||
| DifferentialAction::ACTION_CLAIM => 'commandeer', | |||||
| ); | |||||
| if (PhabricatorEnv::getEnvConfig('differential.enable-email-accept')) { | |||||
| $actions[DifferentialAction::ACTION_ACCEPT] = 'accept'; | |||||
| } | |||||
| $aliases = array( | |||||
| DifferentialAction::ACTION_REJECT => array('reject'), | |||||
| DifferentialAction::ACTION_CLAIM => array('claim'), | |||||
| DifferentialAction::ACTION_RETHINK => array('rethink'), | |||||
| ); | |||||
| $summaries = array( | |||||
| DifferentialAction::ACTION_REJECT => | |||||
| pht('Request changes to a revision.'), | |||||
| DifferentialAction::ACTION_ABANDON => | |||||
| pht('Abandon a revision.'), | |||||
| DifferentialAction::ACTION_RECLAIM => | |||||
| pht('Reclaim a revision.'), | |||||
| DifferentialAction::ACTION_RESIGN => | |||||
| pht('Resign from a revision.'), | |||||
| DifferentialAction::ACTION_RETHINK => | |||||
| pht('Plan changes to a revision.'), | |||||
| DifferentialAction::ACTION_CLAIM => | |||||
| pht('Commandeer a revision.'), | |||||
| DifferentialAction::ACTION_ACCEPT => | |||||
| pht('Accept a revision.'), | |||||
| ); | |||||
| $descriptions = array( | |||||
| ); | |||||
| $objects = array(); | $objects = array(); | ||||
| foreach ($actions as $action => $keyword) { | foreach ($actions as $action) { | ||||
| $object = id(new DifferentialActionEmailCommand()) | $keyword = $action->getCommandKeyword(); | ||||
| ->setCommand($keyword) | if ($keyword === null) { | ||||
| ->setAction($action) | continue; | ||||
| ->setCommandSummary($summaries[$action]); | |||||
| if (isset($aliases[$action])) { | |||||
| $object->setCommandAliases($aliases[$action]); | |||||
| } | } | ||||
| if (isset($descriptions[$action])) { | $aliases = $action->getCommandAliases(); | ||||
| $object->setCommandDescription($descriptions[$action]); | $summary = $action->getCommandSummary(); | ||||
| } | |||||
| $object = id(new self()) | |||||
| ->setCommand($keyword) | |||||
| ->setCommandAliases($aliases) | |||||
| ->setAction($action->getTransactionTypeConstant()) | |||||
| ->setCommandSummary($summary); | |||||
| $objects[] = $object; | $objects[] = $object; | ||||
| } | } | ||||
| return $objects; | return $objects; | ||||
| } | } | ||||
| public function isCommandSupportedForObject( | public function isCommandSupportedForObject( | ||||
| PhabricatorApplicationTransactionInterface $object) { | PhabricatorApplicationTransactionInterface $object) { | ||||
| return ($object instanceof DifferentialRevision); | return ($object instanceof DifferentialRevision); | ||||
| } | } | ||||
| public function buildTransactions( | public function buildTransactions( | ||||
| PhabricatorUser $viewer, | PhabricatorUser $viewer, | ||||
| PhabricatorApplicationTransactionInterface $object, | PhabricatorApplicationTransactionInterface $object, | ||||
| PhabricatorMetaMTAReceivedMail $mail, | PhabricatorMetaMTAReceivedMail $mail, | ||||
| $command, | $command, | ||||
| array $argv) { | array $argv) { | ||||
| $xactions = array(); | $xactions = array(); | ||||
| $xactions[] = $object->getApplicationTransactionTemplate() | $xactions[] = $object->getApplicationTransactionTemplate() | ||||
| ->setTransactionType(DifferentialTransaction::TYPE_ACTION) | ->setTransactionType($this->getAction()) | ||||
| ->setNewValue($this->getAction()); | ->setNewValue(true); | ||||
| return $xactions; | return $xactions; | ||||
| } | } | ||||
| } | } | ||||