protected function exportDataTablesCallback(DataTablesProviderInterface $dtProvider, DataTablesRepositoryInterface $repository, DataTablesCSVExporterInterface $dtExporter, $windows) {

        $em = $this->getDoctrine()->getManager();

        $stream = fopen("php://output", "w+");

        // Export the columns.
        fputcsv($stream, DataTablesExportHelper::convert($dtExporter->exportColumns(), $windows), ";");

        // Paginates.
        $total = $repository->dataTablesCountExported($dtProvider);
        $pages = PaginateHelper::getPagesCount($total, DataTablesRepositoryInterface::REPOSITORY_LIMIT);

        // Handle each page.
        for ($i = 0; $i < $pages; ++$i) {

            // Get the offset and limit.
            list($offset, $limit) = PaginateHelper::getPageOffsetAndLimit($i, DataTablesRepositoryInterface::REPOSITORY_LIMIT, $total);

            // Get the export query with offset and limit.
            $result = $repository->dataTablesExportAll($dtProvider)
                ->setFirstResult($offset)
                ->setMaxResults($limit)
                ->getQuery()
                ->iterate();

            while (false !== ($row = $result->next())) {

                $this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_PRE_EXPORT, [$row[0]]);

                fputcsv($stream, DataTablesExportHelper::convert($dtExporter->exportRow($row[0]), $windows), ";");

                // Detach the entity to avoid memory consumption.
                $em->detach($row[0]);

                $this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_POST_EXPORT, [$row[0]]);
            }
        }

        // Close the file.
        fclose($stream);
    }
protected function exportDataTablesCallback(DataTablesProviderInterface $dtProvider, DataTablesRepositoryInterface $repository, DataTablesCSVExporterInterface $dtExporter, $windows) {

        $em = $this->getDoctrine()->getManager();

        $stream = fopen("php://output", "w+");

        // Export the columns.
        fputcsv($stream, DataTablesExportHelper::convert($dtExporter->exportColumns(), $windows), ";");

        // Paginates.
        $total = $repository->dataTablesCountExported($dtProvider);
        $pages = PaginateHelper::getPagesCount($total, DataTablesRepositoryInterface::REPOSITORY_LIMIT);

        // Handle each page.
        for ($i = 0; $i < $pages; ++$i) {

            // Get the offset and limit.
            list($offset, $limit) = PaginateHelper::getPageOffsetAndLimit($i, DataTablesRepositoryInterface::REPOSITORY_LIMIT, $total);

            // Get the export query with offset and limit.
            $result = $repository->dataTablesExportAll($dtProvider)
                ->setFirstResult($offset)
                ->setMaxResults($limit)
                ->getQuery()
                ->iterate();

            while (false !== ($row = $result->next())) {

                $this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_PRE_EXPORT, [$row[0]]);

                fputcsv($stream, DataTablesExportHelper::convert($dtExporter->exportRow($row[0]), $windows), ";");

                // Detach the entity to avoid memory consumption.
                $em->detach($row[0]);

                $this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_POST_EXPORT, [$row[0]]);
            }
        }

        // Close the file.
        fclose($stream);
    }
protected function exportDataTablesCallback ( DataTablesProviderInterface $ dtProvider , DataTablesRepositoryInterface $ repository , DataTablesCSVExporterInterface $ dtExporter , $ windows ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ stream = fopen ( "php://output" , "w+" ) ; // Export the columns. fputcsv ( $ stream , DataTablesExportHelper :: convert ( $ dtExporter -> exportColumns ( ) , $ windows ) , ";" ) ; // Paginates. $ total = $ repository -> dataTablesCountExported ( $ dtProvider ) ; $ pages = PaginateHelper :: getPagesCount ( $ total , DataTablesRepositoryInterface :: REPOSITORY_LIMIT ) ; // Handle each page. for ( $ i = 0 ; $ i < $ pages ; ++ $ i ) { // Get the offset and limit. list ( $ offset , $ limit ) = PaginateHelper :: getPageOffsetAndLimit ( $ i , DataTablesRepositoryInterface :: REPOSITORY_LIMIT , $ total ) ; // Get the export query with offset and limit. $ result = $ repository -> dataTablesExportAll ( $ dtProvider ) -> setFirstResult ( $ offset ) -> setMaxResults ( $ limit ) -> getQuery ( ) -> iterate ( ) ; while ( false !== ( $ row = $ result -> next ( ) ) ) { $ this -> dispatchDataTablesEvent ( DataTablesEvents :: DATATABLES_PRE_EXPORT , [ $ row [ 0 ] ] ) ; fputcsv ( $ stream , DataTablesExportHelper :: convert ( $ dtExporter -> exportRow ( $ row [ 0 ] ) , $ windows ) , ";" ) ; // Detach the entity to avoid memory consumption. $ em -> detach ( $ row [ 0 ] ) ; $ this -> dispatchDataTablesEvent ( DataTablesEvents :: DATATABLES_POST_EXPORT , [ $ row [ 0 ] ] ) ; } } // Close the file. fclose ( $ stream ) ; }
Export callback.

@param DataTablesProviderInterface $dtProvider The provider.
@param DataTablesRepositoryInterface $repository The repository.
@param DataTablesCSVExporterInterface $dtExporter The exporter.
@param bool $windows Windows ?
@return void
Export callback .