-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOroMessageQueueBundle.php
More file actions
71 lines (64 loc) · 3.65 KB
/
OroMessageQueueBundle.php
File metadata and controls
71 lines (64 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace Oro\Bundle\MessageQueueBundle;
use Oro\Bundle\MessageQueueBundle\DependencyInjection\Compiler\AddTopicDescriptionPass;
use Oro\Bundle\MessageQueueBundle\DependencyInjection\Compiler\BuildDestinationMetaRegistryPass;
use Oro\Bundle\MessageQueueBundle\DependencyInjection\Compiler\BuildExtensionsPass;
use Oro\Bundle\MessageQueueBundle\DependencyInjection\Compiler\BuildMessageProcessorRegistryPass;
use Oro\Bundle\MessageQueueBundle\DependencyInjection\Compiler\BuildMonologHandlersPass;
use Oro\Bundle\MessageQueueBundle\DependencyInjection\Compiler\BuildTopicMetaRegistryPass;
use Oro\Bundle\MessageQueueBundle\DependencyInjection\Compiler\ConfigureClearersPass;
use Oro\Bundle\MessageQueueBundle\DependencyInjection\Compiler\ConfigureDbalTransportExtensionsPass;
use Oro\Bundle\MessageQueueBundle\DependencyInjection\Compiler\MakeAnnotationReaderServicesPersistentPass;
use Oro\Bundle\MessageQueueBundle\DependencyInjection\Compiler\MakeLoggerServicesPersistentPass;
use Oro\Bundle\MessageQueueBundle\DependencyInjection\OroMessageQueueExtension;
use Oro\Bundle\MessageQueueBundle\DependencyInjection\Transport\Factory\DbalTransportFactory;
use Oro\Component\DependencyInjection\Compiler\PriorityNamedTaggedServiceWithHandlerCompilerPass;
use Oro\Component\DependencyInjection\Compiler\TaggedServiceTrait;
use Oro\Component\MessageQueue\Event\AfterSaveJobEvent;
use Oro\Component\MessageQueue\Event\BeforeSaveJobEvent;
use Oro\Component\MessageQueue\Job\Topics;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\EventDispatcher\DependencyInjection\AddEventAliasesPass;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* OroMessageQueueBundle incorporates the OroMessageQueue component into OroPlatform
* and thereby provides message queue processing capabilities for all application components
*/
class OroMessageQueueBundle extends Bundle
{
use TaggedServiceTrait;
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
{
$container->addCompilerPass(new ConfigureDbalTransportExtensionsPass());
$container->addCompilerPass(new BuildExtensionsPass());
$container->addCompilerPass(new BuildMessageProcessorRegistryPass());
$container->addCompilerPass(new BuildTopicMetaRegistryPass());
$container->addCompilerPass(new BuildDestinationMetaRegistryPass());
$container->addCompilerPass(new BuildMonologHandlersPass());
$container->addCompilerPass(new ConfigureClearersPass());
$container->addCompilerPass(new MakeLoggerServicesPersistentPass());
$container->addCompilerPass(new MakeAnnotationReaderServicesPersistentPass());
$container->addCompilerPass(new PriorityNamedTaggedServiceWithHandlerCompilerPass(
'oro_message_queue.client.message_filter',
'oro_message_queue.message_filter',
function (array $attributes, string $serviceId): array {
return [$serviceId, $this->getAttribute($attributes, 'topic')];
}
));
/** @var OroMessageQueueExtension $extension */
$extension = $container->getExtension('oro_message_queue');
$extension->addTransportFactory(new DbalTransportFactory());
$container->addCompilerPass(
AddTopicDescriptionPass::create()
->add(Topics::CALCULATE_ROOT_JOB_STATUS, 'Calculate root job status')
->add(Topics::ROOT_JOB_STOPPED, 'Root job stopped')
);
$container->addCompilerPass(new AddEventAliasesPass([
BeforeSaveJobEvent::class => BeforeSaveJobEvent::EVENT_ALIAS,
AfterSaveJobEvent::class => AfterSaveJobEvent::EVENT_ALIAS,
]));
}
}