diff --git a/src/Controller/KanjiController.php b/src/Controller/KanjiController.php index 817a4f5..1b603d3 100644 --- a/src/Controller/KanjiController.php +++ b/src/Controller/KanjiController.php @@ -7,6 +7,7 @@ use App\Service\AnkiService; use App\Service\CharListService; use App\Utils\Number; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\VarExporter\VarExporter; @@ -26,11 +27,11 @@ class KanjiController extends AbstractController } /** @return array> */ - private function getCharInfo(): array + private function getCharInfo(bool $force = false): array { $cacheFile = "$this->varBasepath/charlist.php"; - if (file_exists($cacheFile)) return require $cacheFile; + if (!$force and file_exists($cacheFile)) return require $cacheFile; $ret = []; @@ -74,12 +75,13 @@ class KanjiController extends AbstractController public function index( string $start, string $end, + Request $request, ): Response { $jiten = json_decode(file_get_contents( "{$this->getParameter('kernel.project_dir')}/data/kanken-links.json", ), true); - $charInfo = $this->getCharInfo(); + $charInfo = $this->getCharInfo(force: $request->isNoCache()); $chars = []; foreach (range(intval("{$start}0", 16), intval("{$end}f", 16)) as $codepoint) {