resq/src/Command/TestSMSCommand.php

41 lines
1.1 KiB
PHP

<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use App\Service\RisingTideGateway;
class TestSMSCommand extends Command
{
protected $gateway;
protected function configure()
{
$this->setName('sms:test')
->setDescription('Sends a test SMS message.')
->setHelp('Sends a test SMS message.')
->addArgument('destination', InputArgument::REQUIRED, 'Destination number to send to');
}
public function __construct(RisingTideGateway $gateway)
{
$this->gateway = $gateway;
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$number = $input->getArgument('destination');
error_log('sending sms to ' . $number);
$msg = 'This is a test.';
$this->gateway->sendSMS($number, 'MOTOLITE', $msg);
return 0;
}
}