Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * 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));
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 /**
  * 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;
 }
Example #5
0
 /**
  * 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);
 }
Example #6
0
 /**
  * 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);
 }
Example #7
0
 /**
  * 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;
 }