Skip to content

Commit

Permalink
Merge pull request #74 from vmalyk/hotfix/missed-translator-in-contro…
Browse files Browse the repository at this point in the history
…ller

Added and fixed controller for getting translations
  • Loading branch information
kjkooistra-youwe authored Jul 22, 2024
2 parents 64ce8d3 + d9aae6a commit 7720f1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
16 changes: 9 additions & 7 deletions src/WorkflowGui/Controller/WorkflowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use Pimcore\Bundle\CoreBundle\DependencyInjection\Configuration;
use Pimcore\Cache\Symfony\CacheClearer;
use Symfony\Contracts\Translation\TranslatorInterface;
use Pimcore\Controller\Traits\JsonHelperTrait;
use Pimcore\Controller\UserAwareController;
use Pimcore\Model\User;
Expand All @@ -42,6 +43,7 @@ public function __construct(
protected ConfigFileResolverInterface $configFileResolver,
protected KernelInterface $kernel,
protected CacheClearer $cacheClearer,
protected TranslatorInterface $translator
) {}

public function listAction(): JsonResponse
Expand Down Expand Up @@ -91,7 +93,7 @@ public function cloneAction(Request $request): JsonResponse
if ($workflowByName) {
return $this->json([
'success' => false,
'message' => $this->trans('workflow_gui_workflow_with_name_already_exists'),
'message' => $this->translator->trans('workflow_gui_workflow_with_name_already_exists'),
]);
}

Expand Down Expand Up @@ -283,12 +285,12 @@ public function visualizeAction(Request $request): Response
$this->isGrantedOr403();

try {
return new Response($this->container->get('twig')->render(
return $this->render(
'@WorkflowGui/Workflow/visualize.html.twig',
[
'image' => $this->getVisualization($request->get('workflow'), 'svg'),
]
));
);
} catch (\Throwable $e) {
return new Response($e->getMessage());
}
Expand Down Expand Up @@ -325,21 +327,21 @@ private function getVisualization($workflow, $format): string
$dot = Console::getExecutable('dot');

if (!$php) {
throw new \InvalidArgumentException($this->trans('workflow_cmd_not_found', ['php']));
throw new \InvalidArgumentException($this->translator->trans('workflow_cmd_not_found', ['php'], 'admin'));
}

if (!$dot) {
throw new \InvalidArgumentException($this->trans('workflow_cmd_not_found', ['dot']));
throw new \InvalidArgumentException($this->translator->trans('workflow_cmd_not_found', ['dot'], 'admin'));
}

$workflowRepository = $this->repository->find($workflow);

if ($workflowRepository === null) {
throw new \InvalidArgumentException($this->trans('workflow_gui_not_found'));
throw new \InvalidArgumentException($this->translator->trans('workflow_gui_not_found', [], 'admin'));
}

if (!$workflowRepository['enabled'] ?? false) {
throw new \InvalidArgumentException($this->trans('workflow_gui_enable_message'));
throw new \InvalidArgumentException($this->translator->trans('workflow_gui_enable_message', [], 'admin'));
}

$cmd = $php.' '.PIMCORE_PROJECT_ROOT.'/bin/console --env="${:arg_environment}" pimcore:workflow:dump "${:arg_workflow}" | '.$dot.' -T"${:arg_format}"';
Expand Down
10 changes: 5 additions & 5 deletions src/WorkflowGui/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ services:
- '@Youwe\Pimcore\WorkflowGui\Resolver\ConfigFileResolver'

Youwe\Pimcore\WorkflowGui\Controller\WorkflowController:
arguments:
arguments:
- '@Youwe\Pimcore\WorkflowGui\Repository\WorkflowRepository'
- '@Youwe\Pimcore\WorkflowGui\Resolver\ConfigFileResolver'
- '@kernel'
- '@Pimcore\Cache\Symfony\CacheClearer'
tags:
- { name: controller.service_arguments }
calls:
- { method: setContainer, arguments: [ '@service_container' ] }
- '@translator'
tags: ['controller.service_arguments', 'container.service_subscriber']
calls:
- { method: setContainer, arguments: [ '@Psr\Container\ContainerInterface' ] }
- { method: setTokenResolver, arguments: [ '@Pimcore\Security\User\TokenStorageUserResolver' ] }
- { method: setPimcoreSerializer, arguments: [ '@pimcore.serializer' ] }

0 comments on commit 7720f1c

Please sign in to comment.