lithium\core\Environment::get PHP Method

get() public static method

Gets the current environment name, a setting associated with the current environment, or the entire configuration array for the current environment.
public static get ( string $name = null ) : mixed
$name string The name of the environment setting to retrieve, or the name of an environment, if that environment's entire configuration is to be retrieved. If retrieving the current environment name, `$name` should not be passed.
return mixed If `$name` is unspecified, returns the name of the current environment name as a string (i.e. `'production'`). If an environment name is specified, returns that environment's entire configuration as an array.
    public static function get($name = null)
    {
        $cur = static::$_current;
        if (!$name) {
            return $cur;
        }
        if ($name === true) {
            return isset(static::$_configurations[$cur]) ? static::$_configurations[$cur] : null;
        }
        if (isset(static::$_configurations[$name])) {
            return static::_processDotPath($name, static::$_configurations);
        }
        if (!isset(static::$_configurations[$cur])) {
            return static::_processDotPath($name, static::$_configurations);
        }
        return static::_processDotPath($name, static::$_configurations[$cur]);
    }

Usage Example

Example #1
0
 public static function config($name = null)
 {
     if (empty(self::$_config)) {
         $config = Libraries::get('li3_varnish');
         $env = Environment::get();
         if (isset($config[$env])) {
             $config += $config[$env];
             unset($config[$env]);
         }
         foreach ($config as $k => $v) {
             if (isset(self::$_defaults[$k]) && is_array(self::$_defaults[$k])) {
                 $config[$k] += self::$_defaults[$k];
             }
         }
         self::$_config = $config + self::$_defaults;
     }
     if (isset($name)) {
         if (isset(self::$_config[$name])) {
             return self::$_config[$name];
         } else {
             return null;
         }
     }
     return self::$_config;
 }
All Usage Examples Of lithium\core\Environment::get