2019-09-10 23:10:57 +00:00
|
|
|
<?php
|
2020-10-14 22:19:31 +00:00
|
|
|
|
2021-07-19 05:53:45 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-09-10 23:10:57 +00:00
|
|
|
namespace App\Console\Command\Internal;
|
|
|
|
|
2020-06-26 20:22:53 +00:00
|
|
|
use App\Console\Command\CommandAbstract;
|
2019-09-10 23:10:57 +00:00
|
|
|
use App\Entity;
|
|
|
|
use App\Radio\Adapters;
|
|
|
|
use App\Radio\Backend\Liquidsoap;
|
2020-06-26 20:22:53 +00:00
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
2019-09-10 23:10:57 +00:00
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
|
|
|
|
class DjOnCommand extends CommandAbstract
|
|
|
|
{
|
|
|
|
public function __invoke(
|
|
|
|
SymfonyStyle $io,
|
2020-06-26 20:22:53 +00:00
|
|
|
EntityManagerInterface $em,
|
2019-09-10 23:10:57 +00:00
|
|
|
Adapters $adapters,
|
2020-01-29 02:23:55 +00:00
|
|
|
int $stationId,
|
|
|
|
string $djUser = ''
|
2020-10-14 22:19:31 +00:00
|
|
|
): int {
|
2019-09-10 23:10:57 +00:00
|
|
|
$station = $em->find(Entity\Station::class, $stationId);
|
|
|
|
|
|
|
|
if (!($station instanceof Entity\Station) || !$station->getEnableStreamers()) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$adapter = $adapters->getBackendAdapter($station);
|
|
|
|
|
|
|
|
if ($adapter instanceof Liquidsoap) {
|
2020-01-29 02:23:55 +00:00
|
|
|
$io->write($adapter->onConnect($station, $djUser));
|
|
|
|
return 0;
|
2019-09-10 23:10:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$io->write('received');
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|