Exemple #1
0
 public static function getAll()
 {
     if (self::$settings) {
         return self::$settings;
     }
     $list = SettingsModel::all();
     $return = array();
     foreach ($list as $item) {
         $return[$item->key] = $item->value;
     }
     self::$settings = $return;
     return $return;
 }
 public function __construct()
 {
     $this->models = SettingsModel::all();
 }
Exemple #3
0
 /**
  * Конструктор
  */
 protected function __construct()
 {
     // Кешировка данных
     $cache = new Cache();
     $cache->setLocalPath('settings');
     $cache->load();
     if ($cache->isValid()) {
         $this->_items = json_decode($cache->getData(), true);
     } else {
         $data = \SettingsModel::all();
         if (!empty($data)) {
             foreach ($data as $i) {
                 $this->_items[$i->group][$i->name] = array('id' => $i->id, 'name' => $i->name, 'value' => $i->value, 'title' => $i->title, 'desc' => $i->desc);
             }
         }
         $cache->setData(json_encode($this->_items));
         $cache->save();
     }
 }