Skip to content

Extracted the DI loading of an array from the YamlFileLoader #11954

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

Closed
wants to merge 1 commit into from

Conversation

stof
Copy link
Member

@stof stof commented Sep 19, 2014

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

This allows to reuse the logic easily for other loaders needing to extract data from an array.

Note that references and expressions are subject to the same syntax than in YAML files. the goal is to load arrays from a place where you might not be able to instantiate objects.

currently, only the YAMLFileLoader is using it, but the PlainArrayLoader (better named ArrayFileLoader btw) submitted in #11953 could reuse it as well. This would make it benefit from the safeguards added in #11374 as well.

I haven't added dedicated tests yet (but the code is executed by the YamlFileLoader tests). I can add some tests if there is an interest in merging this.

This allows to reuse the logic easily for other loaders needing to extract
data from an array.
@cordoval
Copy link
Contributor

exactly what i was thinking, this is very good @stof 👍

throw new InvalidArgumentException('The values in the "imports" key should be arrays.');
}

$this->import($import['resource'], null);
Copy link
Member

Choose a reason for hiding this comment

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

You should check if the key resource exists

@fabpot
Copy link
Member

fabpot commented Sep 24, 2014

I'm 👎 as enabling the YAML conventions in an array loader looks like a non-sense to me.

@stof
Copy link
Member Author

stof commented Sep 24, 2014

Yeah, this was the point where I was not sure about this. I agree that the string-based convention to reference services and others are a bit hackish. Closing this, and the PlainArrayLoader should not rely on such convention anymore

@stof stof closed this Sep 24, 2014
@stof stof deleted the di_array_loader branch September 24, 2014 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants