<?php
 class MenuModuleItemVO implements MotoDomObjectInterface { public $id; public $order; public $parent; public $click; public $properties; protected $_node; protected $_childs = null; public function __construct(DOMNode $parent = null) { if (!empty($parent)) { $this->loadDomElement($parent); } } public function loadDomElement(DOMNode $parent) { $this->_node = $parent; $this->id = (integer) $parent->getAttribute('id'); $this->parent = (integer) $parent->getAttribute('parent'); $this->click = (string) $parent->getAttribute('click'); $this->order = (integer) $parent->getAttribute('order'); $this->properties = PropertyVO::findAll($parent); return $this; } public function saveDomElement(DOMNode $parent) { $parent->setAttribute('id', (integer) $this->id); $parent->setAttribute('parent', (integer) $this->parent); $parent->setAttribute('click', (string) $this->click); $parent->setAttribute('order', (integer) $this->order); $propertiesNode = $parent->appendChild(new DOMElement('properties')); foreach ($this->properties as $property) { $property->saveDomElement($propertiesNode->appendChild(new DOMElement('item'))); } return $parent; } public function remove() { if (!is_null($this->_node)) { $this->_node->parentNode->removeChild($this->_node); $this->_node = null; } return true; } public static function findById($id, DOMNode $context) { return MotoXML::findOneByXPath(".//data/item[@id='{$id}']", $context, get_class()); } public static function findAll(DOMNode $context) { return MotoXML::findByXPath(".//data/item", $context, get_class()); } function childExists() { return ( $this->_childs != null); } function getChilds() { return $this->_childs; } function addChild($item) { if ($this->_childs == null) $this->_childs = array(); $this->_childs[] = $item; } } 