Export/Exporter.php
private function generateFiles($languages, $chunkDir, array $options, OutputInterface $output)
    {
        $urls = array();

        $output->writeln(sprintf('Exporting %s content types', count($options['contentTypeIds'])));

        foreach ($options['contentTypeIds'] as $contentTypeId) {
            $contentTypeCurrentName = null;

            foreach ($languages as $lang) {
                $options['lang'] = $lang;

                $count = $this->countContentItemsByContentTypeId($contentTypeId, $options);

                $info = sprintf('Fetching %s items of contentTypeId %s (language: %s)', $count, $contentTypeId, $lang);
                $output->writeln($info);
                $this->logger->info($info);

                $contentTypeName = $this->contentTypeService->loadContentType($contentTypeId)->getName($lang);

                if ($contentTypeName !== null) {
                    $contentTypeCurrentName = $contentTypeName;
                }

                for ($i = 1; $i <= ceil($count / $options['pageSize']); ++$i) {
                    $filename = sprintf('%d_%s_%d', $contentTypeId, $lang, $i);
                    $chunkPath = $chunkDir . $filename;
                    $options['page'] = $i;

                    $output->writeln(sprintf(
                        'Fetching content from database for contentTypeId: %s, language: %s, chunk: #%s',
                        $contentTypeId,
                        $lang,
                        $i
                    ));

                    $contentItems = $this->getContentItems($contentTypeId, $options);
                    $parameters = new ParameterBag($options);

                    $output->writeln(sprintf(
                        'Preparing content for contentTypeId: %s, language: %s, amount: %s, chunk: #%s',
                        $contentTypeId,
                        $lang,
                        count($contentItems),
                        $i
                    ));

                    $content = $this->content->prepareContent(array($contentTypeId => $contentItems), $parameters, $output);

                    unset($contentItems);

                    $output->writeln(sprintf(
                        'Generating file for contentTypeId: %s, language: %s, chunk: #%s',
                        $contentTypeId,
                        $lang,
                        $i
                    ));

                    $this->generateFile($content, $chunkPath, $options);

                    unset($content);

                    $url = sprintf(
                        '%s/api/ezp/v2/ez_recommendation/v1/exportDownload/%s%s',
                        $options['host'], $chunkDir, $filename
                    );

                    $info = sprintf('Generating url: %s', $url);
                    $output->writeln($info);
                    $this->logger->info($info);

                    $urls[$contentTypeId][$lang]['urlList'][] = $url;
                    $urls[$contentTypeId][$lang]['contentTypeName'] = $contentTypeCurrentName;
                }
            }
        }

        return $urls;
    }
private function generateFiles($languages, $chunkDir, array $options, OutputInterface $output)
    {
        $urls = array();

        $output->writeln(sprintf('Exporting %s content types', count($options['contentTypeIds'])));

        foreach ($options['contentTypeIds'] as $contentTypeId) {
            $contentTypeCurrentName = null;

            foreach ($languages as $lang) {
                $options['lang'] = $lang;

                $count = $this->countContentItemsByContentTypeId($contentTypeId, $options);

                $info = sprintf('Fetching %s items of contentTypeId %s (language: %s)', $count, $contentTypeId, $lang);
                $output->writeln($info);
                $this->logger->info($info);

                $contentTypeName = $this->contentTypeService->loadContentType($contentTypeId)->getName($lang);

                if ($contentTypeName !== null) {
                    $contentTypeCurrentName = $contentTypeName;
                }

                for ($i = 1; $i <= ceil($count / $options['pageSize']); ++$i) {
                    $filename = sprintf('%d_%s_%d', $contentTypeId, $lang, $i);
                    $chunkPath = $chunkDir . $filename;
                    $options['page'] = $i;

                    $output->writeln(sprintf(
                        'Fetching content from database for contentTypeId: %s, language: %s, chunk: #%s',
                        $contentTypeId,
                        $lang,
                        $i
                    ));

                    $contentItems = $this->getContentItems($contentTypeId, $options);
                    $parameters = new ParameterBag($options);

                    $output->writeln(sprintf(
                        'Preparing content for contentTypeId: %s, language: %s, amount: %s, chunk: #%s',
                        $contentTypeId,
                        $lang,
                        count($contentItems),
                        $i
                    ));

                    $content = $this->content->prepareContent(array($contentTypeId => $contentItems), $parameters, $output);

                    unset($contentItems);

                    $output->writeln(sprintf(
                        'Generating file for contentTypeId: %s, language: %s, chunk: #%s',
                        $contentTypeId,
                        $lang,
                        $i
                    ));

                    $this->generateFile($content, $chunkPath, $options);

                    unset($content);

                    $url = sprintf(
                        '%s/api/ezp/v2/ez_recommendation/v1/exportDownload/%s%s',
                        $options['host'], $chunkDir, $filename
                    );

                    $info = sprintf('Generating url: %s', $url);
                    $output->writeln($info);
                    $this->logger->info($info);

                    $urls[$contentTypeId][$lang]['urlList'][] = $url;
                    $urls[$contentTypeId][$lang]['contentTypeName'] = $contentTypeCurrentName;
                }
            }
        }

        return $urls;
    }
