Skip to content

Latest commit

 

History

History
48 lines (35 loc) · 1.67 KB

yaml_reader_task.md

File metadata and controls

48 lines (35 loc) · 1.67 KB

YamlReaderTask

Parses a YAML file, whose path is set in the options, and iterates over its root elements.

Task reference

  • Service: CleverAge\ProcessBundle\Task\File\Yaml\YamlReaderTask
  • Code: yaml_reader (task: yaml_reader)
  • Iterable task

Accepted inputs

Input is ignored

Possible outputs

mixed: the value of each root element of the parsed file, one per iteration (keys are not output). Underlying method is Symfony Yaml::parseFile().

Options

Code Type Required Default Description
file_path string X Path of the YAML file to read. An UnexpectedValueException is thrown at initialization if the file does not exist (with process-bundle v5, the process fails when the task is first executed, see initializable tasks)

Examples

# Task configuration level
read_yaml:
  task: yaml_reader
  options:
    file_path: '%kernel.project_dir%/var/data/data.yaml'
  outputs: [process_item]

Notes

  • The root of the file must be a mapping or a sequence, otherwise an InvalidArgumentException is thrown (e.g. for an empty file). An empty root mapping or sequence ({} or []) produces no output: the task is skipped.
  • The current root key is added to the error context of the process as iterator_key.