Fixed exception when trying to export an empty entity list

Fixes issue #836
This commit is contained in:
Jan Böhmer 2025-02-01 20:57:27 +01:00
parent fd7a0156bc
commit aa06e1df04
3 changed files with 14 additions and 2 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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>