Welcome Guest, Not a member yet? Register   Sign In
Need a little help with a config file for my custom library...???
#13

[eluser]tomcode[/eluser]
I'll keep the config file as plain data holder, no code, the model call probably won't work anyway.

You could do :

Code:
class Paypal_ap {

    var $defaults = array('x', 'y');
    
    var $x = NULL;
    var $y = NULL;
    var $z = NULL;
    
    function Paypal_ap($params = array())
    {
      $this->initialize($params);
    }

    function initialize($params = array())
    {
        foreach($params as $key => $param)
        {
            if(isset($this->$key))
            {
                $this->$key = $param;
            }
        }
    }

    function reset()
    {
        $CI =& get_instance();
        
        $values = array();
        
        foreach($this->defaults as $key)
        {
            $values[$key] = $CI->config->item($key);
        }
        
        $this->initialize($values);
    }
}

Now You can have a fully automated run, You can set values from the controller and You have a convenience function to easily return to a default state.


Messages In This Thread
Need a little help with a config file for my custom library...??? - by El Forum - 12-20-2010, 04:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB