4 * @task docs Command Documentation
6 abstract class MetaMTAEmailTransactionCommand
extends Phobject
{
8 abstract public function getCommand();
11 * Return a brief human-readable description of the command effect.
13 * This should normally be one or two sentences briefly describing the
16 * @return string Brief human-readable remarkup.
19 abstract public function getCommandSummary();
23 * Return a one-line Remarkup description of command syntax for documentation.
25 * @return string Brief human-readable remarkup.
28 public function getCommandSyntax() {
29 return '**!'.$this->getCommand().'**';
33 * Return a longer human-readable description of the command effect.
35 * This can be as long as necessary to explain the command.
37 * @return string Human-readable remarkup of whatever length is desired.
40 public function getCommandDescription() {
44 abstract public function isCommandSupportedForObject(
45 PhabricatorApplicationTransactionInterface
$object);
47 abstract public function buildTransactions(
48 PhabricatorUser
$viewer,
49 PhabricatorApplicationTransactionInterface
$object,
50 PhabricatorMetaMTAReceivedMail
$mail,
54 public function getCommandAliases() {
58 public function getCommandObjects() {
62 public static function getAllCommands() {
63 return id(new PhutilClassMapQuery())
64 ->setAncestorClass(__CLASS__
)
65 ->setExpandMethod('getCommandObjects')
66 ->setUniqueMethod('getCommand')
70 public static function getAllCommandsForObject(
71 PhabricatorApplicationTransactionInterface
$object) {
73 $commands = self
::getAllCommands();
74 foreach ($commands as $key => $command) {
75 if (!$command->isCommandSupportedForObject($object)) {
76 unset($commands[$key]);
83 public static function getCommandMap(array $commands) {
84 assert_instances_of($commands, __CLASS__
);
87 foreach ($commands as $command) {
88 $keywords = $command->getCommandAliases();
89 $keywords[] = $command->getCommand();
91 foreach ($keywords as $keyword) {
92 $keyword = phutil_utf8_strtolower($keyword);
93 if (empty($map[$keyword])) {
94 $map[$keyword] = $command;
98 'Mail commands "%s" and "%s" both respond to keyword "%s". '.
99 'Keywords must be uniquely associated with commands.',
101 get_class($map[$keyword]),