concrete/src/Csv/Import/AbstractImporter.php
protected function processData(ImportResult $importResult, $dataRowsToSkip, $maxDataRows, $collectData = false)
    {
        if ($collectData !== false) {
            $dataCollected = [
                'attributeKeys' => [],
                'attributeControllers' => [],
                'data' => [],
            ];
        } else {
            $dataCollected = null;
        }
        if ($this->csvSchema === null) {
            $importResult->getErrors()->add(t('The CSV schema has not been read.'));
        } else {
            if ($dataCollected !== null) {
                $attributeKeysAndControllers = $this->getAttributeKeysAndControllers();
                foreach ($attributeKeysAndControllers as $attributeIndex => list($attributeKey, $attributeController)) {
                    $dataCollected['attributeKeys'][$attributeIndex] = $attributeKey;
                    $dataCollected['attributeControllers'][$attributeIndex] = $attributeController;
                }
            }
            if ($maxDataRows !== null) {
                $maxDataRows = (int) $maxDataRows;
            }
            if ($maxDataRows === null || $maxDataRows > 0) {
                $dataRowsToSkip = (int) $dataRowsToSkip;
                $this->reader->setOffset(1 + ($dataRowsToSkip > 0 ? $dataRowsToSkip : 0));
                $this->reader->each(function ($cells, $rowIndex) use ($importResult, $maxDataRows, &$dataCollected, $collectData) {
                    $importResult->countRowProcessed($rowIndex);
                    $staticValues = $this->csvSchema->getStaticValues($cells);
                    try {
                        $object = $this->getObjectWithStaticValues($staticValues);
                    } catch (UserMessageException $x) {
                        $importResult->addLineProblem(true, $x->getMessage());
                        $object = null;
                    }
                    if ($object !== null) {
                        $attributesValues = $this->csvSchema->getAttributesValues($cells);
                        $attributesValueObjects = $this->assignCsvAttributes($object, $attributesValues, $importResult);
                        $importResult->increaseImportSuccessCount();
                        if ($dataCollected !== null) {
                            if ($collectData === true || count($dataCollected['data']) < $collectData) {
                                $dataCollected['data'][] = [
                                    'object' => $object,
                                    'attributeValues' => $attributesValueObjects,
                                ];
                            }
                        }
                    }

                    return $maxDataRows === null || $importResult->getTotalDataRowsProcessed() < $maxDataRows;
                });
            }
        }
        if ($dataCollected !== null) {
            $importResult->setDataCollected($dataCollected);
        }
    }
protected function processData(ImportResult $importResult, $dataRowsToSkip, $maxDataRows, $collectData = false)
    {
        if ($collectData !== false) {
            $dataCollected = [
                'attributeKeys' => [],
                'attributeControllers' => [],
                'data' => [],
            ];
        } else {
            $dataCollected = null;
        }
        if ($this->csvSchema === null) {
            $importResult->getErrors()->add(t('The CSV schema has not been read.'));
        } else {
            if ($dataCollected !== null) {
                $attributeKeysAndControllers = $this->getAttributeKeysAndControllers();
                foreach ($attributeKeysAndControllers as $attributeIndex => list($attributeKey, $attributeController)) {
                    $dataCollected['attributeKeys'][$attributeIndex] = $attributeKey;
                    $dataCollected['attributeControllers'][$attributeIndex] = $attributeController;
                }
            }
            if ($maxDataRows !== null) {
                $maxDataRows = (int) $maxDataRows;
            }
            if ($maxDataRows === null || $maxDataRows > 0) {
                $dataRowsToSkip = (int) $dataRowsToSkip;
                $this->reader->setOffset(1 + ($dataRowsToSkip > 0 ? $dataRowsToSkip : 0));
                $this->reader->each(function ($cells, $rowIndex) use ($importResult, $maxDataRows, &$dataCollected, $collectData) {
                    $importResult->countRowProcessed($rowIndex);
                    $staticValues = $this->csvSchema->getStaticValues($cells);
                    try {
                        $object = $this->getObjectWithStaticValues($staticValues);
                    } catch (UserMessageException $x) {
                        $importResult->addLineProblem(true, $x->getMessage());
                        $object = null;
                    }
                    if ($object !== null) {
                        $attributesValues = $this->csvSchema->getAttributesValues($cells);
                        $attributesValueObjects = $this->assignCsvAttributes($object, $attributesValues, $importResult);
                        $importResult->increaseImportSuccessCount();
                        if ($dataCollected !== null) {
                            if ($collectData === true || count($dataCollected['data']) < $collectData) {
                                $dataCollected['data'][] = [
                                    'object' => $object,
                                    'attributeValues' => $attributesValueObjects,
                                ];
                            }
                        }
                    }

                    return $maxDataRows === null || $importResult->getTotalDataRowsProcessed() < $maxDataRows;
                });
            }
        }
        if ($dataCollected !== null) {
            $importResult->setDataCollected($dataCollected);
        }
    }
