-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add server side export * Add missing dev dependency * Replace pseudo-type "iterable" by "\Traversable" To support PHP 7.0 * Replace TranslatorInterface by DataCollectorTranslator To maintain BC, it is not possible to type hint with the TranslatorInterface as older versions of Symfony inject "Symfony\Component\Translation\TranslatorInterface" while newer versions of Symfony inject "Symfony\Contracts\Translation\TranslatorInterface". * Fix ArgumentCountError (Symfony ^3.4) * Fix Content Disposition header format * Do not display the export form * Excel: render HTML in cells The 'render' column option is usually use to inject HTML. * Fix Translator injection Tests were passing using "Symfony\Component\Translation\DataCollectorTranslator" as type-hint but Symfony may inject "Symfony\Bundle\FrameworkBundle\Translation\Translator". * Use a Generator instead of a new Iterator * Using a Generator makes the code more readable. * Avoid creating an array (iterator_to_array) may be sligtly faster? * Add functional test "testEmptyDataTable" * Fix tests * Preserve DataTableState Export the entire table but keep current sort and filtering * Automatically tag exporters * Add CSV exporter * Add missing "_dt" * Fix "DT_RowId" check * Make dependency on contracts explicit Will not fix #122 but should prevent similar issues. * Symfony 3 is not supported, according to the readme.md (#123) * Symfony 3 is not supported, according to the readme.md Symfony 3 is not supported, according to the readme.md. This updates the documentation to reflect that only Symfony 4.1+ is supported by this bundle * Update index.html.md * Option for custom datetime format for creating object (#127) * Fix failing test by reverting custom WebClient handling Alternative to #125 * Fix deprecations helper crashing old Symfony versions * Drop bad testing method on old Symfony frameworks This is actually obsolete since Symfony Flex, as you can now run Symfony 4.1 with more recent components. * Apply code style * Use weak deprecation testing * Prepare 0.4.1 * Fix deprecations (#129) * removed unused symfony/templating * set lowest version of persistence to 1.3.4 * added missing SymfonyTestListener * raise minimum version of doctrine/orm to 2.6.3 * set phpunit schema location to installed package * Update translations with script (#130) * script for updating translation messages from datatables language files * added czech and slovak languages * en rebuilt by script * add missing closing bracket for example (#131) * Integrate translation update script * Update README.md * Restructure tests to improve readability * Bump nokogiri from 1.10.7 to 1.10.8 in /docs (#133) Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.10.7 to 1.10.8. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/master/CHANGELOG.md) - [Commits](sparklemotion/nokogiri@v1.10.7...v1.10.8) Signed-off-by: dependabot[bot] <support@github.com> * Test local translations (#139) * Upgrade to PHPUnit 8/9 * Update Scrutinizer config * Force use outdated version of ocramius/package-versions Breaks both SymfonyInsight and Scrutinizer otherwise. * Fix SymfonyInsight badge * Fix SymfonyInsight badge for real * Javascript improvements (#145) * JS improvements * Remove scrollX * Allow config.options and config.url as functions * Remove empty line * Fix export issue when using GET method * Add server side export * Add missing dev dependency * Replace pseudo-type "iterable" by "\Traversable" To support PHP 7.0 * Replace TranslatorInterface by DataCollectorTranslator To maintain BC, it is not possible to type hint with the TranslatorInterface as older versions of Symfony inject "Symfony\Component\Translation\TranslatorInterface" while newer versions of Symfony inject "Symfony\Contracts\Translation\TranslatorInterface". * Fix ArgumentCountError (Symfony ^3.4) * Fix Content Disposition header format * Do not display the export form * Excel: render HTML in cells The 'render' column option is usually use to inject HTML. * Fix Translator injection Tests were passing using "Symfony\Component\Translation\DataCollectorTranslator" as type-hint but Symfony may inject "Symfony\Bundle\FrameworkBundle\Translation\Translator". * Use a Generator instead of a new Iterator * Using a Generator makes the code more readable. * Avoid creating an array (iterator_to_array) may be sligtly faster? * Add functional test "testEmptyDataTable" * Fix tests * Preserve DataTableState Export the entire table but keep current sort and filtering * Automatically tag exporters * Add CSV exporter * Add missing "_dt" * Fix "DT_RowId" check * Fix export issue when using GET method * Fix tests Co-authored-by: Niels Keurentjes <niels.keurentjes@omines.com> Co-authored-by: Spyros Sakellaropoulos <spyridonas@users.noreply.github.com> Co-authored-by: freezy <freezy-sk@users.noreply.github.com> Co-authored-by: rwkt <37826694+rwkt@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Daniel Gorgan <danut007ro@gmail.com>
- Loading branch information
1 parent
6da1572
commit f3a35b3
Showing
32 changed files
with
1,192 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/composer.lock | ||
/tmp | ||
/vendor | ||
/tests/Fixtures/var/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
* Symfony DataTables Bundle | ||
* (c) Omines Internetbureau B.V. - https://omines.nl/ | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omines\DataTablesBundle\Exception; | ||
|
||
use Omines\DataTablesBundle\Exporter\DataTableExporterInterface; | ||
|
||
/** | ||
* Thrown when a DataTable exporter cannot be found. | ||
* | ||
* @author Maxime Pinot <contact@maximepinot.com> | ||
*/ | ||
class UnknownDataTableExporterException extends \Exception | ||
{ | ||
/** | ||
* UnknownDataTableExporterException constructor. | ||
* | ||
* @param string $name The name of the DataTable exporter that cannot be found | ||
* @param \Traversable $referencedExporters Available DataTable exporters | ||
*/ | ||
public function __construct(string $name, \Traversable $referencedExporters) | ||
{ | ||
$format = <<<EOF | ||
Cannot find a DataTable exporter named "%s". | ||
Did you forget to tag the exporter with 'datatables.exporter'? | ||
Referenced DataTable exporters are : %s. | ||
EOF; | ||
|
||
parent::__construct(sprintf($format, $name, $this->formatReferencedExporters($referencedExporters))); | ||
} | ||
|
||
private function formatReferencedExporters(\Traversable $referencedExporters): string | ||
{ | ||
$names = []; | ||
|
||
/** @var DataTableExporterInterface $exporter */ | ||
foreach ($referencedExporters as $exporter) { | ||
$names[] = sprintf('"%s"', $exporter->getName()); | ||
} | ||
|
||
return implode(', ', $names); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omines\DataTablesBundle\Exporter\Csv; | ||
|
||
use Omines\DataTablesBundle\Exporter\DataTableExporterInterface; | ||
|
||
/** | ||
* Exports DataTable data to a CSV file. | ||
* | ||
* @author Maxime Pinot <maxime.pinot@gbh.fr> | ||
*/ | ||
class CsvExporter implements DataTableExporterInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function export(array $columnNames, \Iterator $data): \SplFileInfo | ||
{ | ||
$filePath = sys_get_temp_dir() . '/' . uniqid('dt') . '.csv'; | ||
|
||
$file = fopen($filePath, 'w'); | ||
|
||
fputcsv($file, $columnNames); | ||
|
||
foreach ($data as $row) { | ||
fputcsv($file, array_map('strip_tags', $row)); | ||
} | ||
|
||
fclose($file); | ||
|
||
return new \SplFileInfo($filePath); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName(): string | ||
{ | ||
return 'csv'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
/* | ||
* Symfony DataTables Bundle | ||
* (c) Omines Internetbureau B.V. - https://omines.nl/ | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omines\DataTablesBundle\Exporter; | ||
|
||
use Omines\DataTablesBundle\Exception\UnknownDataTableExporterException; | ||
|
||
/** | ||
* Holds the available DataTable exporters. | ||
* Exporters must be tagged with 'datatables.exporter'. | ||
* | ||
* @author Maxime Pinot <contact@maximepinot.com> | ||
*/ | ||
class DataTableExporterCollection | ||
{ | ||
/** @var \Traversable The available exporters */ | ||
private $exporters; | ||
|
||
/** | ||
* DataTableExporterCollection constructor. | ||
* | ||
* @param \Traversable $exporters | ||
*/ | ||
public function __construct(\Traversable $exporters) | ||
{ | ||
$this->exporters = $exporters; | ||
} | ||
|
||
/** | ||
* Finds a DataTable exporter that matches the given name. | ||
* | ||
* @param string $name | ||
* | ||
* @return DataTableExporterInterface | ||
* | ||
* @throws UnknownDataTableExporterException | ||
*/ | ||
public function getByName(string $name): DataTableExporterInterface | ||
{ | ||
foreach ($this->exporters as $exporter) { | ||
if ($exporter->getName() === $name) { | ||
return $exporter; | ||
} | ||
} | ||
|
||
throw new UnknownDataTableExporterException($name, $this->exporters); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* Symfony DataTables Bundle | ||
* (c) Omines Internetbureau B.V. - https://omines.nl/ | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Omines\DataTablesBundle\Exporter; | ||
|
||
/** | ||
* Available events. | ||
* | ||
* @author Maxime Pinot <contact@maximepinot.com> | ||
*/ | ||
final class DataTableExporterEvents | ||
{ | ||
/** | ||
* The PRE_RESPONSE event is dispatched before sending | ||
* the BinaryFileResponse to the user. | ||
* | ||
* Note that the file is accessible through the Response object. | ||
* Both the file and the Response can be modified before being sent. | ||
* | ||
* @Event("Omines\DataTablesBundle\Exporter\Event\DataTableExporterResponseEvent") | ||
*/ | ||
const PRE_RESPONSE = 'omines_datatables.exporter.pre_response'; | ||
} |
Oops, something went wrong.