router: fix constant placement
This commit is contained in:
parent
8a98eec610
commit
06155d5d93
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
class router {
|
class router {
|
||||||
|
|
||||||
|
const int ROUTER_VERSION = 10;
|
||||||
|
const string ROUTER_MC_KEY = '4in1/routes';
|
||||||
|
|
||||||
protected array $routes = [
|
protected array $routes = [
|
||||||
'children' => [],
|
'children' => [],
|
||||||
're_children' => []
|
're_children' => []
|
||||||
@ -21,9 +24,9 @@ class router {
|
|||||||
$write_cache = !isDev();
|
$write_cache = !isDev();
|
||||||
|
|
||||||
if ($from_cache) {
|
if ($from_cache) {
|
||||||
$cache = $mc->get(ROUTER_MC_KEY);
|
$cache = $mc->get(self::ROUTER_MC_KEY);
|
||||||
|
|
||||||
if ($cache === false || !isset($cache['version']) || $cache['version'] < ROUTER_VERSION) {
|
if ($cache === false || !isset($cache['version']) || $cache['version'] < self::ROUTER_VERSION) {
|
||||||
$from_cache = false;
|
$from_cache = false;
|
||||||
} else {
|
} else {
|
||||||
$this->routes = $cache['routes'];
|
$this->routes = $cache['routes'];
|
||||||
@ -39,7 +42,7 @@ class router {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($write_cache)
|
if ($write_cache)
|
||||||
$mc->set(ROUTER_MC_KEY, ['version' => ROUTER_VERSION, 'routes' => $this->routes]);
|
$mc->set(self::ROUTER_MC_KEY, ['version' => self::ROUTER_VERSION, 'routes' => $this->routes]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
const ROUTER_VERSION = 10;
|
|
||||||
const ROUTER_MC_KEY = '4in1/routes';
|
|
||||||
|
|
||||||
return (function() {
|
return (function() {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user