本文整理汇总了PHP中MenuItem::getXmlPropertySetterName方法的典型用法代码示例。如果您正苦于以下问题:PHP MenuItem::getXmlPropertySetterName方法的具体用法?PHP MenuItem::getXmlPropertySetterName怎么用?PHP MenuItem::getXmlPropertySetterName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItem
的用法示例。
在下文中一共展示了MenuItem::getXmlPropertySetterName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: append
/**
* append node, reuses existing node if it's already there.
* @param $id item id
* @param array $properties named array property list, there should be setters for every option
* @return MenuItem
*/
public function append($id, $properties = array())
{
// items should be unique by id, search children for given id first
$newMenuItem = null;
$isNew = false;
foreach ($this->children as $nodeKey => $node) {
if ($node->getId() == $id) {
$newMenuItem = $node;
}
}
if ($newMenuItem == null) {
// create new menu item
$newMenuItem = new MenuItem($id, $this);
$isNew = true;
}
// set attributes
foreach ($properties as $propname => $propvalue) {
$methodName = $newMenuItem->getXmlPropertySetterName($propname);
$newMenuItem->{$methodName}((string) $propvalue);
}
$orderNum = sprintf("%05d", $newMenuItem->getOrder());
$idx = $orderNum . "_" . $newMenuItem->id;
if ($isNew) {
// new item, add to child list
$this->children[$idx] = $newMenuItem;
} else {
// update existing, if the sort order changed, move this child into the new position
foreach ($this->children as $key => $node) {
if ($node == $newMenuItem && $key != $idx) {
unset($this->children[$key]);
$this->children[$idx] = $newMenuItem;
break;
}
}
}
return $newMenuItem;
}
示例2: append
/**
* append node, reuses existing node if it's already there.
* @param $id item id
* @param array $properties named array property list, there should be setters for every option
* @return MenuItem
*/
public function append($id, $properties = array())
{
// items should be unique by id, search children for given id first
$newMenuItem = null;
$isNew = false;
foreach ($this->children as $nodeKey => $node) {
if ($node->getId() == $id) {
$newMenuItem = $node;
}
}
if ($newMenuItem == null) {
// create new menu item
$newMenuItem = new MenuItem($id, $this);
$isNew = true;
}
// set attributes
foreach ($properties as $propname => $propvalue) {
$methodName = $newMenuItem->getXmlPropertySetterName($propname);
if ($methodName != null) {
$newMenuItem->{$methodName}((string) $propvalue);
}
}
if ($isNew) {
// new item, add to child list
$orderNum = sprintf("%05d", $newMenuItem->getOrder());
$this->children[$orderNum . "_" . $newMenuItem->id] = $newMenuItem;
}
return $newMenuItem;
}