@@ -264,7 +264,12 @@ private function buildDistributionFormularType(
264264 Attachment $ attachment ,
265265 ): DistributionFormular {
266266 $ files = $ this ->buildFileGroups ($ handlerSettings , $ submission );
267- $ xml = $ this ->renderXml ($ handlerSettings , $ submission , $ files )->rendered ;
267+ $ renderResult = $ this ->renderXml ($ handlerSettings , $ submission , $ files );
268+ if ($ renderResult ->exception ) {
269+ throw $ renderResult ->exception ;
270+ }
271+
272+ $ xml = (string ) $ renderResult ->rendered ;
268273 $ xsdUrl = $ handlerSettings ->distributionObject ->xsdUrl ;
269274
270275 $ this ->xmlHelper ->validateXml ($ xml );
@@ -319,10 +324,20 @@ public function renderXml(
319324
320325 $ context = $ this ->xmlHelper ->getRenderContext ($ handlerSettings , $ submission , $ files );
321326
327+ $ rendered = NULL ;
328+ $ exception = NULL ;
329+ try {
330+ $ rendered = $ this ->xmlHelper ->render ($ template , $ context , validateXml: $ validateXml );
331+ }
332+ catch (\Exception $ e ) {
333+ $ exception = $ e ;
334+ }
335+
322336 return new XmlRenderResult (
323- rendered: $ this ->xmlHelper ->render ($ template , $ context , validateXml: $ validateXml ),
324337 template: $ template ,
325338 context: $ context ,
339+ rendered: $ rendered ,
340+ exception: $ exception ,
326341 );
327342 }
328343
@@ -349,7 +364,7 @@ public function buildFileGroups(HandlerSettings $handlerSettings, WebformSubmiss
349364 $ values = $ submission ->getData ()[$ type ] ?? NULL ;
350365 if ($ values ) {
351366 /** @var \Drupal\file\FileInterface[] $files */
352- $ files = $ this ->fileStorage ->loadMultiple ($ values );
367+ $ files = $ this ->fileStorage ->loadMultiple (( array ) $ values );
353368 foreach ($ files as $ file ) {
354369 $ groups [$ type ][] = [
355370 'sftp_filename ' => $ this ->getSftpFilename ($ handlerSettings , $ submission , $ file ->getFilename ()),
0 commit comments