public static function loadConfig($filename)
    {
        self::fireEvent('Atomik::Loadconfig::Before', array(&$filename));
        
        // config file format
        if (!preg_match('/.+\.(php|ini|json)$/', $filename)) {
            $found = false;
            foreach (array('php', 'ini', 'json') as $format) {
                if (file_exists("$filename.$format")) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                throw new AtomikException("Configuration file '$filename' not found");
            }
            $filename .= ".$format";
        } else {
            $format = substr($filename, strrpos($filename, '.') + 1);
        }
        
        $config = array();
        if ($format === 'ini') {
            if (($data = parse_ini_file($filename, true)) === false) {
                throw new AtomikException('INI configuration malformed');
            }
            $config = self::dimensionizeArray($data, '.');
        } else if ($format === 'json') {
            if (($config = json_decode(file_get_contents($filename), true)) === null) {
                throw new AtomikException('JSON configuration malformed');
            }
        } else {
            if (is_array($return = include($filename))) {
                $config = $return;
            }
        }
        
        self::fireEvent('Atomik::Loadconfig::After', array($filename, &$config));
        return $config;
    }
public static function loadConfig($filename)
    {
        self::fireEvent('Atomik::Loadconfig::Before', array(&$filename));
        
        // config file format
        if (!preg_match('/.+\.(php|ini|json)$/', $filename)) {
            $found = false;
            foreach (array('php', 'ini', 'json') as $format) {
                if (file_exists("$filename.$format")) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                throw new AtomikException("Configuration file '$filename' not found");
            }
            $filename .= ".$format";
        } else {
            $format = substr($filename, strrpos($filename, '.') + 1);
        }
        
        $config = array();
        if ($format === 'ini') {
            if (($data = parse_ini_file($filename, true)) === false) {
                throw new AtomikException('INI configuration malformed');
            }
            $config = self::dimensionizeArray($data, '.');
        } else if ($format === 'json') {
            if (($config = json_decode(file_get_contents($filename), true)) === null) {
                throw new AtomikException('JSON configuration malformed');
            }
        } else {
            if (is_array($return = include($filename))) {
                $config = $return;
            }
        }
        
        self::fireEvent('Atomik::Loadconfig::After', array($filename, &$config));
        return $config;
    }
public static function loadConfig ( $ filename ) { self :: fireEvent ( 'Atomik::Loadconfig::Before' , array ( & $ filename ) ) ; // config file format if ( ! preg_match ( '/.+\.(php|ini|json)$/' , $ filename ) ) { $ found = false ; foreach ( array ( 'php' , 'ini' , 'json' ) as $ format ) { if ( file_exists ( "$filename.$format" ) ) { $ found = true ; break ; } } if ( ! $ found ) { throw new AtomikException ( "Configuration file '$filename' not found" ) ; } $ filename .= ".$format" ; } else { $ format = substr ( $ filename , strrpos ( $ filename , '.' ) + 1 ) ; } $ config = array ( ) ; if ( $ format === 'ini' ) { if ( ( $ data = parse_ini_file ( $ filename , true ) ) === false ) { throw new AtomikException ( 'INI configuration malformed' ) ; } $ config = self :: dimensionizeArray ( $ data , '.' ) ; } else if ( $ format === 'json' ) { if ( ( $ config = json_decode ( file_get_contents ( $ filename ) , true ) ) === null ) { throw new AtomikException ( 'JSON configuration malformed' ) ; } } else { if ( is_array ( $ return = include ( $ filename ) ) ) { $ config = $ return ; } } self :: fireEvent ( 'Atomik::Loadconfig::After' , array ( $ filename , & $ config ) ) ; return $ config ; }
Loads a configuration file

Supported format are php, ini and json
If the file's extension is not specified, the method will
search for a file with one of the supported extensions.

@param string $filename
@return array
Loads a configuration file