Exemple #1
0
 /**
  * По ключу элемента ($key) отыскивает его детей и возвращает их
  * @param $key string Путь от текущего элемента, к которому нужно получить доступ
  */
 public function get($key)
 {
     //
     $aNewPath = SystemRegisterHelper::responsePath($key);
     // Если путь больше чем 1
     if (sizeof($aNewPath) > 1) {
         return SystemRegisterHelper::delegate($this->aCurrentPath, $aNewPath, 'get', array());
     } else {
         $aChilds = SystemRegisterSample::selectChild($this->nId);
         // Ищем среди детей
         foreach ($aChilds as $row) {
             if ($row['name'] == $aNewPath[0]) {
                 // Имя совпало
                 // Это ветвь?
                 if (SystemRegisterHelper::isBranch($row['value'], $row['type'])) {
                     $szNewPath = SystemRegisterHelper::createPath($this->aCurrentPath, $aNewPath);
                     return new SystemRegister($szNewPath);
                 } else {
                     $primitive = new SystemRegisterPrimitive($this, $row['name'], $row['value'], $row['comment'], $row['type'], $row['id']);
                     return $primitive;
                 }
             }
         }
     }
     throw new SystemRegisterException('Element `' . $key . '` not found. Current element:' . $this->getFullPath());
 }