Skip to content

Commit 517c38e

Browse files
author
Klyachin Andrey
committed
Supports mongodb persistence driver
1 parent 6e9aaf9 commit 517c38e

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

DependencyInjection/Configuration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ public function getConfigTreeBuilder()
1919
->scalarNode('context')->defaultValue('enqueue.transport.context')->cannotBeEmpty()->end()
2020
->arrayNode('doctrine')
2121
->children()
22+
->scalarNode('driver')->isRequired()->cannotBeEmpty()
23+
->validate()->ifNotInArray(['orm', 'mongodb'])->thenInvalid('Invalid driver')
24+
->end()->end()
2225
->arrayNode('queue_listeners')
2326
->prototype('array')
2427
->addDefaultsIfNotSet()

DependencyInjection/EnqueueElasticaExtension.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,23 @@ public function load(array $configs, ContainerBuilder $container)
4040
;
4141
}
4242
}
43+
44+
$serviceId = 'enqueue_elastica.doctrine.sync_index_with_object_change_processor';
45+
$managerRegistry = $this->getManagerRegistry($config['doctrine']['driver']);
46+
$container
47+
->getDefinition($serviceId)
48+
->replaceArgument(0, new Reference($managerRegistry));
49+
}
50+
51+
private function getManagerRegistry(string $driver): string
52+
{
53+
switch ($driver) {
54+
case 'orm':
55+
return 'doctrine';
56+
break;
57+
case 'mongodb':
58+
return 'doctrine_mongodb';
59+
break;
60+
}
4361
}
4462
}

Doctrine/Queue/SyncIndexWithObjectChangeProcessor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Interop\Queue\PsrContext;
1111
use Interop\Queue\PsrMessage;
1212
use Interop\Queue\PsrProcessor;
13-
use Symfony\Bridge\Doctrine\RegistryInterface;
13+
use Doctrine\Common\Persistence\ManagerRegistry;
1414

1515
final class SyncIndexWithObjectChangeProcessor implements PsrProcessor, CommandSubscriberInterface, QueueSubscriberInterface
1616
{
@@ -31,11 +31,11 @@ final class SyncIndexWithObjectChangeProcessor implements PsrProcessor, CommandS
3131
private $indexable;
3232

3333
/**
34-
* @var RegistryInterface
34+
* @var ManagerRegistry
3535
*/
3636
private $doctrine;
3737

38-
public function __construct(RegistryInterface $doctrine, PersisterRegistry $persisterRegistry, IndexableInterface $indexable)
38+
public function __construct(ManagerRegistry $doctrine, PersisterRegistry $persisterRegistry, IndexableInterface $indexable)
3939
{
4040
$this->persisterRegistry = $persisterRegistry;
4141
$this->indexable = $indexable;

Resources/config/services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
class: 'Enqueue\ElasticaBundle\Doctrine\Queue\SyncIndexWithObjectChangeProcessor'
1313
public: true
1414
arguments:
15-
- '@doctrine'
15+
- null
1616
- '@fos_elastica.persister_registry'
1717
- '@fos_elastica.indexable'
1818
tags:

0 commit comments

Comments
 (0)