protected function processData ( ImportResult $ importResult , $ dataRowsToSkip , $ maxDataRows , $ collectData = false ) { if ( $ collectData !== false ) { $ dataCollected = [ 'attributeKeys' => [ ] , 'attributeControllers' => [ ] , 'data' => [ ] , ] ; } else { $ dataCollected = null ; } if ( $ this -> csvSchema === null ) { $ importResult -> getErrors ( ) -> add ( t ( 'The CSV schema has not been read.' ) ) ; } else { if ( $ dataCollected !== null ) { $ attributeKeysAndControllers = $ this -> getAttributeKeysAndControllers ( ) ; foreach ( $ attributeKeysAndControllers as $ attributeIndex => list ( $ attributeKey , $ attributeController ) ) { $ dataCollected [ 'attributeKeys' ] [ $ attributeIndex ] = $ attributeKey ; $ dataCollected [ 'attributeControllers' ] [ $ attributeIndex ] = $ attributeController ; } } if ( $ maxDataRows !== null ) { $ maxDataRows = ( int ) $ maxDataRows ; } if ( $ maxDataRows === null || $ maxDataRows > 0 ) { $ dataRowsToSkip = ( int ) $ dataRowsToSkip ; $ this -> reader -> setOffset ( 1 + ( $ dataRowsToSkip > 0 ? $ dataRowsToSkip : 0 ) ) ; $ this -> reader -> each ( function ( $ cells , $ rowIndex ) use ( $ importResult , $ maxDataRows , & $ dataCollected , $ collectData ) { $ importResult -> countRowProcessed ( $ rowIndex ) ; $ staticValues = $ this -> csvSchema -> getStaticValues ( $ cells ) ; try { $ object = $ this -> getObjectWithStaticValues ( $ staticValues ) ; } catch ( UserMessageException $ x ) { $ importResult -> addLineProblem ( true , $ x -> getMessage ( ) ) ; $ object = null ; } if ( $ object !== null ) { $ attributesValues = $ this -> csvSchema -> getAttributesValues ( $ cells ) ; $ attributesValueObjects = $ this -> assignCsvAttributes ( $ object , $ attributesValues , $ importResult ) ; $ importResult -> increaseImportSuccessCount ( ) ; if ( $ dataCollected !== null ) { if ( $ collectData === true || count ( $ dataCollected [ 'data' ] ) < $ collectData ) { $ dataCollected [ 'data' ] [ ] = [ 'object' => $ object , 'attributeValues' => $ attributesValueObjects , ] ; } } } return $ maxDataRows === null || $ importResult -> getTotalDataRowsProcessed ( ) < $ maxDataRows ; } ) ; } } if ( $ dataCollected !== null ) { $ importResult -> setDataCollected ( $ dataCollected ) ; } }
Read the data rows and process them.

@param ImportResult $importResult
@param int $dataRowsToSkip the number of data rows to be skipped
@param int|null $maxDataRows the maximum number of data rows to be processed
@param bool|int $collectData Set to false to not collect the imported data, to true to collect the all the imported data, or a number to limit the data to collect

@return null|array If $collectData is set to true, the result will be an array with the keys:
- attributeKeys: the list of attribute keys (\Concrete\Core\Attribute\AttributeKeyInterface[])
- attributeControllers: the list of attribute key controllers (\Concrete\Core\Attribute\Controller[])
- data: a list of array, whose keys are:
- object: the object associated to the CSV data row (\Concrete\Core\Attribute\ObjectInterface)
- attributeValues: the list of attribute values (array[\Concrete\Core\Entity\Attribute\Value\AbstractValue|null])
Read the data rows and process them .