Update to the Conf Component

Not so long ago I’ve created a component to handle DB based configuration and settings. It was pretty clean and slim. Some features however were needed ( requested ), so the component got some updates.

First of all, the way you set and get values have changed, instead of two parameters:

  1.  
  2. $value = $this->get(category’,key’);
  3. $this->set(category’,key’,$val);
  4.  

You now do:

  1.  
  2. $value = $this->get(category.key’);
  3. $this->set(category.key’,$val);
  4.  

This is more cake-ish indeed.
get() also has new parameters, one is the default value returned if the requested value doesn’t exist (kudos to biesbjerg). Another parameter has to deal with boolean values. Basically it converts true’ and false’ to true and false if you set it to true.

  1.  
  2. // return defaultValue’ if key doesn’t exist
  3. $value   = $this->get(category.key’,defaultValue’);
  4. // return true if key doesn’t exist. Also convert boolean values
  5. $value2 = $this->get(category.key2′,true,true);
  6. // get all category values
  7. $all = $this->get(category.*’);
  8.  

Caching has been introduced to minimize db hits. hmm what else, I’ll let you read the tutorial. Don’t forget to grab the new version from bakery