@@ -320,23 +320,32 @@ public function enableApp(string $appId, array $deployOptions = []): JSONRespons
320320
321321 $ envOptions = isset ($ deployOptions ['environment_variables ' ])
322322 ? array_keys ($ deployOptions ['environment_variables ' ]) : [];
323- $ envOptionsString = '' ;
323+ $ envArgs = [] ;
324324 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 ]);
326327 }
327- $ envOptionsString = trim ($ envOptionsString );
328328
329329 $ mountOptions = $ deployOptions ['mounts ' ] ?? [];
330- $ mountOptionsString = '' ;
330+ $ mountArgs = [] ;
331331 foreach ($ mountOptions as $ mountOption ) {
332332 $ 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 );
334335 }
335- $ mountOptionsString = trim ($ mountOptionsString );
336336
337337 // If ExApp is not registered - then it's a "Deploy and Enable" action.
338338 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 )) {
340349 return new JSONResponse (['data ' => ['message ' => $ this ->l10n ->t ('Error starting install of ExApp ' )]], Http::STATUS_INTERNAL_SERVER_ERROR );
341350 }
342351 $ elapsedTime = 0 ;
@@ -394,7 +403,12 @@ public function updateApp(string $appId): JSONResponse {
394403 }
395404
396405 $ 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 )) {
398412 return new JSONResponse (['data ' => ['message ' => $ this ->l10n ->t ('Error starting update of ExApp ' )]], Http::STATUS_INTERNAL_SERVER_ERROR );
399413 }
400414
0 commit comments