-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Config] allow changing the path separator #22253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d5798f5 to
bef2bb0
Compare
9f680c6 to
bcf4039
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing tests and CHANGELOG entry
| { | ||
| const DEFAULT_PATH_SEPARATOR = '.'; | ||
|
|
||
| private $pathSeparator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since all other props are protected, should we make this one protected also, and use it directly in child nodes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep it private if it does not need to be protected. It is easier for our BC policy
| * @var NodeDefinition|null | ||
| */ | ||
| protected $root; | ||
| protected $builder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be deprecated instead with an annotation (no need for runtime BC layer since this is useless, WDYT?)
| */ | ||
| abstract class NodeDefinition implements NodeParentInterface | ||
| { | ||
| private $pathSeparator = BaseNode::DEFAULT_PATH_SEPARATOR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected?
| public function __construct($name, NodeInterface $parent = null, $pathSeparator = self::DEFAULT_PATH_SEPARATOR) | ||
| { | ||
| if (false !== strpos($name, '.')) { | ||
| throw new \InvalidArgumentException('The name must not contain ".".'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be kept, but the dot replaced by the pathSeparator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not, but this is the only place where the name is checked. In prototyped node, name property is not enforced and make Node inconsistent. See 7be490f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bburnichon would you mind reverting this change (and using the $pathSeparator of course). Better not remove an existing check.
| /** | ||
| * @throws \RuntimeException if root node is not defined. | ||
| */ | ||
| private function assertTreeHasRootNode() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think doing removing this an doing the check inline would be fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is currently called twice. It is done this way to keep code DRY.
bcf4039 to
66545c5
Compare
69db47b to
669122c
Compare
|
Rebase needed (we don't merge PRs when they contain merge commit) |
10a8911 to
7e38a5c
Compare
|
Tests are failing on Form Component which I did not change. Is it a known issue? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(tests back to green)
| /** | ||
| * @param string $name The name of the node | ||
| * @param NodeInterface $parent The parent of this node | ||
| * Constructor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we recently remove all comments like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it was reintroduced by my rebase. I will remove it.
| /** | ||
| * @return NodeDefinition[] | ||
| */ | ||
| public function getChildrenNodeDefinitions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reads weird to me, what about getChildNodeDefinitions() or getChildNodesDefinitions()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we really need this interface or if we shouldn't rather check for the method to exist. We could then add this method to the ParentNodeDefinitionInterface in 4.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong opinion about how to name this method. Actually, I already had a hard time finding this one. The same is true for the whole interface.
In case checking for the method to exist, how would you mark deprecation notice though?
| */ | ||
| public function setPathSeparator($separator) | ||
| { | ||
| if ($this instanceof ChildrenAwareNodeDefinitionInterface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($this instanceof ArrayNodeDefinition) { would be enough for the purpose, isn't it?
about the method, my preference is getChildNodeDefinitions
|
We will also need to update the |
UPGRADE-4.0.md
Outdated
| Config | ||
| ------ | ||
|
|
||
| * Implementing `ParentNodeDefinitionInterface` without the `getChildNodeDefinitions()` is now forbidden. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rewrite this to be like this:
Added the
getChildNodeDefinitions()method toParentNodeDefinitionInterface.
|
Twig and VarDumper failure don't seem to be related to my PR. Are failures expected? |
|
The Twig failure should be fixable by rebasing on the latest |
6b99f9b to
5f39fba
Compare
|
Moving to 4.1 as 3.4 is now in beta, thus closed for new feats. |
5f39fba to
b05c98f
Compare
|
Failures do not seem linked to my changes. |
2e54486 to
5f29f79
Compare
|
Rebased after merge of deprecation and removal of |
5f29f79 to
0652c7f
Compare
18664f4 to
14d6f78
Compare
|
@bburnichon please rebase: we don't merge PR with merge commits. |
|
Sorry I did update via github interface. |
9a1e4fe to
e5e70ec
Compare
|
I like this feature, but I wonder if "path separator" is the best name for this option. Path is strongly related to "file paths". Maybe "name separator" or "key separator" or "children separator" etc. |
|
@javiereguiluz "path" is the correct term, already used a lot in the component: |
e5e70ec to
03f8804
Compare
03f8804 to
15e05e1
Compare
|
Thank you @bburnichon. |
This PR was merged into the 4.1-dev branch. Discussion ---------- [Config] allow changing the path separator | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22268 | License | MIT | Doc PR | In bundles configuration, no dots are allowed in key names, but as a standalone config, there is no such limitation that should be enforced. By using current `NodeBuilder` it should be possible to change path separator used (for example: `/`) Commits ------- 15e05e1 Add feature allowing change of Path Separator
In bundles configuration, no dots are allowed in key names, but as a standalone config, there is no such limitation that should be enforced.
By using current
NodeBuilderit should be possible to change path separator used (for example:/)