/**
  * Load system keys by a path.
  */
 public function loadByPath($path)
 {
     $repository = $this->getEntityManager()->getRepository('RegistryBundle:System');
     $stmt = $this->getEntityManager()->getConnection()->prepare('SELECT * FROM system s1
         WHERE s1.systemkey LIKE :path');
     $params = array('path' => $path);
     $stmt->execute($params);
     $result = array();
     while ($row = $stmt->fetch()) {
         $s = new System();
         $s->LoadByArray($row);
         $result[] = $s;
     }
     return $result;
 }
Example #2
0
 /**
  * Read a set of registry keys and return them as array.
  * 
  * Important: This works with Redis too, but can get very slow
  * as all hash values must be retrieved to filter them by code.
  * 
  * @param string  $path
  * @return array
  */
 public function getSystemItems($path)
 {
     $entities = array();
     if ($this->isModeRedis()) {
         // redis load
         $array = $this->redis->hGetAll($this->redis_prefix . self::SYSTEM_HASH_KEY);
         // filter the result array
         foreach (array_keys($array) as $key) {
             if (preg_match('/^' . $path . '/', $key)) {
                 // $key = key; key:name:type
                 // $value = $array[$key]; value
                 // explode key by redis_key_name_delimiter to get key:name:type
                 $s = explode($this->redis_key_name_delimiter, $key);
                 if (count($s) != 3) {
                     throw new \Exception('Redis key format is not correct! (key' . $this->redis_key_name_delimiter . 'name' . $this->redis_key_name_delimiter . 'type)');
                 }
                 $entity = new SysKey();
                 $entity->loadByValues(0, $s[0], $s[1], $s[2], $array[$key]);
                 $entities[] = $entity;
             }
         }
         // cleanup
         unset($array);
     } else {
         if ($this->isModeDoctrine()) {
             // doctrine load
             $entities = $this->system->loadByPath($path);
         }
     }
     return $entities;
 }