concrete/src/Csv/Import/AbstractImporter.php
protected function processHeader(ImportResult $importResult)
    {
        $result = false;
        $this->csvSchema = null;
        $csvSchema = null;
        $this->reader->each(function ($headerCells, $rowIndex) use (&$csvSchema) {
            $csvSchema = new CsvSchema($rowIndex, $headerCells, $this->getStaticHeaders(), $this->getAttributesMap());

            return false;
        });
        if ($csvSchema === null) {
            $importResult->getErrors()->add(t("There's no row in the CSV."));
        } elseif (!$csvSchema->someHeaderRecognized()) {
            $importResult->addLineProblem(true, t('None of the CSV columns have been recognized.'), $csvSchema->getRowIndex());
        } else {
            $unrecognizedHeaders = $csvSchema->getUnrecognizedHeaders();
            if (count($unrecognizedHeaders) > 0) {
                $importResult->addLineProblem(false, t('Unrecognized CSV headers: %s', Misc::join($unrecognizedHeaders)), $csvSchema->getRowIndex());
            }
            $missingHeaders = $csvSchema->getMissingHeaders();
            if (count($missingHeaders) > 0) {
                $importResult->addLineProblem(false, t('Missing CSV headers: %s', Misc::join($missingHeaders)), $csvSchema->getRowIndex());
            }
            $this->csvSchema = $csvSchema;
            $result = true;
        }

        return $result;
    }
protected function processHeader(ImportResult $importResult)
    {
        $result = false;
        $this->csvSchema = null;
        $csvSchema = null;
        $this->reader->each(function ($headerCells, $rowIndex) use (&$csvSchema) {
            $csvSchema = new CsvSchema($rowIndex, $headerCells, $this->getStaticHeaders(), $this->getAttributesMap());

            return false;
        });
        if ($csvSchema === null) {
            $importResult->getErrors()->add(t("There's no row in the CSV."));
        } elseif (!$csvSchema->someHeaderRecognized()) {
            $importResult->addLineProblem(true, t('None of the CSV columns have been recognized.'), $csvSchema->getRowIndex());
        } else {
            $unrecognizedHeaders = $csvSchema->getUnrecognizedHeaders();
            if (count($unrecognizedHeaders) > 0) {
                $importResult->addLineProblem(false, t('Unrecognized CSV headers: %s', Misc::join($unrecognizedHeaders)), $csvSchema->getRowIndex());
            }
            $missingHeaders = $csvSchema->getMissingHeaders();
            if (count($missingHeaders) > 0) {
                $importResult->addLineProblem(false, t('Missing CSV headers: %s', Misc::join($missingHeaders)), $csvSchema->getRowIndex());
            }
            $this->csvSchema = $csvSchema;
            $result = true;
        }

        return $result;
    }
protected function processHeader ( ImportResult $ importResult ) { $ result = false ; $ this -> csvSchema = null ; $ csvSchema = null ; $ this -> reader -> each ( function ( $ headerCells , $ rowIndex ) use ( & $ csvSchema ) { $ csvSchema = new CsvSchema ( $ rowIndex , $ headerCells , $ this -> getStaticHeaders ( ) , $ this -> getAttributesMap ( ) ) ; return false ; } ) ; if ( $ csvSchema === null ) { $ importResult -> getErrors ( ) -> add ( t ( "There's no row in the CSV." ) ) ; } elseif ( ! $ csvSchema -> someHeaderRecognized ( ) ) { $ importResult -> addLineProblem ( true , t ( 'None of the CSV columns have been recognized.' ) , $ csvSchema -> getRowIndex ( ) ) ; } else { $ unrecognizedHeaders = $ csvSchema -> getUnrecognizedHeaders ( ) ; if ( count ( $ unrecognizedHeaders ) > 0 ) { $ importResult -> addLineProblem ( false , t ( 'Unrecognized CSV headers: %s' , Misc :: join ( $ unrecognizedHeaders ) ) , $ csvSchema -> getRowIndex ( ) ) ; } $ missingHeaders = $ csvSchema -> getMissingHeaders ( ) ; if ( count ( $ missingHeaders ) > 0 ) { $ importResult -> addLineProblem ( false , t ( 'Missing CSV headers: %s' , Misc :: join ( $ missingHeaders ) ) , $ csvSchema -> getRowIndex ( ) ) ; } $ this -> csvSchema = $ csvSchema ; $ result = true ; } return $ result ; }
Read the header row and initialize the CSV schema.

@param ImportResult $importResult

@return bool returns true in case of success, false in case of failures (see the getErrors() method of the result)
Read the header row and initialize the CSV schema .