Browse Source

完善 contract

xaboy 6 years ago
parent
commit
df0661ab4c

+ 2 - 2
src/Contract/ColComponentInterface.php

@@ -12,7 +12,7 @@
 namespace FormBuilder\Contract;
 
 
-interface ColComponentInterface extends FormComponentInterface
+interface ColComponentInterface
 {
-
+    public function getCol();
 }

+ 13 - 1
src/Contract/ConfigInterface.php

@@ -12,7 +12,19 @@
 namespace FormBuilder\Contract;
 
 
-interface ConfigInterface extends FormComponentInterface
+interface ConfigInterface
 {
+    public function info($type);
 
+    public function formStyle($formStyle);
+
+    public function row($row);
+
+    public function submitBtn($submitBtn);
+
+    public function resetBtn($resetBtn);
+
+    public function injectEvent($bool);
+
+    public function getConfig();
 }

+ 2 - 2
src/Contract/OptionComponentInterface.php

@@ -12,7 +12,7 @@
 namespace FormBuilder\Contract;
 
 
-interface OptionComponentInterface extends FormComponentInterface
+interface OptionComponentInterface
 {
-
+    public function getOption();
 }

+ 7 - 1
src/Contract/ValidateInterface.php

@@ -12,7 +12,13 @@
 namespace FormBuilder\Contract;
 
 
-interface ValidateInterface extends FormComponentInterface
+interface ValidateInterface
 {
 
+    /**
+     * 获取验证规则
+     *
+     * @return array
+     */
+    public function getValidate();
 }

+ 1 - 1
src/Form.php

@@ -321,7 +321,7 @@ class Form
     public function formConfig()
     {
         $config = $this->config;
-        if ($config instanceof ConfigInterface) return $config->build();
+        if ($config instanceof ConfigInterface) return $config->getConfig();
         foreach ($config as $k => $v) {
             $config[$k] = $this->parseFormComponent($v);
         }

+ 1 - 1
src/Rule/BaseRule.php

@@ -236,7 +236,7 @@ trait BaseRule
 
     protected function parseCol($col)
     {
-        return $col instanceof ColComponentInterface ? $col->build() : $col;
+        return $col instanceof ColComponentInterface ? $col->getCol() : $col;
     }
 
     protected function parseBaseRule()

+ 1 - 1
src/Rule/OptionsRule.php

@@ -85,7 +85,7 @@ trait OptionsRule
      */
     protected function parseOption($option)
     {
-        return $option instanceof OptionComponentInterface ? $option->build() : $option;
+        return $option instanceof OptionComponentInterface ? $option->getOption() : $option;
     }
 
     /**

+ 1 - 1
src/Rule/ValidateRule.php

@@ -54,7 +54,7 @@ trait ValidateRule
     {
         $validate = [];
         foreach ($this->validate as $value) {
-            $validate[] = $value instanceof ValidateInterface ? $value->build() : $value;
+            $validate[] = $value instanceof ValidateInterface ? $value->getValidate() : $value;
         }
 
         return $validate;

+ 1 - 1
src/UI/Elm/Components/Option.php

@@ -48,7 +48,7 @@ class Option implements OptionComponentInterface
     /**
      * @return array
      */
-    public function build()
+    public function getOption()
     {
         return $this->rule;
     }

+ 1 - 1
src/UI/Elm/Config.php

@@ -175,7 +175,7 @@ class Config implements ConfigInterface
     /**
      * @return array
      */
-    public function build()
+    public function getConfig()
     {
         $config = $this->config;
         if (isset($config['form']) && ($form = $config['form']) instanceof FormStyle)

+ 2 - 2
src/UI/Elm/Style/Col.php

@@ -151,13 +151,13 @@ class Col implements ColComponentInterface
 
     protected function buildGrid($grid)
     {
-        return $grid instanceof self ? $grid->build() : (int)$grid;
+        return $grid instanceof self ? $grid->getCol() : (int)$grid;
     }
 
     /**
      * @return object
      */
-    public function build()
+    public function getCol()
     {
         return (object)$this->rule;
     }

+ 1 - 1
src/UI/Iview/Components/Option.php

@@ -48,7 +48,7 @@ class Option implements OptionComponentInterface
     /**
      * @return array
      */
-    public function build()
+    public function getOption()
     {
         return $this->rule;
     }

+ 1 - 1
src/UI/Iview/Config.php

@@ -175,7 +175,7 @@ class Config implements ConfigInterface
     /**
      * @return array
      */
-    public function build()
+    public function getConfig()
     {
         $config = $this->config;
         if (isset($config['form']) && ($form = $config['form']) instanceof FormStyle)

+ 2 - 2
src/UI/Iview/Style/Col.php

@@ -163,13 +163,13 @@ class Col implements ColComponentInterface
 
     protected function buildGrid($grid)
     {
-        return $grid instanceof self ? $grid->build() : (int)$grid;
+        return $grid instanceof self ? $grid->getCol() : (int)$grid;
     }
 
     /**
      * @return object
      */
-    public function build()
+    public function getCol()
     {
         return (object)$this->rule;
     }

+ 1 - 1
src/UI/Iview/Validate.php

@@ -201,7 +201,7 @@ class Validate implements ValidateInterface
         return $this;
     }
 
-    public function build()
+    public function getValidate()
     {
         $validate = $this->validate;
         $validate['type'] = $this->type;