/** * Set config value partially of completely * @param $name * @param $value * @return $this */ public function setConfig($name, $value) { if (is_null($name)) { $this->_config = new ArrayStorage($value); } else { $this->_config->setDeepValue($name, $value); } return $this; }
public static function getConfig($deepKey = null, $defaultValue = null) { if (empty(self::$_config)) { return $defaultValue; } if ($deepKey) { return self::$_config->getDeepValue($deepKey, $defaultValue); } }
public function set($deepKey, $value, $toEnvironment = null) { //@todo hasDeepKey if ($this->_environmentData && ($this->_environmentData->hasDeep($deepKey) && $toEnvironment !== false) || $toEnvironment === true) { $this->_environmentData->setDeepValue($deepKey, $value); } else { $this->_originalData->setDeepValue($deepKey, $value); } $this->_combinedData->setDeepValue($deepKey, $value); return $this; }
public function testBasic() { $storage = new ArrayStorage(); $storage->offsetSet('key', 'value'); $this->assertEquals('value', $storage->offsetGet('key'), 'offsetGet after offsetSet'); $this->assertEquals('value', $storage->get('key'), 'get after offsetSet'); $this->assertEquals('value', $storage['key'], '[]get after offsetSet'); $this->assertEquals('value', $storage->key, '__get after offsetSet'); $storage->key2 = 'value2'; $this->assertEquals('value2', $storage->key2, '__get after __set'); $this->assertEquals('value2', $storage->get('key2'), 'get after __set'); $this->assertEquals('value', $storage->getFirst(), 'first item getter'); $this->assertEquals('value2', $storage->getLast(), 'last item getter'); }
public function __call($method, $params) { $operation = substr($method, 0, 3); if (in_array($operation, array('get', 'set'))) { if (substr($method, -4) == 'Root') { $key = 'roots/' . strtolower(substr($method, 3, -4)); } else { $key = strtolower(substr($method, 3)); } if ($operation == 'get') { return $this->_vars->getDeepValue($key); } else { $this->_vars->setDeepValue($key, $params[0]); DC::getEventDispatcher()->dispatchEvent('environment.update', $key); return $this; } } else { return $this; } }
public function removeRoute($name) { $this->_routes->offsetUnset($name); return $this; }
public function get($key = null) { return $this->_data->get($key); }
public function getAll() { return $this->_storage->getArray(); }
public function setVar($name, $value) { $this->_vars->setDeepValue($name, $value); return $this; }
public function getCombinedVars($format = null) { if (!$format) { $format = $this->_responseFormat; } $combinedVars = new ArrayStorage($this->_vars); if ($this->_formatVars->has($format)) { $combinedVars->extendDeepValue($this->_formatVars->get($format)); } if ($format == View::FORMAT_HTML) { $combinedVars['_baseUri'] = DC::getRouter()->getBaseUri(); } return $combinedVars; }