Components/FileService/Csv/CsvConfigurableStepsProvider.php
protected function appendLines(array &$stepActionParams, array &$endpointOptions, array &$context)
    {
        $stepParamsResolver = new OptionsResolver();
        $stepParamsResolver->setRequired([
            self::PARAM_CSV_ROWS,
        ]);
        $stepParamsResolver->setDefault(self::PARAM_FILE_NAME, $endpointOptions[CsvConfigurableProtocol::OPTION_PATH]);
        $stepParamsResolver->setDefault(self::PARAM_HEADERS, null);
        $params = $stepParamsResolver->resolve($stepActionParams);

        $filePath = $params[self::PARAM_FILE_NAME];
        $fullPath = $this->getRootPath($endpointOptions).DIRECTORY_SEPARATOR.$filePath;

        $rows = $params[self::PARAM_CSV_ROWS];

        $headers = $params[self::PARAM_HEADERS];
        if (is_array($headers) && !file_exists($fullPath)) {
            $rows = array_merge([$headers], $rows);
        }

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

        foreach ($rows as $row) {
            if (!is_array($row)) {
                $type = gettype($row);
                throw new \InvalidArgumentException("Row in Rows is not an array, {$type} given.");
            }

            fputcsv($fileHandle, $row, $endpointOptions[CsvConfigurableProtocol::OPTION_DELIMITER], $endpointOptions[CsvConfigurableProtocol::OPTION_ENCLOSURE], $endpointOptions[CsvConfigurableProtocol::OPTION_ESCAPE_CHAR]);
        }
    }
protected function appendLines(array &$stepActionParams, array &$endpointOptions, array &$context)
    {
        $stepParamsResolver = new OptionsResolver();
        $stepParamsResolver->setRequired([
            self::PARAM_CSV_ROWS,
        ]);
        $stepParamsResolver->setDefault(self::PARAM_FILE_NAME, $endpointOptions[CsvConfigurableProtocol::OPTION_PATH]);
        $stepParamsResolver->setDefault(self::PARAM_HEADERS, null);
        $params = $stepParamsResolver->resolve($stepActionParams);

        $filePath = $params[self::PARAM_FILE_NAME];
        $fullPath = $this->getRootPath($endpointOptions).DIRECTORY_SEPARATOR.$filePath;

        $rows = $params[self::PARAM_CSV_ROWS];

        $headers = $params[self::PARAM_HEADERS];
        if (is_array($headers) && !file_exists($fullPath)) {
            $rows = array_merge([$headers], $rows);
        }

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

        foreach ($rows as $row) {
            if (!is_array($row)) {
                $type = gettype($row);
                throw new \InvalidArgumentException("Row in Rows is not an array, {$type} given.");
            }

            fputcsv($fileHandle, $row, $endpointOptions[CsvConfigurableProtocol::OPTION_DELIMITER], $endpointOptions[CsvConfigurableProtocol::OPTION_ENCLOSURE], $endpointOptions[CsvConfigurableProtocol::OPTION_ESCAPE_CHAR]);
        }
    }
protected function appendLines ( array & $ stepActionParams , array & $ endpointOptions , array & $ context ) { $ stepParamsResolver = new OptionsResolver ( ) ; $ stepParamsResolver -> setRequired ( [ self :: PARAM_CSV_ROWS , ] ) ; $ stepParamsResolver -> setDefault ( self :: PARAM_FILE_NAME , $ endpointOptions [ CsvConfigurableProtocol :: OPTION_PATH ] ) ; $ stepParamsResolver -> setDefault ( self :: PARAM_HEADERS , null ) ; $ params = $ stepParamsResolver -> resolve ( $ stepActionParams ) ; $ filePath = $ params [ self :: PARAM_FILE_NAME ] ; $ fullPath = $ this -> getRootPath ( $ endpointOptions ) . DIRECTORY_SEPARATOR . $ filePath ; $ rows = $ params [ self :: PARAM_CSV_ROWS ] ; $ headers = $ params [ self :: PARAM_HEADERS ] ; if ( is_array ( $ headers ) && ! file_exists ( $ fullPath ) ) { $ rows = array_merge ( [ $ headers ] , $ rows ) ; } $ fileHandle = $ this -> getFileHandle ( $ fullPath , 'a' ) ; foreach ( $ rows as $ row ) { if ( ! is_array ( $ row ) ) { $ type = gettype ( $ row ) ; throw new \ InvalidArgumentException ( "Row in Rows is not an array, {$type} given." ) ; } fputcsv ( $ fileHandle , $ row , $ endpointOptions [ CsvConfigurableProtocol :: OPTION_DELIMITER ] , $ endpointOptions [ CsvConfigurableProtocol :: OPTION_ENCLOSURE ] , $ endpointOptions [ CsvConfigurableProtocol :: OPTION_ESCAPE_CHAR ] ) ; } }
Write an array of lines to a csv file in to a context variable
it is assumed the file handle is in the context.

Required Params:
- CsvConfigurableProducer::PARAM_CSV_ROWS

@param array $stepActionParams
@param array $endpointOptions
@param array $context
Write an array of lines to a csv file in to a context variable it is assumed the file handle is in the context .