Components/FileService/Csv/CsvConfigurableStepsProvider.php
protected function readLines(array &$stepActionParams, array &$endpointOptions, array &$context)
    {
        $stepParamsResolver = new OptionsResolver();
        $stepParamsResolver->setRequired([
            self::PARAM_CONTEXT_RESULT_NAME,
        ]);

        $stepParamsResolver->setDefault(self::PARAM_MAX_LINES, 1);
        $stepParamsResolver->setDefault(self::PARAM_FILE_NAME, null);
        $params = $stepParamsResolver->resolve($stepActionParams);

        $fullPath = $this->getRootPath($endpointOptions);
        if (null !== $params[self::PARAM_FILE_NAME]) {
            if (DIRECTORY_SEPARATOR !== substr($fullPath, -1)) {
                $fullPath .= DIRECTORY_SEPARATOR;
            }
            $fullPath .= $params[self::PARAM_FILE_NAME];
        }

        $fileHandle = $this->getFileHandle($fullPath, 'r');

        $contextResultName = $params[self::PARAM_CONTEXT_RESULT_NAME];
        $maxLines = $params[self::PARAM_MAX_LINES];
        $maxLineLength = $endpointOptions[CsvConfigurableProtocol::OPTION_MAX_LENGTH];

        $rows = [];

        $i = 0;
        while ($i < $maxLines) {
            $row = fgetcsv($fileHandle, $maxLineLength, $endpointOptions[CsvConfigurableProtocol::OPTION_DELIMITER]);

            if (false === $row) {
                break;
            }

            $rows[] = $row;
            ++$i;
        }

        if (0 === count($rows)) {
            throw new NoResultsException("No more results from $fullPath");
        }

        $context[self::KEY_RESULTS][$contextResultName] = $rows;
    }
protected function readLines(array &$stepActionParams, array &$endpointOptions, array &$context)
    {
        $stepParamsResolver = new OptionsResolver();
        $stepParamsResolver->setRequired([
            self::PARAM_CONTEXT_RESULT_NAME,
        ]);

        $stepParamsResolver->setDefault(self::PARAM_MAX_LINES, 1);
        $stepParamsResolver->setDefault(self::PARAM_FILE_NAME, null);
        $params = $stepParamsResolver->resolve($stepActionParams);

        $fullPath = $this->getRootPath($endpointOptions);
        if (null !== $params[self::PARAM_FILE_NAME]) {
            if (DIRECTORY_SEPARATOR !== substr($fullPath, -1)) {
                $fullPath .= DIRECTORY_SEPARATOR;
            }
            $fullPath .= $params[self::PARAM_FILE_NAME];
        }

        $fileHandle = $this->getFileHandle($fullPath, 'r');

        $contextResultName = $params[self::PARAM_CONTEXT_RESULT_NAME];
        $maxLines = $params[self::PARAM_MAX_LINES];
        $maxLineLength = $endpointOptions[CsvConfigurableProtocol::OPTION_MAX_LENGTH];

        $rows = [];

        $i = 0;
        while ($i < $maxLines) {
            $row = fgetcsv($fileHandle, $maxLineLength, $endpointOptions[CsvConfigurableProtocol::OPTION_DELIMITER]);

            if (false === $row) {
                break;
            }

            $rows[] = $row;
            ++$i;
        }

        if (0 === count($rows)) {
            throw new NoResultsException("No more results from $fullPath");
        }

        $context[self::KEY_RESULTS][$contextResultName] = $rows;
    }
protected function readLines ( array & $ stepActionParams , array & $ endpointOptions , array & $ context ) { $ stepParamsResolver = new OptionsResolver ( ) ; $ stepParamsResolver -> setRequired ( [ self :: PARAM_CONTEXT_RESULT_NAME , ] ) ; $ stepParamsResolver -> setDefault ( self :: PARAM_MAX_LINES , 1 ) ; $ stepParamsResolver -> setDefault ( self :: PARAM_FILE_NAME , null ) ; $ params = $ stepParamsResolver -> resolve ( $ stepActionParams ) ; $ fullPath = $ this -> getRootPath ( $ endpointOptions ) ; if ( null !== $ params [ self :: PARAM_FILE_NAME ] ) { if ( DIRECTORY_SEPARATOR !== substr ( $ fullPath , - 1 ) ) { $ fullPath .= DIRECTORY_SEPARATOR ; } $ fullPath .= $ params [ self :: PARAM_FILE_NAME ] ; } $ fileHandle = $ this -> getFileHandle ( $ fullPath , 'r' ) ; $ contextResultName = $ params [ self :: PARAM_CONTEXT_RESULT_NAME ] ; $ maxLines = $ params [ self :: PARAM_MAX_LINES ] ; $ maxLineLength = $ endpointOptions [ CsvConfigurableProtocol :: OPTION_MAX_LENGTH ] ; $ rows = [ ] ; $ i = 0 ; while ( $ i < $ maxLines ) { $ row = fgetcsv ( $ fileHandle , $ maxLineLength , $ endpointOptions [ CsvConfigurableProtocol :: OPTION_DELIMITER ] ) ; if ( false === $ row ) { break ; } $ rows [ ] = $ row ; ++ $ i ; } if ( 0 === count ( $ rows ) ) { throw new NoResultsException ( "No more results from $fullPath" ) ; } $ context [ self :: KEY_RESULTS ] [ $ contextResultName ] = $ rows ; }
Read a line from a csv file in to a context variable
it is assumed the file handle is in the context.

Required Params:
- CsvConfigurableProducer::PARAM_CONTEXT_RESULT_NAME
Optional Params:
- CsvConfigurableProducer::PARAM_MAX_LINES Defaults to 1

@param array $stepActionParams
@param array $endpointOptions
@param array $context

@throws NoResultsException if there are no more lines to consume
Read a line from a csv file in to a context variable it is assumed the file handle is in the context .