/** * Hydrate recursively the descendants of the given node * @param sfBreadNav $node Propel object for src node * @param PDOStatement $stmt Executed PDOStatement */ protected static function hydrateDescendants(NodeObject $node, PDOStatement $stmt) { $descendants = array(); $children = array(); $prevSibling = null; // set the class once to avoid overhead in the loop $cls = sfBreadNavPeer::getOMClass(); $cls = substr('.' . $cls, strrpos('.' . $cls, '.') + 1); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key = sfBreadNavPeer::getPrimaryKeyHashFromRow($row, 0); if (null === ($child = sfBreadNavPeer::getInstanceFromPool($key))) { $child = new $cls(); $child->hydrate($row); } $child->setLevel($node->getLevel() + 1); $child->setParentNode($node); if (!empty($prevSibling)) { $child->setPrevSibling($prevSibling); $prevSibling->setNextSibling($child); } $descendants[] = $child; if ($child->hasChildren()) { $descendants = array_merge($descendants, sfBreadNavPeer::hydrateDescendants($child, $stmt)); } else { $child->setChildren(array()); } $children[] = $child; $prevSibling = $child; sfBreadNavPeer::addInstanceToPool($child); if ($child->getRightValue() + 1 == $node->getRightValue()) { $child->setNextSibling(null); break; } } $node->setChildren($children); return $descendants; }