/** * Initializes the decorator. * * @param \Aimeos\MW\Config\Iface $object Config object or decorator * @param string $prefix Prefix for keys to distinguish several instances */ public function __construct(\Aimeos\MW\Config\Iface $object, $prefix = '') { if (function_exists('apc_store') === false) { throw new \Aimeos\MW\Config\Exception('APC not available'); } parent::__construct($object); $this->prefix = $prefix; }
/** * Sets the value for the specified key * * @param string $name Path to the requested value like tree/node/classname * @param mixed $value Value that should be associated with the given path */ public function set($name, $value) { foreach ($this->prefixes as $prefix => $len) { if (strncmp($name, $prefix, $len) === 0) { return parent::set($name, $value); } } throw new \Aimeos\MW\Config\Exception(sprintf('Not allowed to set "%1$s" configuration', $name)); }
/** * Returns the value of the requested config key. * * @param string $name Path to the requested value like tree/node/classname * @param mixed $default Value returned if requested key isn't found * @return mixed Value associated to the requested key */ public function get($name, $default = null) { $name = trim($name, '/'); if (isset($this->negCache[$name])) { return $default; } if (array_key_exists($name, $this->cache)) { return $this->cache[$name]; } if (($value = $this->getValueFromArray($this->config, explode('/', $name))) === null) { $value = parent::get($name, null); } if ($value === null) { $this->negCache[$name] = true; return $default; } $this->cache[$name] = $value; return $value; }
/** * Returns the value of the requested config key. * * @param string $name Path to the requested value like tree/node/classname * @param mixed $default Value returned if requested key isn't found * @return mixed Value associated to the requested key */ public function get($name, $default = null) { $value = parent::get($name, $default); $this->file->set($name, $value, $default); return $value; }
/** * Initializes the decorator. * * @param \Aimeos\MW\Config\Iface $object Config object or decorator * @param string $filename File name the collected configuration is written to */ public function __construct(\Aimeos\MW\Config\Iface $object, $filename = 'confdoc.ser') { parent::__construct($object); // this object is not cloned! $this->file = new ConfigFile($filename); }
/** * Sets the value for the specified key. * * @param string $path Path to the requested value like tree/node/classname * @param string $value Value that should be associated with the given path */ public function set($path, $value) { $path = trim($path, '/'); parent::set($path, $value); apc_store($this->prefix . $path, $value); }
/** * Initializes the decorator. * * @param \Aimeos\MW\Config\Iface $object Config object or decorator * @param array $config Pre-cached non-shared configuration */ public function __construct(\Aimeos\MW\Config\Iface $object, $config = array()) { parent::__construct($object); $this->config = $config; }