Welcome Guest, Not a member yet? Register   Sign In
Libraries and config files.
#1

[eluser]Adam Griffiths[/eluser]
Hey guys,

I am in the middle of writing an authentication library, and I have a config file set up for it. The only problem I have is that I don't know how to access the variables. I've seen on the forum people mentioning about an initialize() function, do I need one? What does it need to do?

I have also seen in the Loader.php file...

Code:
function _ci_init_class($class, $prefix = '', $config = FALSE)
    {    
        $class = strtolower($class);
        
        // Is there an associated config file for this class?
        if ($config === NULL)
        {
            if (file_exists(APPPATH.'config/'.$class.EXT))
            {
                include_once(APPPATH.'config/'.$class.EXT);
            }
        }
        
        if ($prefix == '')
        {
            $name = (class_exists('CI_'.$class)) ? 'CI_'.$class : $class;
        }
        else
        {
            $name = $prefix.$class;
        }
        
        // Set the variable name we will assign the class to    
        $classvar = ( ! isset($this->_ci_varmap[$class])) ? $class : $this->_ci_varmap[$class];
                
        // Instantiate the class        
        $CI =& get_instance();
        if ($config !== NULL)
        {
            $CI->$classvar = new $name($config);
        }
        else
        {        
            $CI->$classvar = new $name;
        }    
    }

I guess from that I don't need to load the config file...but how would I access the config items in there?

I'm new to writing libraries, so if this sounds really dopey, it's just because I'm starting out Tongue

Thanks!


Messages In This Thread
Libraries and config files. - by El Forum - 08-14-2008, 12:24 PM
Libraries and config files. - by El Forum - 08-14-2008, 12:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB