mirror of
https://github.com/Aviortheking/DeltaCMS.git
synced 2025-06-07 15:29:55 +00:00
Support for forms in cache
This commit is contained in:
parent
b9e3115838
commit
739fe46ce9
@ -1,20 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use AdminPanel\Classes\AdminPanel;
|
use AdminPanel\AdminPanel;
|
||||||
use AdminPanel\Logger\Logger;
|
|
||||||
use Symfony\Component\VarDumper\Caster\ExceptionCaster;
|
|
||||||
use Psr\Log\InvalidArgumentException;
|
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
ini_set('display_errors', 'On');
|
ini_set('display_errors', 'On');
|
||||||
|
|
||||||
/** @var Composer\Autoload\ClassLoader $loader */
|
/** @var Composer\Autoload\ClassLoader $loader */
|
||||||
$loader = require_once __DIR__ . "/../vendor/autoload.php";
|
$loader = require_once __DIR__ . "/../vendor/autoload.php";
|
||||||
$logger = new Logger(dirname(__DIR__) . '/logs/logs.log');
|
|
||||||
|
|
||||||
|
|
||||||
|
//die;
|
||||||
$ap = AdminPanel::getInstance();
|
$ap = AdminPanel::getInstance();
|
||||||
|
// dd($ap);
|
||||||
/*
|
/*
|
||||||
1: get all the template folders
|
1: get all the template folders
|
||||||
2: match routes directly with modules
|
2: match routes directly with modules
|
||||||
@ -22,11 +18,12 @@ $ap = AdminPanel::getInstance();
|
|||||||
$cache = $ap->getCache();
|
$cache = $ap->getCache();
|
||||||
$caches = $cache->getMultiple(array(
|
$caches = $cache->getMultiple(array(
|
||||||
'routes',
|
'routes',
|
||||||
'templates'
|
'templates',
|
||||||
|
'forms'
|
||||||
));
|
));
|
||||||
|
|
||||||
//if cache don't exist create it!
|
//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";
|
$modulesDIR = __DIR__ . "/Modules";
|
||||||
$modules = array_diff(scandir($modulesDIR), array('..', '.'));
|
$modules = array_diff(scandir($modulesDIR), array('..', '.'));
|
||||||
/** @var string $module */
|
/** @var string $module */
|
||||||
@ -43,6 +40,9 @@ if ($caches["routes"] === null || $caches['templates'] === null) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
foreach ($json->routes as $routeName => $routeArgs) {
|
foreach ($json->routes as $routeName => $routeArgs) {
|
||||||
|
if (isset($routeArgs->file)) {
|
||||||
|
$routeArgs->file = $moduleDIR . $routeArgs->file;
|
||||||
|
}
|
||||||
$cache->set('routes', array_merge(
|
$cache->set('routes', array_merge(
|
||||||
$cache->get('routes', array()),
|
$cache->get('routes', array()),
|
||||||
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(
|
$caches = $cache->getMultiple(array(
|
||||||
@ -70,7 +80,7 @@ foreach ($caches['routes'] as $key => $value) {
|
|||||||
if (isset($value->type)) {
|
if (isset($value->type)) {
|
||||||
header("Content-Type: " . $value->type . "; charset=UTF-8");
|
header("Content-Type: " . $value->type . "; charset=UTF-8");
|
||||||
}
|
}
|
||||||
echo file_get_contents($moduleDIR . $value->file);
|
echo file_get_contents($value->file);
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
$loader->loadClass($value->controller);
|
$loader->loadClass($value->controller);
|
||||||
@ -92,6 +102,4 @@ foreach ($caches['routes'] as $key => $value) {
|
|||||||
|
|
||||||
|
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
// dd();
|
|
||||||
echo "404";
|
echo "404";
|
||||||
die;
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user