mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +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",
|
||||
"sabre/dav": "^4.",
|
||||
"sabre/xml": "*",
|
||||
"slim/slim": "^3.0",
|
||||
"slim/slim": "^4.0",
|
||||
"erusev/parsedown": "*",
|
||||
"erusev/parsedown-extra": "*",
|
||||
"pear/log": "*",
|
||||
|
@ -20,6 +20,7 @@
|
|||
"alecrabbit/php-console-colour": "*",
|
||||
"zf1/zend-search-lucene": "*",
|
||||
"symfony/http-foundation": "^5.4",
|
||||
"php-di/php-di": "^6.4",
|
||||
"seeddms/core": "dev-master",
|
||||
"seeddms/lucene": "dev-master",
|
||||
"seeddms/preview": "dev-master",
|
||||
|
@ -66,5 +67,4 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
|
|
|
@ -48,18 +48,18 @@ class SeedDMS_Auth_Middleware_Session { /* {{{ */
|
|||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function __invoke($request, $response, $next) {
|
||||
public function __invoke($request, $handler) {
|
||||
// $this->container has the DI
|
||||
$dms = $this->container->dms;
|
||||
$settings = $this->container->config;
|
||||
$logger = $this->container->logger;
|
||||
$dms = $this->container->get('dms');
|
||||
$settings = $this->container->get('config');
|
||||
$logger = $this->container->get('logger');
|
||||
$userobj = null;
|
||||
if ($this->container->has('userobj')) {
|
||||
$userobj = $this->container->userobj;
|
||||
$userobj = $this->container->get('userobj');
|
||||
}
|
||||
|
||||
if ($userobj) {
|
||||
$response = $next($request, $response);
|
||||
$response = $handler->handle($request);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
@ -100,9 +100,9 @@ class SeedDMS_Auth_Middleware_Session { /* {{{ */
|
|||
} else {
|
||||
return $response->withStatus(403);
|
||||
}
|
||||
$this->container['userobj'] = $userobj;
|
||||
$this->container->set('userobj', $userobj);
|
||||
|
||||
$response = $next($request, $response);
|
||||
$response = $handler->handle($request);
|
||||
return $response;
|
||||
}
|
||||
} /* }}} */
|
||||
|
|
50
index.php
50
index.php
|
@ -31,6 +31,9 @@
|
|||
|
||||
require "inc/inc.Settings.php";
|
||||
|
||||
use DI\ContainerBuilder;
|
||||
use Slim\Factory\AppFactory;
|
||||
|
||||
if(true) {
|
||||
require_once("inc/inc.Utils.php");
|
||||
require_once("inc/inc.LogInit.php");
|
||||
|
@ -39,7 +42,9 @@ if(true) {
|
|||
require_once("inc/inc.Extension.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) {
|
||||
return function ($request, $response) use ($c, $settings, $dms) {
|
||||
$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");
|
||||
};
|
||||
};
|
||||
$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['dms'] = $dms;
|
||||
$container['config'] = $settings;
|
||||
$container['conversionmgr'] = $conversionmgr;
|
||||
$container['logger'] = $logger;
|
||||
$container['fulltextservice'] = $fulltextservice;
|
||||
$container['notifier'] = $notifier;
|
||||
$container['authenticator'] = $authenticator;
|
||||
$container->set('dms', $dms);
|
||||
$container->set('config', $settings);
|
||||
$container->set('conversionmgr', $conversionmgr);
|
||||
$container->set('logger', $logger);
|
||||
$container->set('fulltextservice', $fulltextservice);
|
||||
$container->set('notifier', $notifier);
|
||||
$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'])) {
|
||||
foreach($GLOBALS['SEEDDMS_HOOKS']['initDMS'] as $hookObj) {
|
||||
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));
|
||||
// } 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