private function loadLocationsFrom(
        $countryCode,
        $pathname
    ) {
        $countryInfo = $this->getCountryInfo($countryCode);
        $country = $this
            ->locationBuilder
            ->addLocation(
                $countryInfo[0],
                $countryInfo[1],
                $countryInfo[0],
                'country'
            );

        $interpreter = new Interpreter();
        $interpreter->unstrict();
        $nbItems = 0;
        $interpreter->addObserver(function (array $columns) use ($country, &$nbItems) {

            if (
            isset(
                $columns[1],
                $columns[2],
                $columns[3],
                $columns[4],
                $columns[5],
                $columns[6]
            )
            ) {
                ++$nbItems;
                $stateId = $this->normalizeId($columns[4]);
                $state = $this
                    ->locationBuilder
                    ->addLocation(
                        $country->getId() . '_' . $stateId,
                        $columns[3],
                        $stateId,
                        'state',
                        $country
                    );

                $provinceId = $this->normalizeId($columns[6]);
                $province = $this
                    ->locationBuilder
                    ->addLocation(
                        $state->getId() . '_' . $provinceId,
                        $columns[5],
                        $provinceId,
                        'province',
                        $state
                    );

                $cityId = $this->normalizeId($columns[2]);
                $city = $this
                    ->locationBuilder
                    ->addLocation(
                        $province->getId() . '_' . $cityId,
                        $columns[2],
                        $cityId,
                        'city',
                        $province
                    );

                $postalCodeId = $this->normalizeId($columns[1]);
                $this
                    ->locationBuilder
                    ->addLocation(
                        $city->getId() . '_' . $postalCodeId,
                        $columns[1],
                        $postalCodeId,
                        'postalcode',
                        $city
                    );
            }
        });

        $config = new LexerConfig();
        $config->setDelimiter("\t");
        $lexer = new Lexer($config);
        $lexer->parse($pathname, $interpreter);

        return $country;
    }
private function loadLocationsFrom(
        $countryCode,
        $pathname
    ) {
        $countryInfo = $this->getCountryInfo($countryCode);
        $country = $this
            ->locationBuilder
            ->addLocation(
                $countryInfo[0],
                $countryInfo[1],
                $countryInfo[0],
                'country'
            );

        $interpreter = new Interpreter();
        $interpreter->unstrict();
        $nbItems = 0;
        $interpreter->addObserver(function (array $columns) use ($country, &$nbItems) {

            if (
            isset(
                $columns[1],
                $columns[2],
                $columns[3],
                $columns[4],
                $columns[5],
                $columns[6]
            )
            ) {
                ++$nbItems;
                $stateId = $this->normalizeId($columns[4]);
                $state = $this
                    ->locationBuilder
                    ->addLocation(
                        $country->getId() . '_' . $stateId,
                        $columns[3],
                        $stateId,
                        'state',
                        $country
                    );

                $provinceId = $this->normalizeId($columns[6]);
                $province = $this
                    ->locationBuilder
                    ->addLocation(
                        $state->getId() . '_' . $provinceId,
                        $columns[5],
                        $provinceId,
                        'province',
                        $state
                    );

                $cityId = $this->normalizeId($columns[2]);
                $city = $this
                    ->locationBuilder
                    ->addLocation(
                        $province->getId() . '_' . $cityId,
                        $columns[2],
                        $cityId,
                        'city',
                        $province
                    );

                $postalCodeId = $this->normalizeId($columns[1]);
                $this
                    ->locationBuilder
                    ->addLocation(
                        $city->getId() . '_' . $postalCodeId,
                        $columns[1],
                        $postalCodeId,
                        'postalcode',
                        $city
                    );
            }
        });

        $config = new LexerConfig();
        $config->setDelimiter("\t");
        $lexer = new Lexer($config);
        $lexer->parse($pathname, $interpreter);

        return $country;
    }
private function loadLocationsFrom ( $ countryCode , $ pathname ) { $ countryInfo = $ this -> getCountryInfo ( $ countryCode ) ; $ country = $ this -> locationBuilder -> addLocation ( $ countryInfo [ 0 ] , $ countryInfo [ 1 ] , $ countryInfo [ 0 ] , 'country' ) ; $ interpreter = new Interpreter ( ) ; $ interpreter -> unstrict ( ) ; $ nbItems = 0 ; $ interpreter -> addObserver ( function ( array $ columns ) use ( $ country , & $ nbItems ) { if ( isset ( $ columns [ 1 ] , $ columns [ 2 ] , $ columns [ 3 ] , $ columns [ 4 ] , $ columns [ 5 ] , $ columns [ 6 ] ) ) { ++ $ nbItems ; $ stateId = $ this -> normalizeId ( $ columns [ 4 ] ) ; $ state = $ this -> locationBuilder -> addLocation ( $ country -> getId ( ) . '_' . $ stateId , $ columns [ 3 ] , $ stateId , 'state' , $ country ) ; $ provinceId = $ this -> normalizeId ( $ columns [ 6 ] ) ; $ province = $ this -> locationBuilder -> addLocation ( $ state -> getId ( ) . '_' . $ provinceId , $ columns [ 5 ] , $ provinceId , 'province' , $ state ) ; $ cityId = $ this -> normalizeId ( $ columns [ 2 ] ) ; $ city = $ this -> locationBuilder -> addLocation ( $ province -> getId ( ) . '_' . $ cityId , $ columns [ 2 ] , $ cityId , 'city' , $ province ) ; $ postalCodeId = $ this -> normalizeId ( $ columns [ 1 ] ) ; $ this -> locationBuilder -> addLocation ( $ city -> getId ( ) . '_' . $ postalCodeId , $ columns [ 1 ] , $ postalCodeId , 'postalcode' , $ city ) ; } } ) ; $ config = new LexerConfig ( ) ; $ config -> setDelimiter ( "\t" ) ; $ lexer = new Lexer ( $ config ) ; $ lexer -> parse ( $ pathname , $ interpreter ) ; return $ country ; }
Extract data from de CSV and create new Location objects.

@param string $countryCode Country code
@param string $pathname    Pathname

@return LocationInterface Root location
Extract data from de CSV and create new Location objects .