feat: Allow character list force-rebuild with "no-cache"
This commit is contained in:
parent
39fbc1b01d
commit
46ae2a17b2
|
@ -7,6 +7,7 @@ use App\Service\AnkiService;
|
||||||
use App\Service\CharListService;
|
use App\Service\CharListService;
|
||||||
use App\Utils\Number;
|
use App\Utils\Number;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
use Symfony\Component\VarExporter\VarExporter;
|
use Symfony\Component\VarExporter\VarExporter;
|
||||||
|
@ -26,11 +27,11 @@ class KanjiController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return array<string, array<string, 0>> */
|
/** @return array<string, array<string, 0>> */
|
||||||
private function getCharInfo(): array
|
private function getCharInfo(bool $force = false): array
|
||||||
{
|
{
|
||||||
$cacheFile = "$this->varBasepath/charlist.php";
|
$cacheFile = "$this->varBasepath/charlist.php";
|
||||||
|
|
||||||
if (file_exists($cacheFile)) return require $cacheFile;
|
if (!$force and file_exists($cacheFile)) return require $cacheFile;
|
||||||
|
|
||||||
$ret = [];
|
$ret = [];
|
||||||
|
|
||||||
|
@ -74,12 +75,13 @@ class KanjiController extends AbstractController
|
||||||
public function index(
|
public function index(
|
||||||
string $start,
|
string $start,
|
||||||
string $end,
|
string $end,
|
||||||
|
Request $request,
|
||||||
): Response {
|
): Response {
|
||||||
$jiten = json_decode(file_get_contents(
|
$jiten = json_decode(file_get_contents(
|
||||||
"{$this->getParameter('kernel.project_dir')}/data/kanken-links.json",
|
"{$this->getParameter('kernel.project_dir')}/data/kanken-links.json",
|
||||||
), true);
|
), true);
|
||||||
|
|
||||||
$charInfo = $this->getCharInfo();
|
$charInfo = $this->getCharInfo(force: $request->isNoCache());
|
||||||
|
|
||||||
$chars = [];
|
$chars = [];
|
||||||
foreach (range(intval("{$start}0", 16), intval("{$end}f", 16)) as $codepoint) {
|
foreach (range(intval("{$start}0", 16), intval("{$end}f", 16)) as $codepoint) {
|
||||||
|
|
Loading…
Reference in New Issue