Beispiel #1
0
LaravelCFG.prototype.addPoolToPool      = function (pathName, selectedPool, poolpath) {
  poolpath     = poolpath.split('/');
  selectedPool = selectedPool.split('/');
  this.initPool();

  var sourcePool = _un.getPath(this.cfgObject.pool, selectedPool);

  if (typeof sourcePool !== 'undefined') {

    var destination = _un.clone(poolpath);

    destination.push(pathName);

    var destinationPool = _un.getPath(this.cfgObject.pool, destination);

    if (typeof destinationPool === 'undefined') {

      this.cfgObject.pool = _un.setPath(this.cfgObject.pool, sourcePool, destination);

      this.saveCFG(function () {});

    } else {
      // destinationPool already exist
    }

  } else {
    // selectedPool is missing
  }
};
Beispiel #2
0
Config.prototype.get = function(key) {
    if (typeof key === 'undefined') {
        return this._config;
    }

    return _.getPath(this._config, key);
};
Beispiel #3
0
LaravelCFG.prototype.pathByName         = function (name, pool) {
  this.initPool();
  var poolpath;
  if (typeof pool === 'string' && pool === '') {
    poolpath = [];
  } else {
    poolpath = pool.split('/');
  }
  poolpath.push(name);
  return _un.getPath(this.cfgObject.pool, poolpath);
};
Beispiel #4
0
LaravelCFG.prototype.removePool = function (poolpath) {
  poolpath = poolpath.split('/');
  var last = poolpath[poolpath.length - 1];
  poolpath.pop();

  var obj = _un.getPath(this.cfgObject.pool, poolpath);

  if (typeof obj !== 'undefined') {
    delete obj[last];
    _un.setPath(this.cfgObject.pool, obj, poolpath);
    this.saveCFG(function () {});
  }
};
Beispiel #5
0
LaravelCFG.prototype.removePathFromPool = function (pathName, poolpath) {
  poolpath = poolpath.split('/');

  var obj = _un.getPath(this.cfgObject.pool, poolpath);

  if (typeof obj !== 'undefined') {
    if (obj.hasOwnProperty(pathName)) {
      delete obj[pathName];
      _un.setPath(this.cfgObject.pool, obj, poolpath);
      this.saveCFG(function () {});
    }
  }
};
Beispiel #6
0
Config.prototype._mergeProtectedArray = function(key, value) {
    var protectedValue = _.getPath(this.protectedConfig, key).slice(0);

    if (!Array.isArray(value)) {
        value = [value];
    }

    protectedValue = value.concat(protectedValue);

    // _.setPath does not mutate the original object:
    // https://github.com/documentcloud/underscore-contrib/issues/184
    this._config = _.setPath(this._config, protectedValue, key.split('.'), {});
};
Beispiel #7
0
LaravelCFG.prototype.poolByName         = function (name) {
  this.initPool();
  return _un.getPath(this.cfgObject.pool, name.split('/'));
};
Beispiel #8
0
Config.prototype._isProtectedArray = function(key) {
    return typeof _.getPath(this.protectedConfig, key) !== 'undefined';
};