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 DjAuthCommand 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,
|
|
|
|
int $stationId,
|
|
|
|
string $djUser = '',
|
2019-09-11 17:58:22 +00:00
|
|
|
string $djPassword = ''
|
2020-10-14 22:19:31 +00:00
|
|
|
): int {
|
2019-09-10 23:10:57 +00:00
|
|
|
$station = $em->getRepository(Entity\Station::class)->find($stationId);
|
|
|
|
|
|
|
|
if (!($station instanceof Entity\Station) || !$station->getEnableStreamers()) {
|
|
|
|
$io->write('false');
|
2020-10-14 22:19:31 +00:00
|
|
|
return 0;
|
2019-09-10 23:10:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$adapter = $adapters->getBackendAdapter($station);
|
|
|
|
|
|
|
|
if ($adapter instanceof Liquidsoap) {
|
2019-09-11 17:58:22 +00:00
|
|
|
$response = $adapter->authenticateStreamer($station, $djUser, $djPassword);
|
2019-09-10 23:10:57 +00:00
|
|
|
$io->write($response);
|
2020-10-14 22:19:31 +00:00
|
|
|
return 0;
|
2019-09-10 23:10:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$io->write('false');
|
2020-10-14 22:19:31 +00:00
|
|
|
return 0;
|
2019-09-10 23:10:57 +00:00
|
|
|
}
|
|
|
|
}
|