Esempio n. 1
0
 /**
  * 
  * vytvori novou item pod predaneho parenta
  * @param LBoxConfigItemStructure $parent
  * @param string $urlPart
  */
 public function getCreateChild(LBoxConfigItemStructure $parent, $urlPart = "")
 {
     try {
         if (strlen($urlPart) < 1) {
             throw new LBoxExceptionConfig(LBoxExceptionConfig::MSG_PARAM_STRING_NOTNULL, LBoxExceptionConfig::CODE_BAD_PARAM);
         }
         $url = $parent->url . "/" . $urlPart . "/";
         $url = preg_replace("/(\\/+)/", "/", $url);
         if ($parent->hasChildren()) {
             $maxId = 0;
             foreach ($parent->getChildNodesIterator() as $child) {
                 $maxId = $child->id > $maxId ? $child->id : $maxId;
             }
             $id = $maxId + 1;
         } else {
             $id = (int) ((string) $parent->id . "001");
             while (array_key_exists($id, $this->cacheNodes)) {
                 $id++;
             }
         }
         $child = $this->getCreateItem($url, $id);
         $parent->appendChild($child);
         return $child;
     } catch (Exception $e) {
         throw $e;
     }
 }