当前位置: 首页>>代码示例>>PHP>>正文


PHP MenuItem::getXmlPropertySetterName方法代码示例

本文整理汇总了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;
 }
开发者ID:paudam,项目名称:opnsense-core,代码行数:43,代码来源:MenuItem.php

示例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;
 }
开发者ID:nasaa0528,项目名称:core,代码行数:35,代码来源:MenuItem.php


注:本文中的MenuItem::getXmlPropertySetterName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。