aboutsummaryrefslogtreecommitdiff
path: root/lib/plugins
diff options
context:
space:
mode:
authorAndré Noack <noack@data-quest.de>2024-12-12 14:52:00 +0000
committerDavid Siegfried <david.siegfried@uni-vechta.de>2024-12-12 14:52:00 +0000
commit940d2aaa8638b4e0c764579cb3977e7be527c81f (patch)
tree79bd2d7f02359e1bb24931b33513e082f8404a91 /lib/plugins
parent3a2a88172ccbe97aaecf4ea32b97cd07b92dcb11 (diff)
StEP 1552 closes #1552
Closes #1552 Merge request studip/studip!1137
Diffstat (limited to 'lib/plugins')
-rw-r--r--lib/plugins/core/StudIPPlugin.php33
-rw-r--r--lib/plugins/engine/PluginManager.php2
2 files changed, 28 insertions, 7 deletions
diff --git a/lib/plugins/core/StudIPPlugin.php b/lib/plugins/core/StudIPPlugin.php
index cbcac64..a747119 100644
--- a/lib/plugins/core/StudIPPlugin.php
+++ b/lib/plugins/core/StudIPPlugin.php
@@ -184,20 +184,35 @@ abstract class StudIPPlugin
}
/**
- * This method dispatches all actions.
- *
- * @param string part of the dispatch path that was not consumed
+ * This method formerly dispatches all actions. Left in place for
+ * compatibility
+ * @param string $unconsumed_path part of the dispatch path that was not consumed
*
* @return void
*/
public function perform($unconsumed_path)
{
+
+ }
+
+ /**
+ * This method returns callable for slim app
+ *
+ * @param string $unconsumed_path part of the dispatch path that was not consumed
+ *
+ * @return Closure
+ * @throws \Trails\Exceptions\UnknownAction
+ */
+ public function getRouteCallable(string $unconsumed_path): Closure
+ {
+ $this->perform($unconsumed_path);
$args = explode('/', $unconsumed_path);
$action = $args[0] !== '' ? array_shift($args).'_action' : 'show_action';
if (!method_exists($this, $action)) {
try {
- app(PluginDispatcher::class, ['plugin' => $this])->dispatch($unconsumed_path);
+ $dispatcher = app(PluginDispatcher::class, ['plugin' => $this]);
+ return $dispatcher->getRouteCallable($unconsumed_path);
} catch (Trails\Exceptions\UnknownAction $exception) {
if (count($args) > 0) {
throw $exception;
@@ -206,10 +221,16 @@ abstract class StudIPPlugin
}
}
} else {
- call_user_func_array([$this, $action], $args);
+ $that = $this;
+ return function ($request, $response, array $otherargs) use ($action, $args, $that) {
+ ob_start();
+ call_user_func_array([$that, $action], $args);
+ $content = ob_get_contents();
+ $response->getBody()->write($content);
+ return $response;
+ };
}
}
-
/**
* Callback function called after enabling a plugin.
* The plugin's ID is transmitted for convenience.
diff --git a/lib/plugins/engine/PluginManager.php b/lib/plugins/engine/PluginManager.php
index 919e175..6177e00 100644
--- a/lib/plugins/engine/PluginManager.php
+++ b/lib/plugins/engine/PluginManager.php
@@ -609,7 +609,7 @@ class PluginManager
*/
public function getPlugin ($class)
{
- $user = $GLOBALS['user']->id;
+ $user = $GLOBALS['user']->id ?? 'nobody' ;
$plugin_info = $this->getPluginInfo($class);
$plugin = null;