[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/metamta/management/ -> PhabricatorMailManagementResendWorkflow.php (source)

   1  <?php
   2  
   3  final class PhabricatorMailManagementResendWorkflow
   4    extends PhabricatorMailManagementWorkflow {
   5  
   6    protected function didConstruct() {
   7      $this
   8        ->setName('resend')
   9        ->setSynopsis('Send mail again.')
  10        ->setExamples(
  11          '**resend** --id 1 --id 2')
  12        ->setArguments(
  13          array(
  14            array(
  15              'name'    => 'id',
  16              'param'   => 'id',
  17              'help'    => 'Send mail with a given ID again.',
  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 messages to resend.");
  30      }
  31  
  32      $messages = id(new PhabricatorMetaMTAMail())->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 messages do not exist: '.
  42            implode(', ', array_keys($missing)));
  43        }
  44      }
  45  
  46      foreach ($messages as $message) {
  47        $message->setStatus(PhabricatorMetaMTAMail::STATUS_QUEUE);
  48        $message->save();
  49  
  50        $mailer_task = PhabricatorWorker::scheduleTask(
  51          'PhabricatorMetaMTAWorker',
  52          $message->getID(),
  53          PhabricatorWorker::PRIORITY_ALERTS);
  54  
  55        $console->writeOut(
  56          "Queued message #%d for resend.\n",
  57          $message->getID());
  58      }
  59    }
  60  
  61  }


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