2016-09-03 01:41:17 +00:00
|
|
|
<?php
|
2016-09-18 00:00:46 +00:00
|
|
|
namespace App\Console\Command;
|
2016-09-03 01:41:17 +00:00
|
|
|
|
2016-09-18 00:00:46 +00:00
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
class RestartRadio extends CommandAbstract
|
2016-09-03 01:41:17 +00:00
|
|
|
{
|
|
|
|
/**
|
2016-09-18 00:00:46 +00:00
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
protected function configure()
|
|
|
|
{
|
|
|
|
$this->setName('radio:restart')
|
|
|
|
->setDescription('Restart all radio stations.');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
2016-09-03 01:41:17 +00:00
|
|
|
*/
|
2016-09-18 00:00:46 +00:00
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
2016-09-03 01:41:17 +00:00
|
|
|
{
|
|
|
|
\App\Debug::setEchoMode(true);
|
|
|
|
|
|
|
|
\App\Debug::log('Restarting all radio stations...');
|
|
|
|
\App\Debug::divider();
|
|
|
|
|
|
|
|
$stations = \Entity\Station::fetchAll();
|
|
|
|
|
|
|
|
foreach($stations as $station)
|
|
|
|
{
|
|
|
|
\App\Debug::log('Restarting station #'.$station->id.': '.$station->name);
|
|
|
|
|
|
|
|
$backend = $station->getBackendAdapter();
|
|
|
|
$frontend = $station->getFrontendAdapter();
|
|
|
|
|
|
|
|
$backend->stop();
|
|
|
|
$frontend->stop();
|
|
|
|
|
|
|
|
$frontend->write();
|
|
|
|
$backend->write();
|
|
|
|
|
|
|
|
$frontend->start();
|
|
|
|
$backend->start();
|
|
|
|
|
|
|
|
\App\Debug::divider();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|