18
18
19
19
use Pimcore \Bundle \CoreBundle \DependencyInjection \Configuration ;
20
20
use Pimcore \Cache \Symfony \CacheClearer ;
21
+ use Symfony \Contracts \Translation \TranslatorInterface ;
21
22
use Pimcore \Controller \Traits \JsonHelperTrait ;
22
23
use Pimcore \Controller \UserAwareController ;
23
24
use Pimcore \Model \User ;
@@ -42,6 +43,7 @@ public function __construct(
42
43
protected ConfigFileResolverInterface $ configFileResolver ,
43
44
protected KernelInterface $ kernel ,
44
45
protected CacheClearer $ cacheClearer ,
46
+ protected TranslatorInterface $ translator
45
47
) {}
46
48
47
49
public function listAction (): JsonResponse
@@ -91,7 +93,7 @@ public function cloneAction(Request $request): JsonResponse
91
93
if ($ workflowByName ) {
92
94
return $ this ->json ([
93
95
'success ' => false ,
94
- 'message ' => $ this ->trans ('workflow_gui_workflow_with_name_already_exists ' ),
96
+ 'message ' => $ this ->translator -> trans ('workflow_gui_workflow_with_name_already_exists ' ),
95
97
]);
96
98
}
97
99
@@ -283,12 +285,12 @@ public function visualizeAction(Request $request): Response
283
285
$ this ->isGrantedOr403 ();
284
286
285
287
try {
286
- return new Response ( $ this -> container -> get ( ' twig ' ) ->render (
288
+ return $ this ->render (
287
289
'@WorkflowGui/Workflow/visualize.html.twig ' ,
288
290
[
289
291
'image ' => $ this ->getVisualization ($ request ->get ('workflow ' ), 'svg ' ),
290
292
]
291
- )) ;
293
+ );
292
294
} catch (\Throwable $ e ) {
293
295
return new Response ($ e ->getMessage ());
294
296
}
@@ -325,21 +327,21 @@ private function getVisualization($workflow, $format): string
325
327
$ dot = Console::getExecutable ('dot ' );
326
328
327
329
if (!$ php ) {
328
- throw new \InvalidArgumentException ($ this ->trans ('workflow_cmd_not_found ' , ['php ' ]));
330
+ throw new \InvalidArgumentException ($ this ->translator -> trans ('workflow_cmd_not_found ' , ['php ' ], ' admin ' ));
329
331
}
330
332
331
333
if (!$ dot ) {
332
- throw new \InvalidArgumentException ($ this ->trans ('workflow_cmd_not_found ' , ['dot ' ]));
334
+ throw new \InvalidArgumentException ($ this ->translator -> trans ('workflow_cmd_not_found ' , ['dot ' ], ' admin ' ));
333
335
}
334
336
335
337
$ workflowRepository = $ this ->repository ->find ($ workflow );
336
338
337
339
if ($ workflowRepository === null ) {
338
- throw new \InvalidArgumentException ($ this ->trans ('workflow_gui_not_found ' ));
340
+ throw new \InvalidArgumentException ($ this ->translator -> trans ('workflow_gui_not_found ' , [], ' admin ' ));
339
341
}
340
342
341
343
if (!$ workflowRepository ['enabled ' ] ?? false ) {
342
- throw new \InvalidArgumentException ($ this ->trans ('workflow_gui_enable_message ' ));
344
+ throw new \InvalidArgumentException ($ this ->translator -> trans ('workflow_gui_enable_message ' , [], ' admin ' ));
343
345
}
344
346
345
347
$ cmd = $ php .' ' .PIMCORE_PROJECT_ROOT .'/bin/console --env="${:arg_environment}" pimcore:workflow:dump "${:arg_workflow}" | ' .$ dot .' -T"${:arg_format}" ' ;
0 commit comments