Пример #1
0
 /**
  * Initialize the all or only autoload options.
  *
  * @param bool $autoload
  */
 protected function initialize($autoload = false)
 {
     if ($this->initialized) {
         return;
     }
     if ($autoload) {
         if (!$this->autoload) {
             $this->options = $this->autoload = $this->cache->fetch($this->prefix . 'Autoload');
         }
         if ($this->autoload) {
             return;
         }
         $query = "SELECT name, value, autoload FROM {$this->table} WHERE autoload = 1";
     } else {
         $query = "SELECT name, value, autoload FROM {$this->table}";
     }
     if ($options = $this->connection->fetchAll($query)) {
         foreach ($options as $option) {
             $this->options[$option['name']] = json_decode($option['value'], true);
             if ($option['autoload']) {
                 $this->autoload[$option['name']] = $this->options[$option['name']];
             }
         }
         $this->cache->save($this->prefix . 'Autoload', $this->autoload);
         if (!$autoload) {
             $this->initialized = true;
         }
     }
 }