mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-08 20:46:05 +00:00
upgrade from slim 3 to slim 4
This commit is contained in:
parent
abe6b94b3e
commit
b6dcff3fe3
|
@ -8,7 +8,7 @@
|
||||||
"robthree/twofactorauth": "^1.5",
|
"robthree/twofactorauth": "^1.5",
|
||||||
"sabre/dav": "^4.",
|
"sabre/dav": "^4.",
|
||||||
"sabre/xml": "*",
|
"sabre/xml": "*",
|
||||||
"slim/slim": "^3.0",
|
"slim/slim": "^4.0",
|
||||||
"erusev/parsedown": "*",
|
"erusev/parsedown": "*",
|
||||||
"erusev/parsedown-extra": "*",
|
"erusev/parsedown-extra": "*",
|
||||||
"pear/log": "*",
|
"pear/log": "*",
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
"alecrabbit/php-console-colour": "*",
|
"alecrabbit/php-console-colour": "*",
|
||||||
"zf1/zend-search-lucene": "*",
|
"zf1/zend-search-lucene": "*",
|
||||||
"symfony/http-foundation": "^5.4",
|
"symfony/http-foundation": "^5.4",
|
||||||
|
"php-di/php-di": "^6.4",
|
||||||
"seeddms/core": "dev-master",
|
"seeddms/core": "dev-master",
|
||||||
"seeddms/lucene": "dev-master",
|
"seeddms/lucene": "dev-master",
|
||||||
"seeddms/preview": "dev-master",
|
"seeddms/preview": "dev-master",
|
||||||
|
@ -66,5 +67,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,18 +48,18 @@ class SeedDMS_Auth_Middleware_Session { /* {{{ */
|
||||||
*
|
*
|
||||||
* @return \Psr\Http\Message\ResponseInterface
|
* @return \Psr\Http\Message\ResponseInterface
|
||||||
*/
|
*/
|
||||||
public function __invoke($request, $response, $next) {
|
public function __invoke($request, $handler) {
|
||||||
// $this->container has the DI
|
// $this->container has the DI
|
||||||
$dms = $this->container->dms;
|
$dms = $this->container->get('dms');
|
||||||
$settings = $this->container->config;
|
$settings = $this->container->get('config');
|
||||||
$logger = $this->container->logger;
|
$logger = $this->container->get('logger');
|
||||||
$userobj = null;
|
$userobj = null;
|
||||||
if ($this->container->has('userobj')) {
|
if ($this->container->has('userobj')) {
|
||||||
$userobj = $this->container->userobj;
|
$userobj = $this->container->get('userobj');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($userobj) {
|
if ($userobj) {
|
||||||
$response = $next($request, $response);
|
$response = $handler->handle($request);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,9 +100,9 @@ class SeedDMS_Auth_Middleware_Session { /* {{{ */
|
||||||
} else {
|
} else {
|
||||||
return $response->withStatus(403);
|
return $response->withStatus(403);
|
||||||
}
|
}
|
||||||
$this->container['userobj'] = $userobj;
|
$this->container->set('userobj', $userobj);
|
||||||
|
|
||||||
$response = $next($request, $response);
|
$response = $handler->handle($request);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
50
index.php
50
index.php
|
@ -31,6 +31,9 @@
|
||||||
|
|
||||||
require "inc/inc.Settings.php";
|
require "inc/inc.Settings.php";
|
||||||
|
|
||||||
|
use DI\ContainerBuilder;
|
||||||
|
use Slim\Factory\AppFactory;
|
||||||
|
|
||||||
if(true) {
|
if(true) {
|
||||||
require_once("inc/inc.Utils.php");
|
require_once("inc/inc.Utils.php");
|
||||||
require_once("inc/inc.LogInit.php");
|
require_once("inc/inc.LogInit.php");
|
||||||
|
@ -39,7 +42,9 @@ if(true) {
|
||||||
require_once("inc/inc.Extension.php");
|
require_once("inc/inc.Extension.php");
|
||||||
require_once("inc/inc.DBInit.php");
|
require_once("inc/inc.DBInit.php");
|
||||||
|
|
||||||
$c = new \Slim\Container(); //Create Your container
|
$containerBuilder = new \DI\ContainerBuilder();
|
||||||
|
$c = $containerBuilder->build();
|
||||||
|
/*
|
||||||
$c['notFoundHandler'] = function ($c) use ($settings, $dms) {
|
$c['notFoundHandler'] = function ($c) use ($settings, $dms) {
|
||||||
return function ($request, $response) use ($c, $settings, $dms) {
|
return function ($request, $response) use ($c, $settings, $dms) {
|
||||||
$uri = $request->getUri();
|
$uri = $request->getUri();
|
||||||
|
@ -62,25 +67,42 @@ if(true) {
|
||||||
->withHeader('Location', isset($settings->_siteDefaultPage) && strlen($settings->_siteDefaultPage)>0 ? $settings->_httpRoot.$settings->_siteDefaultPage : $settings->_httpRoot."out/out.ViewFolder.php");
|
->withHeader('Location', isset($settings->_siteDefaultPage) && strlen($settings->_siteDefaultPage)>0 ? $settings->_httpRoot.$settings->_siteDefaultPage : $settings->_httpRoot."out/out.ViewFolder.php");
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
$app = new \Slim\App($c);
|
*/
|
||||||
|
AppFactory::setContainer($c);
|
||||||
|
$app = AppFactory::create();
|
||||||
|
/* put lots of data into the container, because if slim instanciates
|
||||||
|
* a class by itself (with the help from the DI container), it will
|
||||||
|
* pass the container to the constructor of the instanciated class.
|
||||||
|
*/
|
||||||
$container = $app->getContainer();
|
$container = $app->getContainer();
|
||||||
$container['dms'] = $dms;
|
$container->set('dms', $dms);
|
||||||
$container['config'] = $settings;
|
$container->set('config', $settings);
|
||||||
$container['conversionmgr'] = $conversionmgr;
|
$container->set('conversionmgr', $conversionmgr);
|
||||||
$container['logger'] = $logger;
|
$container->set('logger', $logger);
|
||||||
$container['fulltextservice'] = $fulltextservice;
|
$container->set('fulltextservice', $fulltextservice);
|
||||||
$container['notifier'] = $notifier;
|
$container->set('notifier', $notifier);
|
||||||
$container['authenticator'] = $authenticator;
|
$container->set('authenticator', $authenticator);
|
||||||
|
|
||||||
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['initDMS'])) {
|
||||||
|
foreach($GLOBALS['SEEDDMS_HOOKS']['initDMS'] as $hookObj) {
|
||||||
|
if (method_exists($hookObj, 'addMiddleware')) {
|
||||||
|
$hookObj->addMiddleware($app);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$app->get('/', function($request, $response) {
|
||||||
|
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')) {
|
||||||
|
// FIXME: pass $app only just like initRestAPI. $app has a container
|
||||||
|
// which contains all other objects
|
||||||
$hookObj->addRoute(array('dms'=>$dms, 'app'=>$app, 'settings'=>$settings, 'conversionmgr'=>$conversionmgr, 'authenticator'=>$authenticator, 'fulltextservice'=>$fulltextservice, 'logger'=>$logger));
|
$hookObj->addRoute(array('dms'=>$dms, 'app'=>$app, 'settings'=>$settings, 'conversionmgr'=>$conversionmgr, 'authenticator'=>$authenticator, 'fulltextservice'=>$fulltextservice, 'logger'=>$logger));
|
||||||
// } else {
|
|
||||||
// include("inc/inc.Authentication.php");
|
|
||||||
// if (method_exists($hookObj, 'addRouteAfterAuthentication')) {
|
|
||||||
// $hookObj->addRouteAfterAuthentication(array('dms'=>$dms, 'app'=>$app, 'settings'=>$settings, 'user'=>$user));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1358
restapi/index.php
1358
restapi/index.php
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user