src/Environment.php
public function setup($environment = null, $default = 'development')
    {
        if (Configure::read('Environment.setup')) {
            return false;
        }

        $current = $this->currentEnvironment($environment, $default);

        if (!isset($this->environments[$current])) {
            throw new Exception(sprintf('Environment %s does not exist.', $current));
        }

        $config = array_merge(
            $this->environments[$current]['config'],
            ['Environment.name' => $current]
        );
        foreach ($config as $param => $value) {
            Configure::write($param, $value);
        }

        if (is_callable($this->environments[$current]['callable'])) {
            $this->environments[$current]['callable']();
        }

        Configure::write('Environment.setup', true);

        return true;
    }
public function setup($environment = null, $default = 'development')
    {
        if (Configure::read('Environment.setup')) {
            return false;
        }

        $current = $this->currentEnvironment($environment, $default);

        if (!isset($this->environments[$current])) {
            throw new Exception(sprintf('Environment %s does not exist.', $current));
        }

        $config = array_merge(
            $this->environments[$current]['config'],
            ['Environment.name' => $current]
        );
        foreach ($config as $param => $value) {
            Configure::write($param, $value);
        }

        if (is_callable($this->environments[$current]['callable'])) {
            $this->environments[$current]['callable']();
        }

        Configure::write('Environment.setup', true);

        return true;
    }
public function setup ( $ environment = null , $ default = 'development' ) { if ( Configure :: read ( 'Environment.setup' ) ) { return false ; } $ current = $ this -> currentEnvironment ( $ environment , $ default ) ; if ( ! isset ( $ this -> environments [ $ current ] ) ) { throw new Exception ( sprintf ( 'Environment %s does not exist.' , $ current ) ) ; } $ config = array_merge ( $ this -> environments [ $ current ] [ 'config' ] , [ 'Environment.name' => $ current ] ) ; foreach ( $ config as $ param => $ value ) { Configure :: write ( $ param , $ value ) ; } if ( is_callable ( $ this -> environments [ $ current ] [ 'callable' ] ) ) { $ this -> environments [ $ current ] [ 'callable' ] ( ) ; } Configure :: write ( 'Environment.setup' , true ) ; return true ; }
Configures the current environment

@param string $environment Name of the environment we want to force setup for
@param string $default Default environment name
@return bool
@throws Cake\Core\Exception\Exception
Configures the current environment