/** * Creates a flat list node items. * * @param \Aimeos\MW\Tree\Node\Iface $node Root node * @return Associated list of ID / node object pairs */ protected function getNodeMap(\Aimeos\MW\Tree\Node\Iface $node) { $map = array(); $map[(string) $node->getId()] = $node; foreach ($node->getChildren() as $child) { $map += $this->getNodeMap($child); } return $map; }
/** * 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 \Aimeos\MW\Tree\Node\Iface $node Tree node object */ public function saveNode(\Aimeos\MW\Tree\Node\Iface $node) { if ($node->getId() === null) { throw new \Aimeos\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; } }