Skip to content

Commit

Permalink
Merge pull request #7 from aligent/hotfix/Oro5.0-Compatibilty_Fixes
Browse files Browse the repository at this point in the history
Implement compatibility fixes for Oro 5.0
  • Loading branch information
pasqualinibruno authored Mar 30, 2023
2 parents 756360b + 957f2db commit 29d261d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 15 deletions.
26 changes: 18 additions & 8 deletions Controller/FailedJobController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/AligentAsyncEventsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
13 changes: 13 additions & 0 deletions Resources/config/controllers.yml
Original file line number Diff line number Diff line change
@@ -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 }
1 change: 1 addition & 0 deletions Resources/translations/messages.en.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Resources/views/FailedJob/index.html.twig
Original file line number Diff line number Diff line change
@@ -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 %}
12 changes: 6 additions & 6 deletions Resources/views/FailedJob/view.html.twig
Original file line number Diff line number Diff line change
@@ -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 : {
Expand Down Expand Up @@ -51,14 +51,14 @@
<div class="responsive-cell">
<div class="row-fluid form-horizontal">
<div class="responsive-block">
{{ 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') }}
</div>
</div>
<div class="row-fluid form-horizontal">
<div class="responsive-block">
{{ 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') }}
</div>
</div>
</div>
Expand Down

0 comments on commit 29d261d

Please sign in to comment.