Skip to content

Commit 52a2153

Browse files
NGSTACK-1017 register bundle Doctrine mapping via prepend to support auto_mapping=false
1 parent d496c38 commit 52a2153

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/DependencyInjection/NetgenApiPlatformExtrasExtension.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
use Symfony\Component\Config\Definition\ConfigurationInterface;
88
use Symfony\Component\DependencyInjection\ContainerBuilder;
99
use Symfony\Component\DependencyInjection\Extension\Extension;
10+
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
1011

12+
use function dirname;
1113
use function in_array;
1214
use function is_array;
1315

14-
final class NetgenApiPlatformExtrasExtension extends Extension
16+
final class NetgenApiPlatformExtrasExtension extends Extension implements PrependExtensionInterface
1517
{
1618
private const array SCALAR_ARRAY_PARAMS = [
1719
'ignored_routes',
@@ -29,6 +31,29 @@ public function load(array $configs, ContainerBuilder $container): void
2931
$this->setParameters($container, $config, $this->getAlias());
3032
}
3133

34+
public function prepend(ContainerBuilder $container): void
35+
{
36+
if (!$container->hasExtension('doctrine')) {
37+
return;
38+
}
39+
40+
$container->prependExtensionConfig(
41+
'doctrine',
42+
[
43+
'orm' => [
44+
'mappings' => [
45+
'NetgenApiPlatformExtras' => [
46+
'type' => 'xml',
47+
'is_bundle' => false,
48+
'dir' => dirname(__DIR__, 2) . '/config/doctrine',
49+
'prefix' => 'Netgen\ApiPlatformExtras\Entity',
50+
],
51+
],
52+
],
53+
],
54+
);
55+
}
56+
3257
/**
3358
* @param mixed[] $config
3459
*/

0 commit comments

Comments
 (0)