private function generateFiles ( $ languages , $ chunkDir , array $ options , OutputInterface $ output ) { $ urls = array ( ) ; $ output -> writeln ( sprintf ( 'Exporting %s content types' , count ( $ options [ 'contentTypeIds' ] ) ) ) ; foreach ( $ options [ 'contentTypeIds' ] as $ contentTypeId ) { $ contentTypeCurrentName = null ; foreach ( $ languages as $ lang ) { $ options [ 'lang' ] = $ lang ; $ count = $ this -> countContentItemsByContentTypeId ( $ contentTypeId , $ options ) ; $ info = sprintf ( 'Fetching %s items of contentTypeId %s (language: %s)' , $ count , $ contentTypeId , $ lang ) ; $ output -> writeln ( $ info ) ; $ this -> logger -> info ( $ info ) ; $ contentTypeName = $ this -> contentTypeService -> loadContentType ( $ contentTypeId ) -> getName ( $ lang ) ; if ( $ contentTypeName !== null ) { $ contentTypeCurrentName = $ contentTypeName ; } for ( $ i = 1 ; $ i <= ceil ( $ count / $ options [ 'pageSize' ] ) ; ++ $ i ) { $ filename = sprintf ( '%d_%s_%d' , $ contentTypeId , $ lang , $ i ) ; $ chunkPath = $ chunkDir . $ filename ; $ options [ 'page' ] = $ i ; $ output -> writeln ( sprintf ( 'Fetching content from database for contentTypeId: %s, language: %s, chunk: #%s' , $ contentTypeId , $ lang , $ i ) ) ; $ contentItems = $ this -> getContentItems ( $ contentTypeId , $ options ) ; $ parameters = new ParameterBag ( $ options ) ; $ output -> writeln ( sprintf ( 'Preparing content for contentTypeId: %s, language: %s, amount: %s, chunk: #%s' , $ contentTypeId , $ lang , count ( $ contentItems ) , $ i ) ) ; $ content = $ this -> content -> prepareContent ( array ( $ contentTypeId => $ contentItems ) , $ parameters , $ output ) ; unset ( $ contentItems ) ; $ output -> writeln ( sprintf ( 'Generating file for contentTypeId: %s, language: %s, chunk: #%s' , $ contentTypeId , $ lang , $ i ) ) ; $ this -> generateFile ( $ content , $ chunkPath , $ options ) ; unset ( $ content ) ; $ url = sprintf ( '%s/api/ezp/v2/ez_recommendation/v1/exportDownload/%s%s' , $ options [ 'host' ] , $ chunkDir , $ filename ) ; $ info = sprintf ( 'Generating url: %s' , $ url ) ; $ output -> writeln ( $ info ) ; $ this -> logger -> info ( $ info ) ; $ urls [ $ contentTypeId ] [ $ lang ] [ 'urlList' ] [ ] = $ url ; $ urls [ $ contentTypeId ] [ $ lang ] [ 'contentTypeName' ] = $ contentTypeCurrentName ; } } } return $ urls ; }
Generate export files.

@param array $languages
@param string $chunkDir
@param array $options
@param OutputInterface $output

@return array
Generate export files .