Path: blob/master/src/applications/metamta/command/MetaMTAEmailTransactionCommand.php
12256 views
<?php12/**3* @task docs Command Documentation4*/5abstract class MetaMTAEmailTransactionCommand extends Phobject {67abstract public function getCommand();89/**10* Return a brief human-readable description of the command effect.11*12* This should normally be one or two sentences briefly describing the13* command behavior.14*15* @return string Brief human-readable remarkup.16* @task docs17*/18abstract public function getCommandSummary();192021/**22* Return a one-line Remarkup description of command syntax for documentation.23*24* @return string Brief human-readable remarkup.25* @task docs26*/27public function getCommandSyntax() {28return '**!'.$this->getCommand().'**';29}3031/**32* Return a longer human-readable description of the command effect.33*34* This can be as long as necessary to explain the command.35*36* @return string Human-readable remarkup of whatever length is desired.37* @task docs38*/39public function getCommandDescription() {40return null;41}4243abstract public function isCommandSupportedForObject(44PhabricatorApplicationTransactionInterface $object);4546abstract public function buildTransactions(47PhabricatorUser $viewer,48PhabricatorApplicationTransactionInterface $object,49PhabricatorMetaMTAReceivedMail $mail,50$command,51array $argv);5253public function getCommandAliases() {54return array();55}5657public function getCommandObjects() {58return array($this);59}6061public static function getAllCommands() {62return id(new PhutilClassMapQuery())63->setAncestorClass(__CLASS__)64->setExpandMethod('getCommandObjects')65->setUniqueMethod('getCommand')66->execute();67}6869public static function getAllCommandsForObject(70PhabricatorApplicationTransactionInterface $object) {7172$commands = self::getAllCommands();73foreach ($commands as $key => $command) {74if (!$command->isCommandSupportedForObject($object)) {75unset($commands[$key]);76}77}7879return $commands;80}8182public static function getCommandMap(array $commands) {83assert_instances_of($commands, __CLASS__);8485$map = array();86foreach ($commands as $command) {87$keywords = $command->getCommandAliases();88$keywords[] = $command->getCommand();8990foreach ($keywords as $keyword) {91$keyword = phutil_utf8_strtolower($keyword);92if (empty($map[$keyword])) {93$map[$keyword] = $command;94} else {95throw new Exception(96pht(97'Mail commands "%s" and "%s" both respond to keyword "%s". '.98'Keywords must be uniquely associated with commands.',99get_class($command),100get_class($map[$keyword]),101$keyword));102}103}104}105106return $map;107}108109}110111112