[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/infrastructure/sms/management/ -> PhabricatorSMSManagementShowOutboundWorkflow.php (source)

   1  <?php
   2  
   3  final class PhabricatorSMSManagementShowOutboundWorkflow
   4    extends PhabricatorSMSManagementWorkflow {
   5  
   6    protected function didConstruct() {
   7      $this
   8        ->setName('show-outbound')
   9        ->setSynopsis('Show diagnostic details about outbound sms.')
  10        ->setExamples(
  11          '**show-outbound** --id 1 --id 2')
  12        ->setArguments(
  13          array(
  14            array(
  15              'name'    => 'id',
  16              'param'   => 'id',
  17              'help'    => 'Show details about outbound sms with given ID.',
  18              'repeat'  => true,
  19            ),
  20          ));
  21    }
  22  
  23    public function execute(PhutilArgumentParser $args) {
  24      $console = PhutilConsole::getConsole();
  25  
  26      $ids = $args->getArg('id');
  27      if (!$ids) {
  28        throw new PhutilArgumentUsageException(
  29          "Use the '--id' flag to specify one or more sms messages to show.");
  30      }
  31  
  32      $messages = id(new PhabricatorSMS())->loadAllWhere(
  33        'id IN (%Ld)',
  34        $ids);
  35  
  36      if ($ids) {
  37        $ids = array_fuse($ids);
  38        $missing = array_diff_key($ids, $messages);
  39        if ($missing) {
  40          throw new PhutilArgumentUsageException(
  41            'Some specified sms messages do not exist: '.
  42            implode(', ', array_keys($missing)));
  43        }
  44      }
  45  
  46      $last_key = last_key($messages);
  47      foreach ($messages as $message_key => $message) {
  48        $info = array();
  49  
  50        $info[] = pht('PROPERTIES');
  51        $info[] = pht('ID: %d', $message->getID());
  52        $info[] = pht('Status: %s', $message->getSendStatus());
  53        $info[] = pht('To: %s', $message->getToNumber());
  54        $info[] = pht('From: %s', $message->getFromNumber());
  55  
  56        $info[] = null;
  57        $info[] = pht('BODY');
  58        $info[] = $message->getBody();
  59        $info[] = null;
  60  
  61        $console->writeOut('%s', implode("\n", $info));
  62  
  63        if ($message_key != $last_key) {
  64          $console->writeOut("\n%s\n\n", str_repeat('-', 80));
  65        }
  66      }
  67    }
  68  
  69  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1