ソースを参照

支持组件全局配置

xaboy 6 年 前
コミット
b6d8dae2f6
3 ファイル変更55 行追加0 行削除
  1. 13 0
      src/Contract/ConfigInterface.php
  2. 21 0
      src/UI/Elm/Config.php
  3. 21 0
      src/UI/Iview/Config.php

+ 13 - 0
src/Contract/ConfigInterface.php

@@ -27,5 +27,18 @@ interface ConfigInterface
 
     public function injectEvent($bool);
 
+    /**
+     * @param string $componentName
+     * @param array $config
+     * @return $this
+     */
+    public function componentGlobalConfig($componentName, array $config);
+
+    /**
+     * @param array $config
+     * @return $this
+     */
+    public function componentGlobalCommonConfig(array $config);
+
     public function getConfig();
 }

+ 21 - 0
src/UI/Elm/Config.php

@@ -194,4 +194,25 @@ class Config implements ConfigInterface
     }
 
 
+    /**
+     * @param string $componentName
+     * @param array $config
+     * @return mixed
+     */
+    public function componentGlobalConfig($componentName, array $config)
+    {
+        if (!isset($this->config['global'])) $this->config['global'] = [];
+        $this->config['global'][$componentName] = $config;
+        return $this;
+    }
+
+
+    /**
+     * @param array $config
+     * @return $this
+     */
+    public function componentGlobalCommonConfig(array $config)
+    {
+        return $this->componentGlobalConfig('*', $config);
+    }
 }

+ 21 - 0
src/UI/Iview/Config.php

@@ -194,4 +194,25 @@ class Config implements ConfigInterface
     }
 
 
+    /**
+     * @param string $componentName
+     * @param array $config
+     * @return mixed
+     */
+    public function componentGlobalConfig($componentName, array $config)
+    {
+        if (!isset($this->config['global'])) $this->config['global'] = [];
+        $this->config['global'][$componentName] = $config;
+        return $this;
+    }
+
+
+    /**
+     * @param array $config
+     * @return $this
+     */
+    public function componentGlobalCommonConfig(array $config)
+    {
+        return $this->componentGlobalConfig('*', $config);
+    }
 }