public function load($file, $namespace = '', $parser = null, $env = null)
    {
        $config = [];

        $this->currentFile = $file;

        //~ Check in cache
        if (is_object($this->cache)) {
            $config = $this->cache->get('Eureka.Component.Config.Test.' . $env . '.' . md5($file) . '.cache');
        }

        //~ If not in cache or cache object not defined
        if (empty($config)) {

            if (!file_exists($file)) {
                throw new \Exception('Configuration file does not exists !');
            }

            $config = $parser->load($file);

            if ($env !== null) {
                $configTmp = [];

                //~ Firstable, pick section 'all' from config if section exists.
                if (isset($config['all']) && is_array($config['all'])) {
                    $configTmp = $config['all'];
                }

                //~ Secondly, merge recursively with section corresponding with environment if section exists.
                if (isset($config[$env]) && is_array($config[$env])) {
                    $configTmp = array_replace_recursive($configTmp, $config[$env]);
                }

                //~ Set merged configurations into main array.
                $config = $configTmp;
            }

            if (is_object($this->cache)) {
                $this->cache->set('Eureka.Component.Config.Test.' . $env . '.' . md5($file) . '.cache', $config);
            }
        }

        $this->add($namespace, $config);

        $this->currentFile = '';

        return $this;
    }
public function load($file, $namespace = '', $parser = null, $env = null)
    {
        $config = [];

        $this->currentFile = $file;

        //~ Check in cache
        if (is_object($this->cache)) {
            $config = $this->cache->get('Eureka.Component.Config.Test.' . $env . '.' . md5($file) . '.cache');
        }

        //~ If not in cache or cache object not defined
        if (empty($config)) {

            if (!file_exists($file)) {
                throw new \Exception('Configuration file does not exists !');
            }

            $config = $parser->load($file);

            if ($env !== null) {
                $configTmp = [];

                //~ Firstable, pick section 'all' from config if section exists.
                if (isset($config['all']) && is_array($config['all'])) {
                    $configTmp = $config['all'];
                }

                //~ Secondly, merge recursively with section corresponding with environment if section exists.
                if (isset($config[$env]) && is_array($config[$env])) {
                    $configTmp = array_replace_recursive($configTmp, $config[$env]);
                }

                //~ Set merged configurations into main array.
                $config = $configTmp;
            }

            if (is_object($this->cache)) {
                $this->cache->set('Eureka.Component.Config.Test.' . $env . '.' . md5($file) . '.cache', $config);
            }
        }

        $this->add($namespace, $config);

        $this->currentFile = '';

        return $this;
    }
public function load ( $ file , $ namespace = '' , $ parser = null , $ env = null ) { $ config = [ ] ; $ this -> currentFile = $ file ; //~ Check in cache if ( is_object ( $ this -> cache ) ) { $ config = $ this -> cache -> get ( 'Eureka.Component.Config.Test.' . $ env . '.' . md5 ( $ file ) . '.cache' ) ; } //~ If not in cache or cache object not defined if ( empty ( $ config ) ) { if ( ! file_exists ( $ file ) ) { throw new \ Exception ( 'Configuration file does not exists !' ) ; } $ config = $ parser -> load ( $ file ) ; if ( $ env !== null ) { $ configTmp = [ ] ; //~ Firstable, pick section 'all' from config if section exists. if ( isset ( $ config [ 'all' ] ) && is_array ( $ config [ 'all' ] ) ) { $ configTmp = $ config [ 'all' ] ; } //~ Secondly, merge recursively with section corresponding with environment if section exists. if ( isset ( $ config [ $ env ] ) && is_array ( $ config [ $ env ] ) ) { $ configTmp = array_replace_recursive ( $ configTmp , $ config [ $ env ] ) ; } //~ Set merged configurations into main array. $ config = $ configTmp ; } if ( is_object ( $ this -> cache ) ) { $ this -> cache -> set ( 'Eureka.Component.Config.Test.' . $ env . '.' . md5 ( $ file ) . '.cache' , $ config ) ; } } $ this -> add ( $ namespace , $ config ) ; $ this -> currentFile = '' ; return $ this ; }
Get config value for config var specified.

@param  string $file
@param  string $namespace
@param  object $parser File parser
@param  string $env
@return $this
@throws \Exception
Get config value for config var specified .