From b14259acdffadcfeda5f7837fc6ed24d17a85e1a Mon Sep 17 00:00:00 2001 From: Bruno Pasqualini Date: Mon, 27 Mar 2023 13:45:06 +1030 Subject: [PATCH 1/3] Implement compatibility fixes for Oro 5.0 --- Controller/FailedJobController.php | 26 +++++++++++++------ .../AligentAsyncEventsExtension.php | 1 + Resources/config/controllers.yml | 13 ++++++++++ Resources/translations/messages.en.yml | 1 + Resources/views/FailedJob/index.html.twig | 2 +- Resources/views/FailedJob/view.html.twig | 12 ++++----- 6 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 Resources/config/controllers.yml diff --git a/Controller/FailedJobController.php b/Controller/FailedJobController.php index 1f33b32..e077423 100644 --- a/Controller/FailedJobController.php +++ b/Controller/FailedJobController.php @@ -13,6 +13,7 @@ namespace Aligent\AsyncEventsBundle\Controller; use Aligent\AsyncEventsBundle\Entity\FailedJob; +use Doctrine\Persistence\ManagerRegistry; use Oro\Bundle\SecurityBundle\Annotation\AclAncestor; use Oro\Component\MessageQueue\Client\MessageProducerInterface; use Oro\Component\MessageQueue\Transport\Exception\Exception; @@ -24,6 +25,20 @@ class FailedJobController extends AbstractController { + + protected MessageProducerInterface $messageProducer; + protected ManagerRegistry $doctrine; + + /** + * @param MessageProducerInterface $messageProducer + * @param ManagerRegistry $managerRegistry + */ + public function __construct(MessageProducerInterface $messageProducer, ManagerRegistry $managerRegistry) + { + $this->messageProducer = $messageProducer; + $this->doctrine = $managerRegistry; + } + /** * @Route(name="aligent_failed_jobs_index") * @Acl( @@ -64,9 +79,8 @@ public function viewAction(FailedJob $job) */ public function deleteAction(FailedJob $job) { - $em = $this->getDoctrine()->getManager(); - try { + $em = $this->doctrine->getManager(); $em->remove($job); $em->flush(); } catch (Exception $exception) { @@ -86,17 +100,13 @@ public function deleteAction(FailedJob $job) */ public function retryAction(FailedJob $job) { - /** @var MessageProducerInterface $messageProducer */ - $messageProducer = $this->get('oro_message_queue.message_producer'); - - $em = $this->getDoctrine()->getManager(); - try { - $messageProducer->send( + $this->messageProducer->send( $job->getTopic(), $job->getBody() ); + $em = $this->doctrine->getManager(); $em->remove($job); $em->flush(); } catch (Exception $exception) { diff --git a/DependencyInjection/AligentAsyncEventsExtension.php b/DependencyInjection/AligentAsyncEventsExtension.php index 194608b..1682386 100644 --- a/DependencyInjection/AligentAsyncEventsExtension.php +++ b/DependencyInjection/AligentAsyncEventsExtension.php @@ -32,5 +32,6 @@ public function load(array $configs, ContainerBuilder $container) $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); $loader->load('integration.yml'); + $loader->load('controllers.yml'); } } diff --git a/Resources/config/controllers.yml b/Resources/config/controllers.yml new file mode 100644 index 0000000..6f5731b --- /dev/null +++ b/Resources/config/controllers.yml @@ -0,0 +1,13 @@ +services: + _defaults: + public: true + + # Controller + Aligent\AsyncEventsBundle\Controller\FailedJobController: + arguments: + - '@oro_message_queue.client.message_producer' + - '@doctrine' + calls: + - [setContainer, ['@Psr\Container\ContainerInterface']] + tags: + - { name: container.service_subscriber } \ No newline at end of file diff --git a/Resources/translations/messages.en.yml b/Resources/translations/messages.en.yml index 55be8f1..d6a90b5 100644 --- a/Resources/translations/messages.en.yml +++ b/Resources/translations/messages.en.yml @@ -1,5 +1,6 @@ aligent.webhook.channel.label: Webhook aligent.webhook.webhooktransport.entity_label: Webhook Transport +aligent.asyncevents.failedjob.entity_plural_label: Failed Jobs aligent.async.failedjob.entity.plural_label: Failed Jobs aligent.async.failedjob.retry.label: Retry aligent.async.failedjob.entity_plural_label: Failed Jobs diff --git a/Resources/views/FailedJob/index.html.twig b/Resources/views/FailedJob/index.html.twig index d20144e..08d61b0 100644 --- a/Resources/views/FailedJob/index.html.twig +++ b/Resources/views/FailedJob/index.html.twig @@ -1,3 +1,3 @@ -{% extends '@OroUIBundle/actions/index.html.twig' %} +{% extends '@OroUI/actions/index.html.twig' %} {% set gridName = 'aligent-failed-jobs-grid' %} {% set pageTitle = 'aligent.async.failedjob.entity.plural_label'|trans %} \ No newline at end of file diff --git a/Resources/views/FailedJob/view.html.twig b/Resources/views/FailedJob/view.html.twig index b96954d..f43407c 100644 --- a/Resources/views/FailedJob/view.html.twig +++ b/Resources/views/FailedJob/view.html.twig @@ -1,5 +1,5 @@ -{% extends '@OroUIBundle/actions:view.html.twig' %} -{% import '@OroUIBundle/macros.html.twig' as ui %} +{% extends '@OroUI/actions/view.html.twig' %} +{% import '@OroUI/macros.html.twig' as UI %} {% oro_title_set({ titleTemplate : "%title%", params : { @@ -51,14 +51,14 @@
- {{ ui.renderProperty('aligent.async.failedjob.topic.label'|trans, entity.topic) }} - {{ ui.renderProperty('aligent.async.failedjob.exception.label'|trans, entity.exception) }} - {{ ui.renderCollapsibleHtmlProperty('aligent.async.failedjob.body.label'|trans, entity.body|json_encode, entity, 'body') }} + {{ UI.renderProperty('aligent.async.failedjob.topic.label'|trans, entity.topic) }} + {{ UI.renderProperty('aligent.async.failedjob.exception.label'|trans, entity.exception) }} + {{ UI.renderCollapsibleHtmlProperty('aligent.async.failedjob.body.label'|trans, entity.body|json_encode, entity, 'body') }}
- {{ ui.renderCollapsibleHtmlProperty('aligent.async.failedjob.trace.label'|trans, entity.trace|nl2br, entity, 'trace') }} + {{ UI.renderCollapsibleHtmlProperty('aligent.async.failedjob.trace.label'|trans, entity.trace|nl2br, entity, 'trace') }}
From 9763141a4fdf163bb670d498fabd0012df799938 Mon Sep 17 00:00:00 2001 From: Bruno Pasqualini Date: Tue, 28 Mar 2023 14:58:24 +1030 Subject: [PATCH 2/3] Remove duplicate translation --- Resources/translations/messages.en.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/Resources/translations/messages.en.yml b/Resources/translations/messages.en.yml index d6a90b5..b485cfc 100644 --- a/Resources/translations/messages.en.yml +++ b/Resources/translations/messages.en.yml @@ -1,7 +1,6 @@ aligent.webhook.channel.label: Webhook aligent.webhook.webhooktransport.entity_label: Webhook Transport aligent.asyncevents.failedjob.entity_plural_label: Failed Jobs -aligent.async.failedjob.entity.plural_label: Failed Jobs aligent.async.failedjob.retry.label: Retry aligent.async.failedjob.entity_plural_label: Failed Jobs aligent.async.failedjob.created_at.label: Created At From 957f2db50225beda606fe8ba392c60b139a8d65d Mon Sep 17 00:00:00 2001 From: Bruno Pasqualini Date: Tue, 28 Mar 2023 15:00:21 +1030 Subject: [PATCH 3/3] Reverting changes --- Resources/translations/messages.en.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/translations/messages.en.yml b/Resources/translations/messages.en.yml index b485cfc..d6a90b5 100644 --- a/Resources/translations/messages.en.yml +++ b/Resources/translations/messages.en.yml @@ -1,6 +1,7 @@ aligent.webhook.channel.label: Webhook aligent.webhook.webhooktransport.entity_label: Webhook Transport aligent.asyncevents.failedjob.entity_plural_label: Failed Jobs +aligent.async.failedjob.entity.plural_label: Failed Jobs aligent.async.failedjob.retry.label: Retry aligent.async.failedjob.entity_plural_label: Failed Jobs aligent.async.failedjob.created_at.label: Created At