/** * pretizeno o nastaveni povinnych hodnot * @param string $name * @param string $value */ public function getCreateItem($name = "", $value = "") { try { if (strlen($name) < 1) { throw new LBoxExceptionConfig(LBoxExceptionConfig::MSG_PARAM_STRING_NOTNULL, LBoxExceptionConfig::CODE_BAD_PARAM); } try { if (LBoxConfigManagerProperties::getInstance()->getPropertyByName($name)) { throw new LBoxExceptionConfig("'{$name}': This property already exists!"); } } catch (Exception $e) { switch ($e->getCode()) { case LBoxExceptionProperty::CODE_PROPERTY_NOT_FOUND: break; default: throw $e; } } $instance = parent::getCreateItem(); $instance->name = $name; $instance->setContent($value); return $instance; } catch (Exception $e) { throw $e; } }
/** * pretizeno o nastaveni povinnych hodnot * @param string $url * @param string $id * @return LBoxConfigItem */ public function getCreateItem($url = "", $id = "") { try { if (strlen($url) < 1) { throw new LBoxExceptionConfig(LBoxExceptionConfig::MSG_PARAM_STRING_NOTNULL, LBoxExceptionConfig::CODE_BAD_PARAM); } if (strlen($id) < 1) { $ids = array_keys($this->cacheNodes); arsort($ids); $id = current($ids) + 1; } try { if (LBoxConfigManagerStructure::getInstance()->getPageById($id)) { throw new LBoxExceptionConfigStructure("Page with this id already exists!", LBoxExceptionConfigStructure::CODE_ATTRIBUTE_UNIQUE_NOT_UNIQUE); } } catch (Exception $e) { switch ($e->getCode()) { case LBoxExceptionConfig::CODE_NODE_BYID_NOT_FOUND: case LBoxExceptionConfigStructure::CODE_NODE_BYURL_NOT_FOUND: break; default: throw $e; } } try { if (LBoxConfigManagerStructure::getInstance()->getPageByUrl($url)) { throw new LBoxExceptionConfigStructure("Page with this url already exists!", LBoxExceptionConfigStructure::CODE_ATTRIBUTE_UNIQUE_NOT_UNIQUE); } } catch (Exception $e) { switch ($e->getCode()) { case LBoxExceptionConfig::CODE_NODE_BYID_NOT_FOUND: case LBoxExceptionConfigStructure::CODE_NODE_BYURL_NOT_FOUND: break; default: throw $e; } } $instance = parent::getCreateItem(); $instance->id = $id; $instance->url = $url; return $instance; } catch (Exception $e) { throw $e; } }