mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Fixed exception when trying to export an empty entity list
Fixes issue #836
This commit is contained in:
parent
fd7a0156bc
commit
aa06e1df04
3 changed files with 14 additions and 2 deletions
|
@ -467,6 +467,11 @@ abstract class BaseAdminController extends AbstractController
|
|||
$this->denyAccessUnlessGranted('read', $entity);
|
||||
$entities = $em->getRepository($this->entity_class)->findAll();
|
||||
|
||||
if (count($entities) === 0) {
|
||||
$this->addFlash('error', 'entity.export.flash.error.no_entities');
|
||||
return $this->redirectToRoute($this->route_base.'_new');
|
||||
}
|
||||
|
||||
return $exporter->exportEntityFromRequest($entities, $request);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,8 +112,9 @@ class PartImportExportController extends AbstractController
|
|||
$ids = $request->query->get('ids', '');
|
||||
$parts = $this->partsTableActionHandler->idStringToArray($ids);
|
||||
|
||||
if ($parts === []) {
|
||||
throw new \RuntimeException('No parts found!');
|
||||
if (count($parts) === 0) {
|
||||
$this->addFlash('error', 'entity.export.flash.error.no_entities');
|
||||
return $this->redirectToRoute('homepage');
|
||||
}
|
||||
|
||||
//Ensure that we have access to the parts
|
||||
|
|
|
@ -12323,5 +12323,11 @@ Please note, that you can not impersonate a disabled user. If you try you will g
|
|||
<target>Profile saved!</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="8C9ijHM" name="entity.export.flash.error.no_entities">
|
||||
<segment>
|
||||
<source>entity.export.flash.error.no_entities</source>
|
||||
<target>There are no entities to export!</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue