示例#1
0
文件: Compiler.php 项目: solve/slot
 /**
  * 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;
 }
示例#2
0
 public static function getConfig($deepKey = null, $defaultValue = null)
 {
     if (empty(self::$_config)) {
         return $defaultValue;
     }
     if ($deepKey) {
         return self::$_config->getDeepValue($deepKey, $defaultValue);
     }
 }
示例#3
0
文件: Config.php 项目: solve/config
 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;
 }
示例#4
0
 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');
 }
示例#5
0
 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;
     }
 }
示例#6
0
文件: Router.php 项目: solve/router
 public function removeRoute($name)
 {
     $this->_routes->offsetUnset($name);
     return $this;
 }
示例#7
0
 public function get($key = null)
 {
     return $this->_data->get($key);
 }
示例#8
0
 public function getAll()
 {
     return $this->_storage->getArray();
 }
示例#9
0
文件: Request.php 项目: solve/http
 public function setVar($name, $value)
 {
     $this->_vars->setDeepValue($name, $value);
     return $this;
 }
示例#10
0
文件: View.php 项目: solve/solve
 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;
 }