diff --git a/src/index.php b/src/index.php index a09274f..e261ac7 100644 --- a/src/index.php +++ b/src/index.php @@ -1,20 +1,16 @@ getCache(); $caches = $cache->getMultiple(array( 'routes', - 'templates' + 'templates', + 'forms' )); //if cache don't exist create it! -if ($caches["routes"] === null || $caches['templates'] === null) { +if (!($ap->isCacheEnabled()) || $caches["routes"] === null || $caches['templates'] === null || $caches['forms'] === null) { $modulesDIR = __DIR__ . "/Modules"; $modules = array_diff(scandir($modulesDIR), array('..', '.')); /** @var string $module */ @@ -43,6 +40,9 @@ if ($caches["routes"] === null || $caches['templates'] === null) { ); } foreach ($json->routes as $routeName => $routeArgs) { + if (isset($routeArgs->file)) { + $routeArgs->file = $moduleDIR . $routeArgs->file; + } $cache->set('routes', array_merge( $cache->get('routes', array()), array( @@ -50,6 +50,16 @@ if ($caches["routes"] === null || $caches['templates'] === null) { ) )); } + if (isset($json->forms)) { + foreach ($json->forms as $formName => $formArgs) { + $cache->set('forms', array_merge( + $cache->get('forms', array()), + array( + $formName => $formArgs + ) + )); + } + } } } $caches = $cache->getMultiple(array( @@ -70,7 +80,7 @@ foreach ($caches['routes'] as $key => $value) { if (isset($value->type)) { header("Content-Type: " . $value->type . "; charset=UTF-8"); } - echo file_get_contents($moduleDIR . $value->file); + echo file_get_contents($value->file); die; } $loader->loadClass($value->controller); @@ -92,6 +102,4 @@ foreach ($caches['routes'] as $key => $value) { http_response_code(404); -// dd(); echo "404"; -die;