@@ -58,7 +58,7 @@ protected function configure(): void {
5858 ->addArgument ('webform-id ' , InputArgument::REQUIRED , 'Webform ID ' )
5959 ->addArgument ('handler-id ' , InputArgument::REQUIRED , 'Handler ID ' )
6060 ->addOption ('show-xml ' , NULL , InputOption::VALUE_NONE , 'Show XML ' )
61- ->addOption ('break-on-error ' , NULL , InputOption::VALUE_OPTIONAL , 'Break on error. If set, terminate after first error. ' , TRUE );
61+ ->addOption ('break-on-error ' , NULL , InputOption::VALUE_OPTIONAL , 'Break on error. If set, terminate after first error. ' , FALSE );
6262 }
6363
6464 /**
@@ -78,29 +78,38 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7878 $ handler = $ this ->getHandler ($ handlerId , $ webform );
7979 $ submissions = $ this ->loadSubmissions ($ webform );
8080
81- foreach ($ submissions as $ submission ) {
82- $ preview = $ this ->webformHelper ->renderPreview ($ handler , $ submission );
83- $ hasErrors = count ($ preview ['exceptions ' ]) > 0 ;
84- if ($ hasErrors ) {
85- foreach ($ preview ['exceptions ' ] as $ exception ) {
86- $ io ->error ([$ submission ->label (), $ exception ->getMessage ()]);
81+ if (0 === count ($ submissions )) {
82+ $ io ->warning (sprintf ('No submissions on form %s ' , $ webform ->label ()));
83+ }
84+ else {
85+ foreach ($ submissions as $ submission ) {
86+ $ preview = $ this ->webformHelper ->renderPreview ($ handler , $ submission );
87+ $ hasErrors = count ($ preview ['exceptions ' ]) > 0 ;
88+ if ($ hasErrors ) {
89+ foreach ($ preview ['exceptions ' ] as $ exception ) {
90+ $ io ->error ([$ submission ->label (), $ exception ->getMessage ()]);
91+ }
92+ }
93+ else {
94+ $ io ->success ($ submission ->label ());
8795 }
88- }
89- else {
90- $ io ->success ($ submission ->label ());
91- }
9296
93- if ($ showXml ) {
94- $ io ->writeln ($ preview ['xml ' ]->rendered );
95- }
97+ if ($ showXml ) {
98+ if (NULL === $ preview ['xml ' ]->rendered ) {
99+ $ io ->warning ('Cannot render XML ' );
100+ }
101+ else {
102+ $ io ->writeln ($ preview ['xml ' ]->rendered );
103+ }
104+ }
96105
97- if ($ hasErrors ) {
98- if ($ breakOnError ) {
99- return self ::FAILURE ;
106+ if ($ hasErrors ) {
107+ if ($ breakOnError ) {
108+ return self ::FAILURE ;
109+ }
110+ continue ;
100111 }
101- continue ;
102112 }
103-
104113 }
105114
106115 return self ::SUCCESS ;
0 commit comments