2020-02-06 02:35:13 +00:00
|
|
|
<?php
|
2021-06-28 15:03:21 +00:00
|
|
|
|
2021-07-19 05:53:45 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-02-06 02:35:13 +00:00
|
|
|
namespace App\Console\Command;
|
|
|
|
|
2021-06-28 10:34:19 +00:00
|
|
|
use App\Entity\Repository\SettingsRepository;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
use Symfony\Component\Cache\Adapter\AdapterInterface;
|
2020-02-06 02:35:13 +00:00
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
|
|
|
|
class ClearCacheCommand extends CommandAbstract
|
|
|
|
{
|
2021-06-28 10:34:19 +00:00
|
|
|
public function __invoke(
|
|
|
|
SymfonyStyle $io,
|
|
|
|
AdapterInterface $cache,
|
|
|
|
EntityManagerInterface $em,
|
|
|
|
SettingsRepository $settingsRepo,
|
|
|
|
): int {
|
2020-02-06 02:35:13 +00:00
|
|
|
// Flush all Redis entries.
|
2021-06-28 10:34:19 +00:00
|
|
|
$cache->clear();
|
|
|
|
|
|
|
|
// Clear "Now Playing" cache on all station rows.
|
|
|
|
$em->createQuery(
|
|
|
|
<<<'DQL'
|
|
|
|
UPDATE App\Entity\Station s SET s.nowplaying=null
|
|
|
|
DQL
|
|
|
|
)->execute();
|
|
|
|
|
|
|
|
// Clear cached system settings.
|
|
|
|
$settings = $settingsRepo->readSettings();
|
|
|
|
$settings->setNowplaying(null);
|
|
|
|
$settings->updateUpdateLastRun();
|
|
|
|
$settings->setUpdateResults(null);
|
|
|
|
|
|
|
|
if ('127.0.0.1' !== $settings->getExternalIp()) {
|
|
|
|
$settings->setExternalIp(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
$settingsRepo->writeSettings($settings);
|
2020-02-06 02:35:13 +00:00
|
|
|
|
2020-10-07 23:50:30 +00:00
|
|
|
$io->success('Local cache flushed.');
|
2020-02-06 02:35:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|