return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree());
}
+ public function dumpAtPath(ConfigurationInterface $configuration, $path)
+ {
+ $rootNode = $node = $configuration->getConfigTreeBuilder()->buildTree();
+
+ foreach (explode('.', $path) as $step) {
+ if (!$node instanceof ArrayNode) {
+ throw new \UnexpectedValueException(sprintf('Unable to find node at path "%s.%s"', $rootNode->getName(), $path));
+ }
+
+ /** @var NodeInterface[] $children */
+ $children = $node instanceof PrototypedArrayNode ? $this->getPrototypeChildren($node) : $node->getChildren();
+
+ foreach ($children as $child) {
+ if ($child->getName() === $step) {
+ $node = $child;
+
+ continue 2;
+ }
+ }
+
+ throw new \UnexpectedValueException(sprintf('Unable to find node at path "%s.%s"', $rootNode->getName(), $path));
+ }
+
+ return $this->dumpNode($node);
+ }
+
public function dumpNode(NodeInterface $node)
{
$this->reference = '';
}
/**
- * @param NodeInterface $node
- * @param int $depth
- * @param bool $prototypedArray
+ * @param NodeInterface $node
+ * @param NodeInterface|null $parentNode
+ * @param int $depth
+ * @param bool $prototypedArray
*/
- private function writeNode(NodeInterface $node, $depth = 0, $prototypedArray = false)
+ private function writeNode(NodeInterface $node, NodeInterface $parentNode = null, $depth = 0, $prototypedArray = false)
{
$comments = array();
$default = '';
$comments[] = 'Required';
}
+ // deprecated?
+ if ($node->isDeprecated()) {
+ $comments[] = sprintf('Deprecated (%s)', $node->getDeprecationMessage($node->getName(), $parentNode ? $parentNode->getPath() : $node->getPath()));
+ }
+
// example
if ($example && !is_array($example)) {
$comments[] = 'Example: '.$example;
}
- $default = (string) $default != '' ? ' '.$default : '';
+ $default = '' != (string) $default ? ' '.$default : '';
$comments = count($comments) ? '# '.implode(', ', $comments) : '';
$key = $prototypedArray ? '-' : $node->getName().':';
if ($children) {
foreach ($children as $childNode) {
- $this->writeNode($childNode, $depth + 1, $node instanceof PrototypedArrayNode && !$node->getKeyAttribute());
+ $this->writeNode($childNode, $node, $depth + 1, $node instanceof PrototypedArrayNode && !$node->getKeyAttribute());
}
}
}