當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。