/** * Get all the node settings for all the children of the provided node (recursively). * @param Node $node * @return array Array with NodeSetting objects */ public function getAllNodeSettingsForNode(Node $node, $condition = null, $order = null, array $variables = null) { $path = $node->getPath(); $query = $this->createQuery(0); $query->addCondition('{node.id} = %1% OR {node.parent} = %2% OR {node.parent} LIKE %3%', $node->id, $path, $path . NodeModel::PATH_SEPARATOR . '%'); if ($condition) { $query->addConditionWithVariables($condition, $variables); } if ($order) { $query->addOrderByWithVariables($order, $variables); } return $query->query(); }
/** * Gets the number of children levels for the provided node * @param Node $node * @return integer */ public function getChildrenLevelsForNode(Node $node) { $path = $node->getPath(); $query = $this->createQuery(0); $query->setFields('MAX(LENGTH({parent}) - LENGTH(REPLACE({parent}, %1%, %2%))) + 1 AS levels', self::PATH_SEPARATOR, ''); $query->addCondition('{parent} LIKE %1%', $path . '%'); $result = $query->queryFirst(); return $result->levels - $node->getLevel(); }