Skip to content

Latest commit

 

History

History
62 lines (48 loc) · 2.69 KB

File metadata and controls

62 lines (48 loc) · 2.69 KB

InputFolderBrowserTask

Browses a folder, whose path is given as input, recursively and iterates over each file found (sorted by name), outputting its path. Same behaviour as FolderBrowserTask, except for the folder path.

Task reference

  • Service: CleverAge\ProcessBundle\Task\File\InputFolderBrowserTask
  • Iterable task
  • Flushable task

Accepted inputs

string: path of the folder to browse, prefixed by the base_folder_path option. It must be an existing readable directory.

The folder path is released once its files have all been iterated, so each input (the same path again or a different one) is browsed from the start. Receiving a different folder path while an iteration is in progress throws a \LogicException, and an empty input (null, '') when no folder is being browsed throws an \UnexpectedValueException.

Possible outputs

string: path of the file (folder path followed by the path of the file relative to it). Underlying component is Symfony Finder.

If no file is found, a message is logged with the empty_log_level level, the task is skipped and the folder path is set as error output.

Options

Code Type Required Default Description
base_folder_path string '' Prepended to the input path, without adding any separator
name_pattern string|array|null null Restrict files by name using a pattern (glob, regexp or string) or an array of patterns (see Finder::name())
empty_log_level string warning Log level used when no file is found, one of the Psr\Log\LogLevel constants

The folder_path option of FolderBrowserTask is removed: the path comes from the input.

Examples

# Task configuration level
entry:
  service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
  options:
    output: '/var/data'
  outputs: [directory]
directory:
  service: '@CleverAge\ProcessBundle\Task\File\InputFolderBrowserTask'
  options:
    base_folder_path: '%kernel.project_dir%'
  outputs: [read]
read:
  service: '@CleverAge\ProcessBundle\Task\File\InputFileReaderTask'