]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/config/ConfigPlugin.php
lint: apply phpcbf to application/
[github/shaarli/Shaarli.git] / application / config / ConfigPlugin.php
index 8af89d042a4bc444efb0cbc831340d72b5c21320..dbb249374a7262053b5e03000d38b746c9772563 100644 (file)
@@ -1,6 +1,11 @@
 <?php
+
+use Shaarli\Config\Exception\PluginConfigOrderException;
+
 /**
- * Functions related to configuration management.
+ * Plugin configuration helper functions.
+ *
+ * Note: no access to configuration files here.
  */
 
 /**
@@ -29,8 +34,7 @@ function save_plugin_config($formData)
         // If there is no order, it means a disabled plugin has been enabled.
         if (isset($formData['order_' . $key])) {
             $plugins[(int) $formData['order_' . $key]] = $key;
-        }
-        else {
+        } else {
             $newEnabledPlugins[] = $key;
         }
     }
@@ -78,9 +82,13 @@ function validate_plugin_order($formData)
 }
 
 /**
- * Affect plugin parameters values into plugins array.
+ * Affect plugin parameters values from the ConfigManager into plugins array.
  *
- * @param mixed $plugins Plugins array ($plugins[<plugin_name>]['parameters']['param_name'] = <value>.
+ * @param mixed $plugins Plugins array:
+ *                         $plugins[<plugin_name>]['parameters'][<param_name>] = [
+ *                                                                                 'value' => <value>,
+ *                                                                                 'desc' => <description>
+ *                                                                               ]
  * @param mixed $conf  Plugins configuration.
  *
  * @return mixed Updated $plugins array.
@@ -95,24 +103,10 @@ function load_plugin_parameter_values($plugins, $conf)
 
         foreach ($plugin['parameters'] as $key => $param) {
             if (!empty($conf[$key])) {
-                $out[$name]['parameters'][$key] = $conf[$key];
+                $out[$name]['parameters'][$key]['value'] = $conf[$key];
             }
         }
     }
 
     return $out;
 }
-
-/**
- * Exception used if an error occur while saving plugin configuration.
- */
-class PluginConfigOrderException extends Exception
-{
-    /**
-     * Construct exception.
-     */
-    public function __construct()
-    {
-        $this->message = 'An error occurred while trying to save plugins loading order.';
-    }
-}