-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] "mappings" for validation #13878
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
You shouldn't have to specify the file type in the config. This is already specified by the file extension. |
Ok, for the "$container->addResource()" statement I dont need the file extension. |
locks better? if (preg_match('/\.(yml|xml)$/', $file, $matches)) {
if ('yml' === $matches[1]) {
$yamlMappings[] = $file;
} elseif ('xml' === $matches[1]) {
$xmlMappings[] = $file;
}
} |
Yes. That's the idea. |
620cd61
to
e7d15ac
Compare
I think the proper solution would be to rely on Puli in 3.0, if it gets included. |
I would be glad to have a feature something like this. 👍 I would just drop that in the app/config folder, where all the other configurations reside already. |
->arrayNode('mappings') | ||
->prototype('array') | ||
->children() | ||
->scalarNode('file')->end() |
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.
What is the reason to have an extra file
key here?
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.
in preparation for the "dir" key to include all mapping files automatically from this directory.
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 allow to mix files and directories and make the distinction in the extension?
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.
Or if you want to keep them separated, I would use mappings.files
and mappings.dirs
or something like that as different lists.
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.
could be a solution, like is_file($path)
and is_dir($path)
?
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.
mapping
would become a singular in such case though, as you would have a single node for it though.
I agree with @xabbuh though. The prototyped node should not be mappings
if you only configure either file
or dir
in it
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.
what do you think:
framework:
validation:
mapping:
files:
- ".../validation.yml"
dirs:
- ".../config/validations"
Looks like a good idea to me, @davewwww Can you take the comments into account? |
I've changed the configuration and added the directory feature. |
$files[$ext][] = $file; | ||
} | ||
|
||
if (count($files['xml']) > 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.
IMO !empty($files['xml'])
will be faster and more memory efficient.
…on to define extra validation files or directories which are not in the 'Bundle*/Resources/config' directory.
ok, i've separated the framework-defined files from the user-defined files and removed the addResource(). |
Can you also update the XSD file of the FrameworkBundle config? |
i've never used this xsd feature. ...
<xsd:complexType name="validation">
...
<xsd:attribute name="mapping" type="validation_mapping" />
</xsd:complexType>
<xsd:complexType name="validation_mapping">
<xsd:sequence>
<xsd:element name="file" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="dir" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
... |
@davewwww yes, that looks correct. |
Any update about this feature ? |
@davewwww Do you have time to finish this feature? It looks like we are almost there. Thanks. It would also need to be resubmitted on current master, but that should not be too difficult. |
Thanks! |
This feature allows you, to define additional validation files or directories which are not in the 'Bundle*/Resources/config/' directory.