Skip to content
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

Fix XML/YAML config loading #575

Merged
merged 1 commit into from
Jun 13, 2016
Merged

Fix XML/YAML config loading #575

merged 1 commit into from
Jun 13, 2016

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Jun 13, 2016

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/A
License MIT
Doc PR n/a

Fix an error when the Resources/config directory doesn't exist in the bundle ([InvalidArgumentException] The "/api-platform/src/AppBundle/Resources/config/" directory does not exist.).

Improve the code to load XML and YAML files.

ping @soyuka

$configDirectory = dirname($reflectionClass->getFileName()).'/Resources/config/';

try {
foreach (Finder::create()->files()->in($configDirectory)->path('api_resources')->name('*.{yml,yaml,xml}') as $file) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api_resources.{yml,yaml,xml} doesn't seem to be loaded anymore?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behat is requiring both to be loaded to pass if I remember correctly. If it's not the case, there's a missing test case.

@soyuka
Copy link
Member

soyuka commented Jun 13, 2016

see #576 too, take the want you prefer but anyway both implementations are correct ;)

@dunglas
Copy link
Member Author

dunglas commented Jun 13, 2016

I prefer this implementation because it doesn't rely on glob + the Symfony Finder but only on the finder.

@soyuka
Copy link
Member

soyuka commented Jun 13, 2016

Can you explain how it takes api_resources.xml and api_resources/*.xml? Is Finder::path matching directories with files?

@dunglas
Copy link
Member Author

dunglas commented Jun 13, 2016

It doesn't work. A test should be added for that.

@dunglas
Copy link
Member Author

dunglas commented Jun 13, 2016

My bad, the test (and my code) work fine.

@soyuka
Copy link
Member

soyuka commented Jun 13, 2016

https://github.com/api-platform/core/blob/master/features/configurable.feature

Both are there I checked so this can be merged ;).

Fun that ->path takes both into consideration, good to know. Hope it's a feature and not a bug.

@dunglas dunglas merged commit 2607346 into master Jun 13, 2016
@dunglas dunglas deleted the fix_config branch June 13, 2016 12:13
@dunglas
Copy link
Member Author

dunglas commented Jun 13, 2016

Thank for your help @soyuka

@teohhanhui
Copy link
Contributor

@soyuka:

Fun that ->path takes both into consideration, good to know. Hope it's a feature and not a bug.

Perhaps we should open an issue on symfony/symfony. It's not clear from the documentation... http://symfony.com/doc/current/components/finder.html#path

soyuka added a commit to soyuka/symfony-docs that referenced this pull request Jun 14, 2016
For clarity, adds an example where `path()` is used to match a directory or a file.

ref api-platform/core#575 (comment)
soyuka added a commit to soyuka/symfony-docs that referenced this pull request Jun 14, 2016
For clarity, adds an example where `path()` is used to match a directory or a file.

ref api-platform/core#575 (comment)
soyuka added a commit to soyuka/symfony-docs that referenced this pull request Jun 18, 2016
For clarity, adds an example where `path()` is used to match a directory or a file.

ref api-platform/core#575 (comment)
xabbuh added a commit to symfony/symfony-docs that referenced this pull request Jun 20, 2016
…oyuka)

This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #6652).

Discussion
----------

`Finder::path()` method matching directories and files

For clarity, adds an example where `path()` is used to match a directory or a file.

ref api-platform/core#575 (comment)

Commits
-------

cd28675 Improve `Finder::path` code example about resulting matches
magarzon pushed a commit to magarzon/core that referenced this pull request Feb 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants