Extracted the DI loading of an array from the YamlFileLoader

| 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.
You should check if the key `resource` exists