예제 #1
0
 /**
  * Creates a flat list node items.
  *
  * @param MW_Tree_Node_Interface $node Root node
  * @return Associated list of ID / node object pairs
  */
 protected function _getNodeMap(MW_Tree_Node_Interface $node)
 {
     $map = array();
     $map[(string) $node->getId()] = $node;
     foreach ($node->getChildren() as $child) {
         $map += $this->_getNodeMap($child);
     }
     return $map;
 }
예제 #2
0
 /**
  * Stores the values of the given node to the storage.
  *
  * This method does only store values like the node label but doesn't change
  * the tree layout by adding, moving or deleting nodes.
  *
  * @param MW_Tree_Node_Interface $node Tree node object
  */
 public function saveNode(MW_Tree_Node_Interface $node)
 {
     if ($node->getId() === null) {
         throw new MW_Tree_Exception(sprintf('Unable to save newly created nodes, use insert method instead'));
     }
     if ($node->isModified() === false) {
         return;
     }
     $conn = $this->_dbm->acquire($this->_dbname);
     try {
         $stmt = $conn->create($this->_config['update']);
         $stmt->bind(1, $node->getLabel());
         $stmt->bind(2, $node->getCode());
         $stmt->bind(3, $node->getStatus());
         $stmt->bind(4, $node->getId());
         $stmt->execute()->finish();
         $this->_dbm->release($conn, $this->_dbname);
     } catch (Exception $e) {
         $this->_dbm->release($conn, $this->_dbname);
         throw $e;
     }
 }