@@ -320,23 +320,32 @@ public function enableApp(string $appId, array $deployOptions = []): JSONRespons
320
320
321
321
$ envOptions = isset ($ deployOptions ['environment_variables ' ])
322
322
? array_keys ($ deployOptions ['environment_variables ' ]) : [];
323
- $ envOptionsString = '' ;
323
+ $ envArgs = [] ;
324
324
foreach ($ envOptions as $ envOption ) {
325
- $ envOptionsString .= sprintf (' --env %s=%s ' , $ envOption , $ deployOptions ['environment_variables ' ][$ envOption ]);
325
+ $ envArgs [] = '--env ' ;
326
+ $ envArgs [] = sprintf ('%s=%s ' , $ envOption , $ deployOptions ['environment_variables ' ][$ envOption ]);
326
327
}
327
- $ envOptionsString = trim ($ envOptionsString );
328
328
329
329
$ mountOptions = $ deployOptions ['mounts ' ] ?? [];
330
- $ mountOptionsString = '' ;
330
+ $ mountArgs = [] ;
331
331
foreach ($ mountOptions as $ mountOption ) {
332
332
$ readonlyModifier = $ mountOption ['readonly ' ] ? 'ro ' : 'rw ' ;
333
- $ mountOptionsString .= sprintf (' --mount %s:%s:%s ' , $ mountOption ['hostPath ' ], $ mountOption ['containerPath ' ], $ readonlyModifier );
333
+ $ mountArgs [] = '--mount ' ;
334
+ $ mountArgs [] = sprintf ('%s:%s:%s ' , $ mountOption ['hostPath ' ], $ mountOption ['containerPath ' ], $ readonlyModifier );
334
335
}
335
- $ mountOptionsString = trim ($ mountOptionsString );
336
336
337
337
// If ExApp is not registered - then it's a "Deploy and Enable" action.
338
338
if (!$ exApp ) {
339
- if (!$ this ->service ->runOccCommand (sprintf ("app_api:app:register --silent %s %s %s " , $ appId , $ envOptionsString , $ mountOptionsString ))) {
339
+ $ commandParts = array_merge (
340
+ [
341
+ 'app_api:app:register ' ,
342
+ '--silent ' ,
343
+ $ appId ,
344
+ ],
345
+ $ envArgs ,
346
+ $ mountArgs
347
+ );
348
+ if (!$ this ->service ->runOccCommand ($ commandParts )) {
340
349
return new JSONResponse (['data ' => ['message ' => $ this ->l10n ->t ('Error starting install of ExApp ' )]], Http::STATUS_INTERNAL_SERVER_ERROR );
341
350
}
342
351
$ elapsedTime = 0 ;
@@ -394,7 +403,12 @@ public function updateApp(string $appId): JSONResponse {
394
403
}
395
404
396
405
$ exAppOldVersion = $ this ->exAppService ->getExApp ($ appId )->getVersion ();
397
- if (!$ this ->service ->runOccCommand (sprintf ("app_api:app:update --silent %s " , $ appId ))) {
406
+ $ commandParts = [
407
+ 'app_api:app:update ' ,
408
+ '--silent ' ,
409
+ $ appId ,
410
+ ];
411
+ if (!$ this ->service ->runOccCommand ($ commandParts )) {
398
412
return new JSONResponse (['data ' => ['message ' => $ this ->l10n ->t ('Error starting update of ExApp ' )]], Http::STATUS_INTERNAL_SERVER_ERROR );
399
413
}
400
414
0 commit comments