Jose Diaz-Gonzalez is a developer living in New York City. He currently works at SeatGeek

About

Application Settings

php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
 * AppController
 *
 * Add your application-wide methods in the class below, your controllers
 * will inherit them.
 *
 * @package       cake
 * @subpackage    cake.app
 */
class AppController extends Controller {
/**
* Reads settings from database and writes them using the Configure class
* 
* @return void
* @access private
* @author Jose Diaz-Gonzalez
*/
  function _configureAppSettings() {
      $settings = array();
      $this->loadModel('Setting');
      $Setting = $this->Setting;
      if (($settings = Cache::read("settings.all")) === false) {
          $settings = $this->Setting->find('all');
          Cache::write("settings.all", $settings);
      }
      foreach($settings as $_setting) {
          if ($_setting['Setting']['value'] !== null) {
              Configure::write("{$_setting['Setting']['category']}.{$_setting['Setting']['setting']}", $_setting['Setting']['value']);
          }
      }
  }
}
?>
0 Responses. Add Yours!

Discussion

blog comments powered by Disqus