Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 50ec3bb

Browse filesBrowse files
committed
Add framework.secret doc
1 parent 0e92e0a commit 50ec3bb
Copy full SHA for 50ec3bb

File tree

Expand file treeCollapse file tree

8 files changed

+104
-11
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+104
-11
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ConfigDumpReferenceCommand.php
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ protected function configure()
3737
->setName('config:dump-reference')
3838
->setDefinition(array(
3939
new InputArgument('name', InputArgument::OPTIONAL, 'The Bundle name or the extension alias'),
40-
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
4140
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (yaml or xml)', 'yaml'),
4241
))
4342
->setDescription('Dumps the default configuration for an extension')
@@ -60,6 +59,10 @@ protected function configure()
6059
6160
<info>php %command.full_name% framework profiler.matcher</info>
6261
62+
The <info>--with-doc</info> option dumps nodes with documentation URL.
63+
64+
<info>php %command.full_name% FrameworkBundle --with-doc</info>
65+
6366
EOF
6467
)
6568
;
@@ -110,14 +113,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
110113
$message .= sprintf(' at path "%s"', $path);
111114
}
112115

116+
$withDoc = $input->getOption('with-doc');
113117
switch ($format) {
114118
case 'yaml':
115119
$io->writeln(sprintf('# %s', $message));
116-
$dumper = new YamlReferenceDumper();
120+
$dumper = new YamlReferenceDumper($withDoc);
117121
break;
118122
case 'xml':
119123
$io->writeln(sprintf('<!-- %s -->', $message));
120-
$dumper = new XmlReferenceDumper();
124+
$dumper = new XmlReferenceDumper($withDoc);
121125
break;
122126
default:
123127
$io->writeln($message);

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public function getConfigTreeBuilder()
5959
})
6060
->end()
6161
->children()
62-
->scalarNode('secret')->end()
62+
->scalarNode('secret')
63+
->doc('https://symfony.com/doc/%s/reference/configuration/framework.html#secret')
64+
->end()
6365
->scalarNode('http_method_override')
6466
->info("Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests. Note: When using the HttpCache, you need to call the method in your front controller instead")
6567
->defaultTrue()

‎src/Symfony/Component/Config/Definition/BaseNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/BaseNode.php
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,26 @@ public function getPath()
207207
return $path;
208208
}
209209

210+
/**
211+
* Sets an documentation URL.
212+
*
213+
* @param string $doc The documentation URL
214+
*/
215+
public function setDoc($doc)
216+
{
217+
$this->setAttribute('doc', $doc);
218+
}
219+
220+
/**
221+
* Retrieves the documentation URL configuration for this node.
222+
*
223+
* @return string The documentation URL
224+
*/
225+
public function getDoc()
226+
{
227+
return $this->getAttribute('doc');
228+
}
229+
210230
/**
211231
* Merges two values together.
212232
*

‎src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Config\Definition\NodeInterface;
1515
use Symfony\Component\Config\Definition\Exception\InvalidDefinitionException;
16+
use Symfony\Component\HttpKernel\Kernel;
1617

1718
/**
1819
* This class provides a fluent interface for defining a node.
@@ -340,4 +341,25 @@ protected function normalization()
340341
* @throws InvalidDefinitionException When the definition is invalid
341342
*/
342343
abstract protected function createNode();
344+
345+
/**
346+
* Sets doc configuration.
347+
*
348+
* @param string $doc
349+
*
350+
* @return NodeDefinition|$this
351+
*/
352+
public function doc($doc)
353+
{
354+
if (false === filter_var($doc, FILTER_VALIDATE_URL)) {
355+
throw new \InvalidArgumentException(sprintf('The "%s" is not a valid documentation URL.', $doc));
356+
}
357+
358+
// Adds sf version
359+
if (false !== strpos($doc, 'https://symfony.com/doc/')) {
360+
$doc = sprintf($doc, Kernel::MAJOR_VERSION.'.'.Kernel::MINOR_VERSION);
361+
}
362+
363+
return $this->attribute('doc', $doc);
364+
}
343365
}
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Config\Definition\Dumper;
13+
14+
use Symfony\Component\Config\Definition\ConfigurationInterface;
15+
16+
/**
17+
* Dumps a reference configuration for the given configuration/node instance.
18+
*
19+
* @author Dany Maillard <danymaillard93b@gmail.com>
20+
*/
21+
abstract class ReferenceDumper
22+
{
23+
protected $reference;
24+
protected $withDoc;
25+
26+
function __construct($withDoc = false)
27+
{
28+
$this->withDoc = $withDoc;
29+
}
30+
31+
abstract public function dump(ConfigurationInterface $configuration, $namespace = null);
32+
}

‎src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php
+6-3Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
*
2323
* @author Wouter J <waldio.webdesign@gmail.com>
2424
*/
25-
class XmlReferenceDumper
25+
class XmlReferenceDumper extends ReferenceDumper
2626
{
27-
private $reference;
28-
2927
public function dump(ConfigurationInterface $configuration, $namespace = null)
3028
{
3129
return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree(), $namespace);
@@ -149,6 +147,11 @@ private function writeNode(NodeInterface $node, $depth = 0, $root = false, $name
149147
$comments[] = 'Example: '.$example;
150148
}
151149

150+
// doc
151+
if ($this->withDoc && $doc = $child->getDoc()) {
152+
$comments[] = 'Doc: '.$doc;
153+
}
154+
152155
if ($child->isRequired()) {
153156
$comments[] = 'Required';
154157
}

‎src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
*
2525
* @author Kevin Bond <kevinbond@gmail.com>
2626
*/
27-
class YamlReferenceDumper
27+
class YamlReferenceDumper extends ReferenceDumper
2828
{
29-
private $reference;
30-
31-
public function dump(ConfigurationInterface $configuration)
29+
public function dump(ConfigurationInterface $configuration, $namespace = null)
3230
{
3331
return $this->dumpNode($configuration->getConfigTreeBuilder()->buildTree());
3432
}
@@ -128,6 +126,11 @@ private function writeNode(NodeInterface $node, $depth = 0, $prototypedArray = f
128126
$comments[] = 'Example: '.$example;
129127
}
130128

129+
// doc
130+
if ($this->withDoc && $doc = $node->getDoc()) {
131+
$comments[] = 'Doc: '.$doc;
132+
}
133+
131134
$default = (string) $default != '' ? ' '.$default : '';
132135
$comments = count($comments) ? '# '.implode(', ', $comments) : '';
133136

‎src/Symfony/Component/Config/Definition/NodeInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Definition/NodeInterface.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ public function hasDefaultValue();
5858
*/
5959
public function getDefaultValue();
6060

61+
/**
62+
* Returns the documentation URL of the node.
63+
*
64+
* @return string The documentation URL
65+
*/
66+
public function getDoc();
67+
6168
/**
6269
* Normalizes the supplied value.
6370
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.