X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=862c53efa5d6716ba6faef19b0adf073266a5587;hb=HEAD;hp=8fe862361330fd59274eeceddbd8c1518255ba0e;hpb=8affa2243159052675da7e23b737c76f6b43aeed;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 8fe86236..862c53ef 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,5 @@ setEmpty('general.timezone', date_default_timezone_get()); -$conf->setEmpty('general.title', t('Shared bookmarks on '). escape(index_url($_SERVER))); +$conf->setEmpty('general.title', t('Shared bookmarks on ') . escape(index_url($_SERVER))); -RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl').'/'.$conf->get('resource.theme').'/'; // template directory +RainTPL::$tpl_dir = $conf->get('resource.raintpl_tpl') . '/' . $conf->get('resource.theme') . '/'; // template directory RainTPL::$cache_dir = $conf->get('resource.raintpl_tmp'); // cache directory date_default_timezone_set($conf->get('general.timezone', 'UTC')); $loginManager->checkLoginState(client_ip_id($_SERVER)); -$containerBuilder = new ContainerBuilder($conf, $sessionManager, $cookieManager, $loginManager, $logger); +$pluginManager = new PluginManager($conf); +$pluginManager->load($conf->get('general.enabled_plugins', [])); + +$containerBuilder = new ContainerBuilder( + $conf, + $sessionManager, + $cookieManager, + $loginManager, + $pluginManager, + $logger +); $container = $containerBuilder->build(); $app = new App($container); @@ -153,6 +165,15 @@ $app->group('/admin', function () { $this->get('/visibility/{visibility}', '\Shaarli\Front\Controller\Admin\SessionFilterController:visibility'); })->add('\Shaarli\Front\ShaarliAdminMiddleware'); +$app->group('/plugin', function () use ($pluginManager) { + foreach ($pluginManager->getRegisteredRoutes() as $pluginName => $routes) { + $this->group('/' . $pluginName, function () use ($routes) { + foreach ($routes as $route) { + $this->{strtolower($route['method'])}('/' . ltrim($route['route'], '/'), $route['callable']); + } + }); + } +})->add('\Shaarli\Front\ShaarliMiddleware'); // REST API routes $app->group('/api/v1', function () { @@ -177,6 +198,6 @@ try { } catch (Throwable $e) { die(nl2br( 'An unexpected error happened, and the error template could not be displayed.' . PHP_EOL . PHP_EOL . - exception2text($e) + exception2text($e) )); }