X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fsymfony%2Fconfig%2FDefinition%2FDumper%2FYamlReferenceDumper.php;fp=vendor%2Fsymfony%2Fconfig%2FDefinition%2FDumper%2FYamlReferenceDumper.php;h=5a0e76c5255a382b5265684a156b36aa92c8d5c0;hp=a474249380914bf3c013bf57ac9ea739877d37f6;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/symfony/config/Definition/Dumper/YamlReferenceDumper.php b/vendor/symfony/config/Definition/Dumper/YamlReferenceDumper.php index a47424938..5a0e76c52 100644 --- a/vendor/symfony/config/Definition/Dumper/YamlReferenceDumper.php +++ b/vendor/symfony/config/Definition/Dumper/YamlReferenceDumper.php @@ -33,6 +33,32 @@ class YamlReferenceDumper 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 = ''; @@ -44,11 +70,12 @@ class YamlReferenceDumper } /** - * @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 = ''; @@ -97,12 +124,17 @@ class YamlReferenceDumper $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().':'; @@ -140,7 +172,7 @@ class YamlReferenceDumper 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()); } } }