-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
YamlFileLoader does 'supports' based purely on file extension #20308
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
Comments
Extending the |
We should not have to add anything as there is already a
Unfortunately, this key is not used at all in the DI public function supports($resource, $type = null)
{
return is_string($resxource) && in_array(pathinfo($resource, PATHINFO_EXTENSION), array('yml', 'yaml'), true));
} Imho we should change it to something like: public function supports($resource, $type = null)
{
return is_string($resxource) && (in_array(pathinfo($resource, PATHINFO_EXTENSION), array('yml', 'yaml'), true) || in_array($type, array('yml', 'yaml'), true));
} So we don't care about the resource extension except if |
@chalasr exactly also, in the same loader, $this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file); should become something like $this->import($import['resource'], isset($import['type']) ? $import['type'] : null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file); as the second parameter is the type. I think that's all. |
Good catch @salvocanna, shall I propose the change or do you want to (that's your issue, you deserve it)? |
@chalasr thanks! I'd like to do it even if it's the first one ever made (if I'm successful..) Which branch should it go to? I currently use symfony 2.8 so would be nice to see it there, but depends, should it be seen as a feature or bug fix? |
I'd go for a feature as it never worked before but others may think otherwise. |
@salvocanna I would propose it as a bugfix, as the type key exists and does not look useful as is. At worst your PR can be merged on another branch than the one you target at first (you can also change the base yourself from github if someone ask it). So if you go for a bugfix then 2.7 should be targeted, see http://symfony.com/doc/current/contributing/code/patches.html#step-3-submit-your-patch for details and don't forget to update/add the corresponding tests :) |
See #20611 |
…anagi) This PR was merged into the 3.3-dev branch. Discussion ---------- [DI] FileLoaders: Allow to explicit type to load | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20308 | License | MIT | Doc PR | Not yet (fabbot will scream out regarding the PR fixtures) Commits ------- 6b660c2 [DI] FileLoaders: Allow to explicit type to load
…anagi) This PR was merged into the 3.3-dev branch. Discussion ---------- [DI] FileLoaders: Allow to explicit type to load | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony#20308 | License | MIT | Doc PR | Not yet (fabbot will scream out regarding the PR fixtures) Commits ------- 6b660c2114 [DI] FileLoaders: Allow to explicit type to load
After playing a while with the symfony configuration I realised there's no way to make symfony parse and load a yaml file if its extension is not in ['yml', 'yaml']
Shouldn't it be a configuration?
Something like:
I can submit a pull request
I'm sorry if this may be already implemented somehow and I'm not aware of it.
Cheers
The text was updated successfully, but these errors were encountered: