]> git.agnieray.net Git - galette.git/commitdiff
Fixes on plugins routes
authorJohan Cwiklinski <johan@x-tnd.be>
Sat, 18 Feb 2023 06:50:38 +0000 (07:50 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Sat, 18 Feb 2023 06:50:38 +0000 (07:50 +0100)
galette/includes/routes/plugins.routes.php
galette/lib/Galette/Core/PluginControllerTrait.php

index 128e8086c1f52bfbaf0582acf5c716dd5127403a..82eef721a2ee40e4dda3bf0c8a572683bf714fa8 100644 (file)
@@ -46,7 +46,7 @@ $app->group(
         //Global route to access plugin resources (CSS, JS, images, ...)
         $app->get(
             '/{plugin}/res/{path:.*}',
-            function (Request $request, Response $response, $plugin, $path) {
+            function (Request $request, Response $response, $plugin, $path) use ($container) {
                 $ext = pathinfo($path)['extension'];
                 $auth_ext = [
                     'js'    => 'text/javascript',
@@ -58,7 +58,7 @@ $app->group(
                     'svg'   => 'image/svg+xml'
                 ];
                 if (strpos($path, '../') === false && isset($auth_ext[$ext])) {
-                    $file = $this->get('plugins')->getFile(
+                    $file = $container->get('plugins')->getFile(
                         $plugin,
                         $path
                     );
@@ -84,11 +84,11 @@ $app->group(
             $app->group(
                 '/' . $module['route'],
                 //$module_id may be used in included _routes.php from plugin.
-                function (\Slim\Routing\RouteCollectorProxy $app) use ($module, $module_id, $authenticate, $showPublicPages) {
+                function (\Slim\Routing\RouteCollectorProxy $app) use ($module, $module_id, $authenticate, $showPublicPages, $container) {
                     //Plugin home: give information
                     $app->get(
                         '',
-                        function ($request, $response) use ($module) {
+                        function ($request, $response) use ($module, $container) {
                             $params = [
                                 'page_title'    => $module['name'],
                                 'name'          => $module['name'],
@@ -96,11 +96,11 @@ $app->group(
                                 'date'          => $module['date'],
                                 'author'        => $module['author']
                             ];
-                            if ($this->get('login')->isAdmin()) {
+                            if ($container->get('login')->isAdmin()) {
                                 $params['module'] = $module;
                             }
                             // display page
-                            $this->get(\Slim\Views\Twig::class)->render(
+                            $container->get(\Slim\Views\Twig::class)->render(
                                 $response,
                                 'pages/plugin_info.html.twig',
                                 $params
index 268d2cc2e0affa1e66df6b492e7a125fec3e7e1d..2108bf125890b74288e9f23a8fc1ca5d8b2af57a 100644 (file)
@@ -7,7 +7,7 @@
  *
  * PHP version 5
  *
- * Copyright © 2020-2022 The Galette Team
+ * Copyright © 2020-2023 The Galette Team
  *
  * This file is part of Galette (http://galette.tuxfamily.org).
  *
@@ -28,7 +28,7 @@
  * @package   Galette
  *
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2020-2022 The Galette Team
+ * @copyright 2020-2023 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     2020-12-09
@@ -36,8 +36,6 @@
 
 namespace Galette\Core;
 
-use Analog\Analog;
-
 /**
  * Plugin controllers trait
  *
@@ -45,7 +43,7 @@ use Analog\Analog;
  * @name      PluginControllerTrait
  * @package   Galette
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2020-2022 The Galette Team
+ * @copyright 2020-2023 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     2020-12-09
@@ -55,8 +53,8 @@ trait PluginControllerTrait
 {
     /**
      * Something like:
-     * Inject("Plugin Galette Name")
-     * @var integer
+     * #[Inject("Plugin Galette Name")]
+     * @var array
      */
     protected $module_info;