aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-10-27 19:23:45 +0100
committerArthurHoaro <arthur@hoa.ro>2020-11-15 12:41:43 +0100
commita6e9c08499f9f79dad88cb3ae9eacda0e0c34c96 (patch)
tree41f70d7dc478e70a4a3ce4a578839316f5578765 /index.php
parent6f9e0609f4c118142504234ebcc7d93456b5e588 (diff)
downloadShaarli-a6e9c08499f9f79dad88cb3ae9eacda0e0c34c96.tar.gz
Shaarli-a6e9c08499f9f79dad88cb3ae9eacda0e0c34c96.tar.zst
Shaarli-a6e9c08499f9f79dad88cb3ae9eacda0e0c34c96.zip
Plugin system: allow plugins to provide custom routes
- each route will be prefixed by `/plugin/<plugin_name>` - add a new template for plugins rendering - add a live example in the demo_plugin Check out the "Plugin System" documentation for more detail. Related to #143
Diffstat (limited to 'index.php')
-rw-r--r--index.php22
1 files changed, 21 insertions, 1 deletions
diff --git a/index.php b/index.php
index 1eb7659a..862c53ef 100644
--- a/index.php
+++ b/index.php
@@ -31,6 +31,7 @@ use Psr\Log\LogLevel;
31use Shaarli\Config\ConfigManager; 31use Shaarli\Config\ConfigManager;
32use Shaarli\Container\ContainerBuilder; 32use Shaarli\Container\ContainerBuilder;
33use Shaarli\Languages; 33use Shaarli\Languages;
34use Shaarli\Plugin\PluginManager;
34use Shaarli\Security\BanManager; 35use Shaarli\Security\BanManager;
35use Shaarli\Security\CookieManager; 36use Shaarli\Security\CookieManager;
36use Shaarli\Security\LoginManager; 37use Shaarli\Security\LoginManager;
@@ -87,7 +88,17 @@ date_default_timezone_set($conf->get('general.timezone', 'UTC'));
87 88
88$loginManager->checkLoginState(client_ip_id($_SERVER)); 89$loginManager->checkLoginState(client_ip_id($_SERVER));
89 90
90$containerBuilder = new ContainerBuilder($conf, $sessionManager, $cookieManager, $loginManager, $logger); 91$pluginManager = new PluginManager($conf);
92$pluginManager->load($conf->get('general.enabled_plugins', []));
93
94$containerBuilder = new ContainerBuilder(
95 $conf,
96 $sessionManager,
97 $cookieManager,
98 $loginManager,
99 $pluginManager,
100 $logger
101);
91$container = $containerBuilder->build(); 102$container = $containerBuilder->build();
92$app = new App($container); 103$app = new App($container);
93 104
@@ -154,6 +165,15 @@ $app->group('/admin', function () {
154 $this->get('/visibility/{visibility}', '\Shaarli\Front\Controller\Admin\SessionFilterController:visibility'); 165 $this->get('/visibility/{visibility}', '\Shaarli\Front\Controller\Admin\SessionFilterController:visibility');
155})->add('\Shaarli\Front\ShaarliAdminMiddleware'); 166})->add('\Shaarli\Front\ShaarliAdminMiddleware');
156 167
168$app->group('/plugin', function () use ($pluginManager) {
169 foreach ($pluginManager->getRegisteredRoutes() as $pluginName => $routes) {
170 $this->group('/' . $pluginName, function () use ($routes) {
171 foreach ($routes as $route) {
172 $this->{strtolower($route['method'])}('/' . ltrim($route['route'], '/'), $route['callable']);
173 }
174 });
175 }
176})->add('\Shaarli\Front\ShaarliMiddleware');
157 177
158// REST API routes 178// REST API routes
159$app->group('/api/v1', function () { 179$app->group('/api/v1', function () {