mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-22 01:49:05 +02:00
Fixed entity export.
This commit is contained in:
parent
b6f95ebe48
commit
181e0f72ed
5 changed files with 30 additions and 9 deletions
|
@ -92,6 +92,11 @@ services:
|
|||
tags:
|
||||
- name: doctrine.orm.entity_listener
|
||||
|
||||
# Dont use JSONSerializable Interface,
|
||||
serializer.normalizer.json_serializable:
|
||||
class: Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer
|
||||
tags:
|
||||
- {name: serializer.normalizer, priority: -9000}
|
||||
|
||||
App\Controller\RedirectController:
|
||||
arguments:
|
||||
|
|
|
@ -152,6 +152,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
'entity' => $entity,
|
||||
'form' => $form->createView(),
|
||||
'attachment_helper' => $this->attachmentHelper,
|
||||
'route_base' => $this->route_base,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -264,6 +265,7 @@ abstract class BaseAdminController extends AbstractController
|
|||
'import_form' => $import_form->createView(),
|
||||
'mass_creation_form' => $mass_creation_form->createView(),
|
||||
'attachment_helper' => $this->attachmentHelper,
|
||||
'route_base' => $this->route_base,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class Part extends AttachmentContainingDBElement
|
|||
/**
|
||||
* TODO.
|
||||
*/
|
||||
protected $devices;
|
||||
protected $devices = [];
|
||||
|
||||
/**
|
||||
* @ColumnSecurity(type="datetime")
|
||||
|
|
|
@ -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,
|
||||
$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);
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@
|
|||
|
||||
{% if entity.id %}
|
||||
<div id="export" class="tab-pane fade">
|
||||
{% include 'AdminPages/_export_form.html.twig' with {'path' : path('attachment_type_export', {'id': entity.id})} %}
|
||||
{% include 'AdminPages/_export_form.html.twig' with {'path' : path(route_base ~ '_export', {'id': entity.id})} %}
|
||||
</div>
|
||||
{% else %} {# For new element we have a combined import/export tab #}
|
||||
<div id="import_export" class="tab-pane fade">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue