mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-12 19:34:31 +02:00
Fixed entity export.
This commit is contained in:
parent
b6f95ebe48
commit
181e0f72ed
5 changed files with 30 additions and 9 deletions
|
@ -43,6 +43,14 @@ declare(strict_types=1);
|
|||
namespace App\Services;
|
||||
|
||||
use App\Entity\Base\AbstractNamedDBElement;
|
||||
use Symfony\Component\Serializer\Encoder\CsvEncoder;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
use Symfony\Component\Serializer\Encoder\YamlEncoder;
|
||||
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
use function in_array;
|
||||
use InvalidArgumentException;
|
||||
use function is_array;
|
||||
|
@ -62,6 +70,10 @@ class EntityExporter
|
|||
|
||||
public function __construct(SerializerInterface $serializer)
|
||||
{
|
||||
/*$encoders = [new XmlEncoder(), new JsonEncoder(), new CSVEncoder(), new YamlEncoder()];
|
||||
$normalizers = [new ObjectNormalizer(), new DateTimeNormalizer()];
|
||||
$this->serializer = new Serializer($normalizers, $encoders);
|
||||
$this->serializer-> */
|
||||
$this->serializer = $serializer;
|
||||
}
|
||||
|
||||
|
@ -120,13 +132,15 @@ class EntityExporter
|
|||
$entity_array = [$entity];
|
||||
}
|
||||
|
||||
$response = new Response($this->serializer->serialize($entity_array, $format,
|
||||
[
|
||||
'groups' => $groups,
|
||||
'as_collection' => true,
|
||||
'csv_delimiter' => ';', //Better for Excel
|
||||
'xml_root_node_name' => 'PartDBExport',
|
||||
]));
|
||||
$serialized_data = $this->serializer->serialize($entity_array, $format,
|
||||
[
|
||||
'groups' => $groups,
|
||||
'as_collection' => true,
|
||||
'csv_delimiter' => ';', //Better for Excel
|
||||
'xml_root_node_name' => 'PartDBExport',
|
||||
]);
|
||||
|
||||
$response = new Response($serialized_data);
|
||||
|
||||
$response->headers->set('Content-Type', $content_type);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue