File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ class XWC_Config implements Config_Repository {
2929     * 
3030     * @var T 
3131     */ 
32-     protected  array  $ settings =  array () ;
32+     protected  array  $ settings
3333
3434    /** 
3535     * Constructor 
@@ -39,16 +39,14 @@ class XWC_Config implements Config_Repository {
3939     * 
4040     * @throws \InvalidArgumentException If no settings are provided. 
4141     */ 
42-     public  function  __construct ( array  $ argsprotected  array  $ defaultsarray () ) {
42+     public  function  __construct ( protected   array  $ argsprotected  array  $ defaultsarray () ) {
4343        if  ( ! isset ( $ args'api ' ] ) && ! isset ( $ args'page ' ] ) ) {
4444            throw  new  \InvalidArgumentException (
4545                'You must provide either an WC Settings_API or a WC_Settings_Page configuration ' ,
4646            );
4747        }
4848
49-         foreach  ( $ argsas  $ type$ prefix
50-             $ this parse_settings ( $ type$ prefix
51-         }
49+         $ this reload ();
5250    }
5351
5452    /** 
@@ -227,6 +225,21 @@ protected function get_sub( string ...$keys ): mixed {
227225        return  $ opts
228226    }
229227
228+     /** 
229+      * Reload the config array 
230+      * 
231+      * @return static 
232+      */ 
233+     public  function  reload (): static 
234+         $ this settings  = array ();
235+ 
236+         foreach  ( $ this args  as  $ type$ prefix
237+             $ this parse_settings ( $ type$ prefix
238+         }
239+ 
240+         return  $ this 
241+     }
242+ 
230243    /** 
231244     * Get the settings array 
232245     * 
Original file line number Diff line number Diff line change 1212 * Interface describing a config repository 
1313 */ 
1414interface  Config_Repository {
15+     /** 
16+      * Reload the config array 
17+      * 
18+      * @return static 
19+      */ 
20+     public  function  reload (): static 
21+ 
1522    /** 
1623     * Get the entire config array 
1724     * 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments