@@ -43,17 +43,7 @@ public function load(array $configs, ContainerBuilder $container)
43
43
}
44
44
45
45
if ($ config ['admin_extensions ' ]['menu_options ' ]['enabled ' ]) {
46
- if (!isset ($ bundles ['SonataAdminBundle ' ])) {
47
- throw new InvalidConfigurationException ('To use menu options extionsion, you need sonata-project/SonataAdminBundle in your project. ' );
48
- }
49
-
50
- if ($ config ['admin_extensions ' ]['menu_options ' ]['advanced ' ] && !isset ($ bundles ['BurgovKeyValueFormBundle ' ])) {
51
- throw new InvalidConfigurationException ('To use advanced menu options, you need the burgov/key-value-bundle in your project. ' );
52
- }
53
-
54
- $ container ->setParameter ($ this ->getAlias () . '.admin_extensions.menu_options.advanced ' , $ config ['admin_extensions ' ]['menu_options ' ]['advanced ' ]);
55
-
56
- $ loader ->load ('admin-extension.xml ' );
46
+ $ this ->loadExtensions ($ config , $ loader , $ container );
57
47
}
58
48
59
49
if ($ config ['publish_workflow ' ]['enabled ' ]) {
@@ -132,6 +122,27 @@ public function loadSonataAdmin($config, XmlFileLoader $loader, ContainerBuilder
132
122
$ loader ->load ('admin.xml ' );
133
123
}
134
124
125
+ public function loadExtensions ($ config , XmlFileLoader $ loader , ContainerBuilder $ container )
126
+ {
127
+ $ bundles = $ container ->getParameter ('kernel.bundles ' );
128
+
129
+ if ('auto ' === $ config ['admin_extensions ' ]['menu_options ' ]['enabled ' ] && !isset ($ bundles ['SonataAdminBundle ' ])) {
130
+ return ;
131
+ }
132
+
133
+ if (!isset ($ bundles ['SonataAdminBundle ' ])) {
134
+ throw new InvalidConfigurationException ('To use menu options extionsion, you need sonata-project/SonataAdminBundle in your project. ' );
135
+ }
136
+
137
+ if ($ config ['admin_extensions ' ]['menu_options ' ]['advanced ' ] && !isset ($ bundles ['BurgovKeyValueFormBundle ' ])) {
138
+ throw new InvalidConfigurationException ('To use advanced menu options, you need the burgov/key-value-bundle in your project. ' );
139
+ }
140
+
141
+ $ container ->setParameter ($ this ->getAlias () . '.admin_extensions.menu_options.advanced ' , $ config ['admin_extensions ' ]['menu_options ' ]['advanced ' ]);
142
+
143
+ $ loader ->load ('admin-extension.xml ' );
144
+ }
145
+
135
146
/**
136
147
* Returns the base path for the XSD files.
137
148
*
0 commit comments