Skip to content

Commit 10a0b12

Browse files
committed
Changed: use config setting to disable default mapping
1 parent 7087ddc commit 10a0b12

File tree

6 files changed

+26
-17
lines changed

6 files changed

+26
-17
lines changed

docs/bundle/config_reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ enqueue:
6767
queue_name: ~
6868
job:
6969
enabled: false
70-
entity_manager_name: ~
70+
default_mapping: true
7171
async_events:
7272
enabled: false
7373
extensions:

docs/bundle/job_queue.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,20 @@ enqueue:
6161

6262
job: true
6363

64-
# by default bundle will add a default orm mapping configuration
65-
# if you define custom mappings, you can specify which entity manager to use here
66-
entity_manager_name: ~
64+
# if you configure doctrine mapping yourself, disable default mapping
65+
default_mapping: false
66+
67+
doctrine:
68+
# plus basic bundle configuration
69+
70+
orm:
71+
mappings:
72+
EnqueueJobQueue:
73+
is_bundle: false
74+
type: xml
75+
dir: '%kernel.project_dir%/vendor/enqueue/job-queue/Doctrine/mapping'
76+
prefix: 'Enqueue\JobQueue\Doctrine\Entity'
77+
6778
```
6879

6980
* Run doctrine schema update command

pkg/enqueue-bundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private function getJobConfiguration(): ArrayNodeDefinition
9595

9696
return (new ArrayNodeDefinition('job'))
9797
->children()
98-
->scalarNode('entity_manager_name')->defaultNull()->end()
98+
->booleanNode('default_mapping')->defaultTrue()->end()
9999
->end()
100100
->addDefaultsIfNotSet()
101101
->canBeEnabled()

pkg/enqueue-bundle/DependencyInjection/EnqueueExtension.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ public function load(array $configs, ContainerBuilder $container): void
9898
throw new \LogicException('Job-queue supports only default configuration.');
9999
}
100100

101-
$container->setParameter(
102-
'enqueue.job.entity_manager_name',
103-
$modules['job']['entity_manager_name']
104-
);
105-
106101
$loader->load('job.yml');
107102
}
108103

@@ -176,6 +171,14 @@ private function registerJobQueueDoctrineEntityMapping(ContainerBuilder $contain
176171
return;
177172
}
178173

174+
foreach ($container->getExtensionConfig('enqueue') as $modules) {
175+
foreach ($modules as $config) {
176+
if (isset($config['job']) && false === $config['job']['default_mapping']) {
177+
return;
178+
}
179+
}
180+
}
181+
179182
foreach ($container->getExtensionConfig('doctrine') as $config) {
180183
// do not register mappings if dbal not configured.
181184
if (!empty($config['dbal'])) {

pkg/enqueue-bundle/Resources/config/job.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ services:
99
- '@doctrine'
1010
- 'Enqueue\JobQueue\Doctrine\Entity\Job'
1111
- '%enqueue.job.unique_job_table_name%'
12-
- '%enqueue.job.entity_manager_name%'
1312

1413
# Deprecated. To be removed in 0.10.
1514
enqueue.job.storage:

pkg/job-queue/Doctrine/JobStorage.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ class JobStorage
4646
/**
4747
* @param string $entityClass
4848
* @param string $uniqueTableName
49-
* @param mixed $entityManagerName
5049
*/
51-
public function __construct(ManagerRegistry $doctrine, $entityClass, $uniqueTableName, $entityManagerName = null)
50+
public function __construct(ManagerRegistry $doctrine, $entityClass, $uniqueTableName)
5251
{
5352
$this->doctrine = $doctrine;
5453
$this->entityClass = $entityClass;
5554
$this->uniqueTableName = $uniqueTableName;
56-
$this->entityManagerName = $entityManagerName;
5755
}
5856

5957
/**
@@ -204,9 +202,7 @@ private function getEntityRepository()
204202
private function getEntityManager()
205203
{
206204
if (!$this->em) {
207-
$this->em = empty($this->entityManagerName)
208-
? $this->doctrine->getManagerForClass($this->entityClass)
209-
: $this->doctrine->getManager($this->entityManagerName);
205+
$this->em = $this->doctrine->getManagerForClass($this->entityClass);
210206
}
211207
if (!$this->em->isOpen()) {
212208
$this->em = $this->doctrine->resetManager();

0 commit comments

Comments
 (0)