mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-18 02:59:27 +00:00
remove old code, add error middleware and catch all route
This commit is contained in:
parent
879855536f
commit
a44ddc0b94
50
index.php
50
index.php
|
@ -44,32 +44,9 @@ if(true) {
|
||||||
|
|
||||||
$containerBuilder = new \DI\ContainerBuilder();
|
$containerBuilder = new \DI\ContainerBuilder();
|
||||||
$c = $containerBuilder->build();
|
$c = $containerBuilder->build();
|
||||||
/*
|
|
||||||
$c['notFoundHandler'] = function ($c) use ($settings, $dms) {
|
|
||||||
return function ($request, $response) use ($c, $settings, $dms) {
|
|
||||||
$uri = $request->getUri();
|
|
||||||
if($uri->getBasePath())
|
|
||||||
$file = $uri->getPath();
|
|
||||||
else
|
|
||||||
$file = substr($uri->getPath(), 1);
|
|
||||||
if(file_exists($file) && is_file($file)) {
|
|
||||||
$_SERVER['SCRIPT_FILENAME'] = basename($file);
|
|
||||||
// include($file);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
if($request->isXhr()) {
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
// print_r($request->getUri());
|
|
||||||
// exit;
|
|
||||||
return $c['response']
|
|
||||||
->withStatus(302)
|
|
||||||
->withHeader('Location', isset($settings->_siteDefaultPage) && strlen($settings->_siteDefaultPage)>0 ? $settings->_httpRoot.$settings->_siteDefaultPage : $settings->_httpRoot."out/out.ViewFolder.php");
|
|
||||||
};
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
AppFactory::setContainer($c);
|
AppFactory::setContainer($c);
|
||||||
$app = AppFactory::create();
|
$app = AppFactory::create();
|
||||||
|
|
||||||
/* put lots of data into the container, because if slim instanciates
|
/* put lots of data into the container, because if slim instanciates
|
||||||
* a class by itself (with the help from the DI container), it will
|
* a class by itself (with the help from the DI container), it will
|
||||||
* pass the container to the constructor of the instanciated class.
|
* pass the container to the constructor of the instanciated class.
|
||||||
|
@ -91,12 +68,8 @@ if(true) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$app->get('/', function($request, $response) {
|
$app->addErrorMiddleware(false, true, true);
|
||||||
return $response
|
|
||||||
->withHeader('Location', '/out/out.ViewFolder.php')
|
|
||||||
->withStatus(302);
|
|
||||||
|
|
||||||
});
|
|
||||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['initDMS'])) {
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['initDMS'])) {
|
||||||
foreach($GLOBALS['SEEDDMS_HOOKS']['initDMS'] as $hookObj) {
|
foreach($GLOBALS['SEEDDMS_HOOKS']['initDMS'] as $hookObj) {
|
||||||
if (method_exists($hookObj, 'addRoute')) {
|
if (method_exists($hookObj, 'addRoute')) {
|
||||||
|
@ -107,20 +80,13 @@ if(true) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Catch all route */
|
||||||
$app->get('/out/[{path:.*}]', function($request, $response, $path = null) use ($app) {
|
$app->get('/{path:.*}', function($request, $response) {
|
||||||
$uri = $request->getUri();
|
return $response
|
||||||
if($uri->getBasePath())
|
->withHeader('Location', '/out/out.ViewFolder.php')
|
||||||
$file = $uri->getPath();
|
->withStatus(302);
|
||||||
else
|
|
||||||
$file = substr($uri->getPath(), 1);
|
|
||||||
if(file_exists($file) && is_file($file)) {
|
|
||||||
$_SERVER['SCRIPT_FILENAME'] = basename($file);
|
|
||||||
include($file);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
$app->run();
|
$app->run();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user