1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-12 00:26:13 +01:00
phorge-phorge/src/applications/differential/command/DifferentialActionEmailCommand.php
epriestley 50de3071ac Define Differential email action in terms of EditEngine
Summary: Ref T11114. Move email/command actions, like "!reject", to modular transactions + editengine.

Test Plan: Used `bin/mail receive-test` to pipe "!stuff" to an object, saw appropraite effects in web UI.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11114

Differential Revision: https://secure.phabricator.com/D17133
2017-01-02 13:25:45 -08:00

103 lines
2.3 KiB
PHP

<?php
final class DifferentialActionEmailCommand
extends MetaMTAEmailTransactionCommand {
private $command;
private $action;
private $aliases;
private $commandSummary;
private $commandDescription;
public function getCommand() {
return $this->command;
}
private function setCommand($command) {
$this->command = $command;
return $this;
}
private function setAction($action) {
$this->action = $action;
return $this;
}
private function getAction() {
return $this->action;
}
private function setCommandAliases(array $aliases) {
$this->aliases = $aliases;
return $this;
}
public function getCommandAliases() {
return $this->aliases;
}
public function setCommandSummary($command_summary) {
$this->commandSummary = $command_summary;
return $this;
}
public function getCommandSummary() {
return $this->commandSummary;
}
public function setCommandDescription($command_description) {
$this->commandDescription = $command_description;
return $this;
}
public function getCommandDescription() {
return $this->commandDescription;
}
public function getCommandObjects() {
$actions = DifferentialRevisionActionTransaction::loadAllActions();
$actions = msort($actions, 'getRevisionActionOrderVector');
$objects = array();
foreach ($actions as $action) {
$keyword = $action->getCommandKeyword();
if ($keyword === null) {
continue;
}
$aliases = $action->getCommandAliases();
$summary = $action->getCommandSummary();
$object = id(new self())
->setCommand($keyword)
->setCommandAliases($aliases)
->setAction($action->getTransactionTypeConstant())
->setCommandSummary($summary);
$objects[] = $object;
}
return $objects;
}
public function isCommandSupportedForObject(
PhabricatorApplicationTransactionInterface $object) {
return ($object instanceof DifferentialRevision);
}
public function buildTransactions(
PhabricatorUser $viewer,
PhabricatorApplicationTransactionInterface $object,
PhabricatorMetaMTAReceivedMail $mail,
$command,
array $argv) {
$xactions = array();
$xactions[] = $object->getApplicationTransactionTemplate()
->setTransactionType($this->getAction())
->setNewValue(true);
return $xactions;
}
}