Passed
Push — master ( 788ac5...db4bb1 )
by Dominik
02:10
created

getOrmMappingDriverFactorySimpleYaml()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Beau Simensen <[email protected]> (https://github.com/dflydev/dflydev-doctrine-orm-service-provider)
7
 */
8
9
namespace Chubbyphp\ServiceProvider;
10
11
use Doctrine\Common\Cache\ApcuCache;
12
use Doctrine\Common\Cache\ArrayCache;
13
use Doctrine\Common\Cache\CacheProvider;
14
use Doctrine\Common\Cache\FilesystemCache;
15
use Doctrine\Common\Cache\MemcachedCache;
16
use Doctrine\Common\Cache\XcacheCache;
17
use Doctrine\Common\Cache\RedisCache;
18
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
19
use Doctrine\Common\Persistence\Mapping\Driver\StaticPHPDriver;
20
use Doctrine\DBAL\Types\Type;
21
use Doctrine\ORM\Cache\CacheConfiguration;
22
use Doctrine\ORM\Configuration;
23
use Doctrine\ORM\EntityManager;
24
use Doctrine\ORM\EntityRepository;
25
use Doctrine\ORM\Mapping\ClassMetadataFactory;
26
use Doctrine\ORM\Mapping\DefaultEntityListenerResolver;
27
use Doctrine\ORM\Mapping\DefaultNamingStrategy;
28
use Doctrine\ORM\Mapping\DefaultQuoteStrategy;
29
use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver;
30
use Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver;
31
use Doctrine\ORM\Mapping\Driver\XmlDriver;
32
use Doctrine\ORM\Mapping\Driver\YamlDriver;
33
use Doctrine\ORM\Repository\DefaultRepositoryFactory;
34
use Pimple\Container;
35
use Pimple\ServiceProviderInterface;
36
37
final class DoctrineOrmServiceProvider implements ServiceProviderInterface
38
{
39
    /**
40
     * Register ORM service.
41
     *
42
     * @param Container $container
43
     */
44 3
    public function register(Container $container)
45
    {
46 3
        $container['orm.em.default_options'] = $this->getOrmEmDefaultOptions();
47 3
        $container['orm.ems.options.initializer'] = $this->getOrmEmsOptionsInitializerDefinition($container);
48 3
        $container['orm.ems'] = $this->getOrmEmsDefinition($container);
49 3
        $container['orm.ems.config'] = $this->getOrmEmsConfigServiceProvider($container);
50 3
        $container['orm.proxies_dir'] = sys_get_temp_dir();
51 3
        $container['orm.auto_generate_proxies'] = true;
52 3
        $container['orm.proxies_namespace'] = 'DoctrineProxy';
53 3
        $container['orm.mapping_driver_chain'] = $this->getOrmMappingDriverChainDefinition($container);
54 3
        $container['orm.mapping_driver_chain.factory'] = $this->getOrmMappingDriverChainFactoryDefinition($container);
55 3
        $container['orm.mapping_driver.factory.annotation'] = $this->getOrmMappingDriverFactoryAnnotation($container);
56 3
        $container['orm.mapping_driver.factory.yml'] = $this->getOrmMappingDriverFactoryYaml($container);
57 3
        $container['orm.mapping_driver.factory.simple_yml'] = $this->getOrmMappingDriverFactorySimpleYaml($container);
58 3
        $container['orm.mapping_driver.factory.xml'] = $this->getOrmMappingDriverFactoryXml($container);
59 3
        $container['orm.mapping_driver.factory.simple_xml'] = $this->getOrmMappingDriverFactorySimpleXml($container);
60 3
        $container['orm.mapping_driver.factory.php'] = $this->getOrmMappingDriverFactoryPhp($container);
61 3
        $container['orm.cache.locator'] = $this->getOrmCacheLocatorDefinition($container);
62 3
        $container['orm.cache.factory'] = $this->getOrmCacheFactoryDefinition($container);
63 3
        $container['orm.cache.factory.apcu'] = $this->getOrmCacheFactoryApcuDefinition($container);
64 3
        $container['orm.cache.factory.array'] = $this->getOrmCacheFactoryArrayDefinition($container);
65 3
        $container['orm.cache.factory.filesystem'] = $this->getOrmCacheFactoryFilesystemDefinition($container);
66 3
        $container['orm.cache.factory.memcached'] = $this->getOrmCacheFactoryMemcachedDefinition($container);
67 3
        $container['orm.cache.factory.redis'] = $this->getOrmCacheFactoryRedisDefinition($container);
68 3
        $container['orm.cache.factory.xcache'] = $this->getOrmCacheFactoryXCacheDefinition($container);
69 3
        $container['orm.default_cache'] = ['driver' => 'array'];
70 3
        $container['orm.custom.functions.string'] = [];
71 3
        $container['orm.custom.functions.numeric'] = [];
72 3
        $container['orm.custom.functions.datetime'] = [];
73 3
        $container['orm.custom.hydration_modes'] = [];
74 3
        $container['orm.class_metadata_factory_name'] = ClassMetadataFactory::class;
75 3
        $container['orm.default_repository_class'] = EntityRepository::class;
76 3
        $container['orm.strategy.naming'] = $this->getOrmNamingStrategyDefinition($container);
77 3
        $container['orm.strategy.quote'] = $this->getOrmQuoteStrategyDefinition($container);
78 3
        $container['orm.entity_listener_resolver'] = $this->getOrmEntityListenerResolverDefinition($container);
79 3
        $container['orm.repository_factory'] = $this->getOrmRepositoryFactoryDefinition($container);
80 3
        $container['orm.second_level_cache.enabled'] = false;
81 3
        $container['orm.second_level_cache.configuration'] = $this->getOrmSecondLevelCacheConfigurationDefinition($container);
82 3
        $container['orm.default.query_hints'] = [];
83 3
        $container['orm.em'] = $this->getOrmEmDefinition($container);
84 3
        $container['orm.em.config'] = $this->getOrmEmConfigDefinition($container);
85 3
    }
86
87
    /**
88
     * @return array
89
     */
90 3
    private function getOrmEmDefaultOptions(): array
91
    {
92
        return [
93 3
            'connection' => 'default',
94
            'mappings' => [],
95
            'types' => [],
96
        ];
97
    }
98
99
    /**
100
     * @param Container $container
101
     *
102
     * @return \Closure
103
     */
104
    private function getOrmEmsOptionsInitializerDefinition(Container $container): \Closure
105
    {
106 3
        return $container->protect(function () use ($container) {
107 3
            static $initialized = false;
108
109 3
            if ($initialized) {
110 3
                return;
111
            }
112
113 3
            $initialized = true;
114
115 3
            if (!isset($container['orm.ems.options'])) {
116 2
                $container['orm.ems.options'] = [
117 2
                    'default' => isset($container['orm.em.options']) ? $container['orm.em.options'] : [],
118
                ];
119
            }
120
121 3
            $tmp = $container['orm.ems.options'];
122 3
            foreach ($tmp as $name => &$options) {
123 3
                $options = array_replace($container['orm.em.default_options'], $options);
124
125 3
                if (!isset($container['orm.ems.default'])) {
126 3
                    $container['orm.ems.default'] = $name;
127
                }
128
            }
129
130 3
            $container['orm.ems.options'] = $tmp;
131 3
        });
132
    }
133
134
    /**
135
     * @param Container $container
136
     *
137
     * @return \Closure
138
     */
139
    private function getOrmEmsDefinition(Container $container): \Closure
140
    {
141 3
        return function () use ($container) {
142 3
            $container['orm.ems.options.initializer']();
143
144 3
            $ems = new Container();
145 3
            foreach ($container['orm.ems.options'] as $name => $options) {
146 3
                if ($container['orm.ems.default'] === $name) {
147
                    // we use shortcuts here in case the default has been overridden
148 3
                    $config = $container['orm.em.config'];
149
                } else {
150 1
                    $config = $container['orm.ems.config'][$name];
151
                }
152
153 3
                $ems[$name] = function () use ($container, $options, $config) {
154 3
                    return EntityManager::create(
155 3
                        $container['dbs'][$options['connection']],
156 3
                        $config,
157 3
                        $container['dbs.event_manager'][$options['connection']]
158
                    );
159 3
                };
160
            }
161
162 3
            return $ems;
163 3
        };
164
    }
165
166
    /**
167
     * @param Container $container
168
     *
169
     * @return \Closure
170
     */
171
    private function getOrmEmsConfigServiceProvider(Container $container): \Closure
172
    {
173 3
        return function () use ($container) {
174 3
            $container['orm.ems.options.initializer']();
175
176 3
            $configs = new Container();
177 3
            foreach ($container['orm.ems.options'] as $name => $options) {
178 3
                $configs[$name] = $this->getOrmEmConfigByNameAndOptionsDefinition($container, $name, $options);
179
            }
180
181 3
            return $configs;
182 3
        };
183
    }
184
185
    /**
186
     * @param Container $container
187
     * @param string    $name
188
     * @param array     $options
189
     *
190
     * @return \Closure
191
     */
192
    private function getOrmEmConfigByNameAndOptionsDefinition(
193
        Container $container,
194
        string $name,
195
        array $options
196
    ): \Closure {
197 3
        return function () use ($container, $name, $options) {
198 3
            $config = new Configuration();
199
200 3
            $config->setProxyDir($container['orm.proxies_dir']);
201 3
            $config->setAutoGenerateProxyClasses($container['orm.auto_generate_proxies']);
202 3
            $config->setProxyNamespace($container['orm.proxies_namespace']);
203 3
            $config->setMetadataDriverImpl(
204 3
                $container['orm.mapping_driver_chain']($name, $config, (array) $options['mappings'])
205
            );
206 3
            $config->setQueryCacheImpl($container['orm.cache.locator']($name, 'query', $options));
207 3
            $config->setHydrationCacheImpl($container['orm.cache.locator']($name, 'hydration', $options));
208 3
            $config->setMetadataCacheImpl($container['orm.cache.locator']($name, 'metadata', $options));
209 3
            $config->setResultCacheImpl($container['orm.cache.locator']($name, 'result', $options));
210
211 3
            foreach ((array) $options['types'] as $typeName => $typeClass) {
212 1
                if (Type::hasType($typeName)) {
213 1
                    Type::overrideType($typeName, $typeClass);
214
                } else {
215 1
                    Type::addType($typeName, $typeClass);
216
                }
217
            }
218
219 3
            $config->setCustomStringFunctions($container['orm.custom.functions.string']);
220 3
            $config->setCustomNumericFunctions($container['orm.custom.functions.numeric']);
221 3
            $config->setCustomDatetimeFunctions($container['orm.custom.functions.datetime']);
222 3
            $config->setCustomHydrationModes($container['orm.custom.hydration_modes']);
223
224 3
            $config->setClassMetadataFactoryName($container['orm.class_metadata_factory_name']);
225 3
            $config->setDefaultRepositoryClassName($container['orm.default_repository_class']);
226
227 3
            $config->setNamingStrategy($container['orm.strategy.naming']);
228 3
            $config->setQuoteStrategy($container['orm.strategy.quote']);
229
230 3
            $config->setEntityListenerResolver($container['orm.entity_listener_resolver']);
231 3
            $config->setRepositoryFactory($container['orm.repository_factory']);
232
233 3
            $config->setSecondLevelCacheEnabled($container['orm.second_level_cache.enabled']);
234 3
            $config->setSecondLevelCacheConfiguration($container['orm.second_level_cache.configuration']);
235
236 3
            $config->setDefaultQueryHints($container['orm.default.query_hints']);
237
238 3
            return $config;
239 3
        };
240
    }
241
242
    /**
243
     * @param Container $container
244
     *
245
     * @return \Closure
246
     */
247
    private function getOrmMappingDriverChainDefinition(Container $container): \Closure
248
    {
249 3
        return $container->protect(function (string $name, Configuration $config, array $mappings) use ($container) {
250 3
            $container['orm.ems.options.initializer']();
251
252
            /** @var MappingDriverChain $chain */
253 3
            $chain = $container['orm.mapping_driver_chain.factory']();
254 3
            foreach ($mappings as $entity) {
255 2
                if (!is_array($entity)) {
256
                    throw new \InvalidArgumentException(
257
                        "The 'orm.em.options' option 'mappings' should be an array of arrays."
258
                    );
259
                }
260
261 2
                if (isset($entity['alias'])) {
262 1
                    $config->addEntityNamespace($entity['alias'], $entity['namespace']);
263
                }
264
265 2
                $factoryKey = sprintf('orm.mapping_driver.factory.%s', $entity['type']);
266 2
                if (!isset($container[$factoryKey])) {
267
                    throw new \InvalidArgumentException(
268
                        sprintf('There is no driver factory for type "%s"', $entity['type'])
269
                    );
270
                }
271
272 2
                $chain->addDriver($container[$factoryKey]($entity, $config), $entity['namespace']);
273
            }
274
275 3
            return $container['orm.mapping_driver_chain.instances.'.$name] = $chain;
276 3
        });
277
    }
278
279
    /**
280
     * @param Container $container
281
     *
282
     * @return \Closure
283
     */
284
    private function getOrmMappingDriverChainFactoryDefinition(Container $container): \Closure
285
    {
286 3
        return $container->protect(function () use ($container) {
287 3
            return new MappingDriverChain();
288 3
        });
289
    }
290
291
    /**
292
     * @param Container $container
293
     *
294
     * @return \Closure
295
     */
296
    private function getOrmMappingDriverFactoryAnnotation(Container $container): \Closure
297
    {
298 3
        return $container->protect(function (array $entity, Configuration $config) {
299 2
            $useSimpleAnnotationReader = $entity['use_simple_annotation_reader'] ?? true;
300
301 2
            return $config->newDefaultAnnotationDriver(
302 2
                (array) $entity['path'],
303 2
                $useSimpleAnnotationReader
304
            );
305 3
        });
306
    }
307
308
    /**
309
     * @param Container $container
310
     *
311
     * @return \Closure
312
     */
313
    private function getOrmMappingDriverFactoryYaml(Container $container): \Closure
314
    {
315 3
        return $container->protect(function (array $entity, Configuration $config) {
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
316 2
            return new YamlDriver($entity['path']);
317 3
        });
318
    }
319
320
    /**
321
     * @param Container $container
322
     *
323
     * @return \Closure
324
     */
325
    private function getOrmMappingDriverFactorySimpleYaml(Container $container): \Closure
326
    {
327 3
        return $container->protect(function (array $entity, Configuration $config) {
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
328 2
            return new SimplifiedYamlDriver([$entity['path'] => $entity['namespace']]);
329 3
        });
330
    }
331
332
    /**
333
     * @param Container $container
334
     *
335
     * @return \Closure
336
     */
337
    private function getOrmMappingDriverFactoryXml(Container $container): \Closure
338
    {
339 3
        return $container->protect(function (array $entity, Configuration $config) {
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
340 2
            return new XmlDriver($entity['path']);
341 3
        });
342
    }
343
344
    /**
345
     * @param Container $container
346
     *
347
     * @return \Closure
348
     */
349
    private function getOrmMappingDriverFactorySimpleXml(Container $container): \Closure
350
    {
351 3
        return $container->protect(function (array $entity, Configuration $config) {
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
352 2
            return new SimplifiedXmlDriver([$entity['path'] => $entity['namespace']]);
353 3
        });
354
    }
355
356
    /**
357
     * @param Container $container
358
     *
359
     * @return \Closure
360
     */
361
    private function getOrmMappingDriverFactoryPhp(Container $container): \Closure
362
    {
363 3
        return $container->protect(function (array $entity, Configuration $config) {
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
364 2
            return new StaticPHPDriver($entity['path']);
365 3
        });
366
    }
367
368
    /**
369
     * @param Container $container
370
     *
371
     * @return \Closure
372
     */
373
    private function getOrmCacheLocatorDefinition(Container $container): \Closure
374
    {
375 3
        return $container->protect(function (string $name, string $cacheName, array $options) use ($container) {
376 3
            $cacheNameKey = $cacheName.'_cache';
377
378 3
            if (!isset($options[$cacheNameKey])) {
379 2
                $options[$cacheNameKey] = $container['orm.default_cache'];
380
            }
381
382 3
            if (isset($options[$cacheNameKey]) && !is_array($options[$cacheNameKey])) {
383 2
                $options[$cacheNameKey] = [
384 2
                    'driver' => $options[$cacheNameKey],
385
                ];
386
            }
387
388 3
            if (!isset($options[$cacheNameKey]['driver'])) {
389
                throw new \RuntimeException("No driver specified for '$cacheName'");
390
            }
391
392 3
            $driver = $options[$cacheNameKey]['driver'];
393
394 3
            $cache = $container['orm.cache.factory']($driver, $options[$cacheNameKey]);
395
396 3
            if (isset($options['cache_namespace']) && $cache instanceof CacheProvider) {
397 1
                $cache->setNamespace($options['cache_namespace']);
398
            }
399
400 3
            return $container['orm.cache.instances.'.$name.'.'.$cacheName] = $cache;
401 3
        });
402
    }
403
404
    /**
405
     * @param Container $container
406
     *
407
     * @return \Closure
408
     */
409
    private function getOrmCacheFactoryDefinition(Container $container): \Closure
410
    {
411 3
        return $container->protect(function (string $driver, array $cacheOptions) use ($container) {
412 3
            $cacheFactoryKey = 'orm.cache.factory.'.$driver;
413 3
            if (!isset($container[$cacheFactoryKey])) {
414
                throw new \RuntimeException(
415
                    sprintf('Factory "%s" for cache type "%s" not defined', $cacheFactoryKey, $driver)
416
                );
417
            }
418
419 3
            return $container[$cacheFactoryKey]($cacheOptions);
420 3
        });
421
    }
422
423
    /**
424
     * @param Container $container
425
     *
426
     * @return \Closure
427
     */
428
    private function getOrmCacheFactoryApcuDefinition(Container $container): \Closure
429
    {
430 3
        return $container->protect(function (array $cacheOptions) use ($container) {
0 ignored issues
show
Unused Code introduced by
The parameter $cacheOptions is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
431 1
            return new ApcuCache();
432 3
        });
433
    }
434
435
    /**
436
     * @param Container $container
437
     *
438
     * @return \Closure
439
     */
440
    private function getOrmCacheFactoryArrayDefinition(Container $container): \Closure
441
    {
442 3
        return $container->protect(function (array $cacheOptions) use ($container) {
0 ignored issues
show
Unused Code introduced by
The parameter $cacheOptions is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
443 2
            return new ArrayCache();
444 3
        });
445
    }
446
447
    /**
448
     * @param Container $container
449
     *
450
     * @return \Closure
451
     */
452
    private function getOrmCacheFactoryFilesystemDefinition(Container $container): \Closure
453
    {
454 3
        return $container->protect(function (array $cacheOptions) {
455 1
            if (empty($cacheOptions['path'])) {
456
                throw new \RuntimeException('FilesystemCache path not defined');
457
            }
458
459
            $cacheOptions += [
460 1
                'extension' => FilesystemCache::EXTENSION,
461 1
                'umask' => 0002,
462
            ];
463
464 1
            return new FilesystemCache($cacheOptions['path'], $cacheOptions['extension'], $cacheOptions['umask']);
465 3
        });
466
    }
467
468
    /**
469
     * @param Container $container
470
     *
471
     * @return \Closure
472
     */
473
    private function getOrmCacheFactoryMemcachedDefinition(Container $container): \Closure
474
    {
475 3
        return $container->protect(function (array $cacheOptions) use ($container) {
476 1
            if (empty($cacheOptions['host']) || empty($cacheOptions['port'])) {
477
                throw new \RuntimeException('Host and port options need to be specified for memcached cache');
478
            }
479
480 1
            $memcached = new \Memcached();
481 1
            $memcached->addServer($cacheOptions['host'], $cacheOptions['port']);
482
483 1
            $cache = new MemcachedCache();
484 1
            $cache->setMemcached($memcached);
485
486 1
            return $cache;
487 3
        });
488
    }
489
490
    /**
491
     * @param Container $container
492
     *
493
     * @return \Closure
494
     */
495
    private function getOrmCacheFactoryRedisDefinition(Container $container): \Closure
496
    {
497 3
        return $container->protect(function (array $cacheOptions) use ($container) {
498 1
            if (empty($cacheOptions['host']) || empty($cacheOptions['port'])) {
499
                throw new \RuntimeException('Host and port options need to be specified for redis cache');
500
            }
501
502 1
            $redis = new \Redis();
503 1
            $redis->connect($cacheOptions['host'], $cacheOptions['port']);
504
505 1
            if (isset($cacheOptions['password'])) {
506 1
                $redis->auth($cacheOptions['password']);
507
            }
508
509 1
            $cache = new RedisCache();
510 1
            $cache->setRedis($redis);
511
512 1
            return $cache;
513 3
        });
514
    }
515
516
    /**
517
     * @param Container $container
518
     *
519
     * @return \Closure
520
     */
521
    private function getOrmCacheFactoryXCacheDefinition(Container $container): \Closure
522
    {
523 3
        return $container->protect(function (array $cacheOptions) use ($container) {
0 ignored issues
show
Unused Code introduced by
The parameter $cacheOptions is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
524 1
            return new XcacheCache();
525 3
        });
526
    }
527
528
    /**
529
     * @param Container $container
530
     *
531
     * @return \Closure
532
     */
533
    private function getOrmNamingStrategyDefinition(Container $container): \Closure
534
    {
535 3
        return function () use ($container) {
536 3
            return new DefaultNamingStrategy();
537 3
        };
538
    }
539
540
    /**
541
     * @param Container $container
542
     *
543
     * @return \Closure
544
     */
545
    private function getOrmQuoteStrategyDefinition(Container $container): \Closure
546
    {
547 3
        return function () use ($container) {
548 3
            return new DefaultQuoteStrategy();
549 3
        };
550
    }
551
552
    /**
553
     * @param Container $container
554
     *
555
     * @return \Closure
556
     */
557
    private function getOrmEntityListenerResolverDefinition(Container $container): \Closure
558
    {
559 3
        return function () use ($container) {
560 3
            return new DefaultEntityListenerResolver();
561 3
        };
562
    }
563
564
    /**
565
     * @param Container $container
566
     *
567
     * @return \Closure
568
     */
569
    private function getOrmRepositoryFactoryDefinition(Container $container): \Closure
570
    {
571 3
        return function () use ($container) {
572 3
            return new DefaultRepositoryFactory();
573 3
        };
574
    }
575
576
    /**
577
     * @param Container $container
578
     *
579
     * @return \Closure
580
     */
581
    private function getOrmSecondLevelCacheConfigurationDefinition(Container $container): \Closure
582
    {
583 3
        return function () use ($container) {
584 3
            return new CacheConfiguration();
585 3
        };
586
    }
587
588
    /**
589
     * @param Container $container
590
     *
591
     * @return \Closure
592
     */
593
    private function getOrmEmDefinition(Container $container): \Closure
594
    {
595 3
        return function () use ($container) {
596 3
            $ems = $container['orm.ems'];
597
598 3
            return $ems[$container['orm.ems.default']];
599 3
        };
600
    }
601
602
    /**
603
     * @param Container $container
604
     *
605
     * @return \Closure
606
     */
607
    private function getOrmEmConfigDefinition(Container $container): \Closure
608
    {
609 3
        return function () use ($container) {
610 3
            $configs = $container['orm.ems.config'];
611
612 3
            return $configs[$container['orm.ems.default']];
613 3
        };
614
    }
615
}
616