|
35 | 35 | use App\Entity\LabelSystem\LabelProfile;
|
36 | 36 | use App\Entity\Parameters\AbstractParameter;
|
37 | 37 | use App\Exceptions\AttachmentDownloadException;
|
| 38 | +use App\Exceptions\TwigModeException; |
38 | 39 | use App\Form\AdminPages\ImportType;
|
39 | 40 | use App\Form\AdminPages\MassCreationForm;
|
40 | 41 | use App\Repository\AbstractPartsContainingRepository;
|
|
53 | 54 | use Omines\DataTablesBundle\DataTableFactory;
|
54 | 55 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
55 | 56 | use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
| 57 | +use Symfony\Component\Form\FormError; |
56 | 58 | use Symfony\Component\Form\FormInterface;
|
57 | 59 | use Symfony\Component\HttpFoundation\File\UploadedFile;
|
58 | 60 | use Symfony\Component\HttpFoundation\RedirectResponse;
|
@@ -211,7 +213,12 @@ protected function _edit(AbstractNamedDBElement $entity, Request $request, Entit
|
211 | 213 | //Show preview for LabelProfile if needed.
|
212 | 214 | if ($entity instanceof LabelProfile) {
|
213 | 215 | $example = $this->barcodeExampleGenerator->getElement($entity->getOptions()->getSupportedElement());
|
214 |
| - $pdf_data = $this->labelGenerator->generateLabel($entity->getOptions(), $example); |
| 216 | + $pdf_data = null; |
| 217 | + try { |
| 218 | + $pdf_data = $this->labelGenerator->generateLabel($entity->getOptions(), $example); |
| 219 | + } catch (TwigModeException $exception) { |
| 220 | + $form->get('options')->get('lines')->addError(new FormError($exception->getMessage())); |
| 221 | + } |
215 | 222 | }
|
216 | 223 |
|
217 | 224 | /** @var AbstractPartsContainingRepository $repo */
|
|
0 commit comments