Skip to content

Commit a7159f4

Browse files
committed
Fix a crash when Netgen Tags Bundle is installed but not activated
1 parent 157362a commit a7159f4

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Netgen Admin UI Bundle changelog
22

3+
## 2.1.1 (21.12.2017)
4+
5+
* Fix a crash when Netgen Tags Bundle is installed but not activated
6+
37
## 2.1.0 (14.12.2017)
48

59
* Mark all services as private/public for compatibility with Symfony 3.4

DependencyInjection/NetgenAdminUIExtension.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ public function load(array $configs, ContainerBuilder $container)
3030
$loader->load('controllers.yml');
3131
$loader->load('services.yml');
3232

33-
$activatedBundles = array_keys($container->getParameter('kernel.bundles'));
33+
$activatedBundles = $container->getParameter('kernel.bundles');
3434

35-
if (!in_array('EzCoreExtraBundle', $activatedBundles, true)) {
35+
if (!array_key_exists('EzCoreExtraBundle', $activatedBundles)) {
3636
throw new RuntimeException('Netgen Admin UI Bundle requires EzCoreExtraBundle (lolautruche/ez-core-extra-bundle) to be activated to work properly.');
3737
}
3838

39-
if (class_exists('Netgen\TagsBundle\Version') && TagsBundleVersion::MAJOR_VERSION >= 3) {
39+
if ($this->hasTags($activatedBundles)) {
4040
$loader->load('tags/services.yml');
4141
}
4242

43-
if ($this->hasLayouts($container)) {
43+
if ($this->hasLayouts($activatedBundles)) {
4444
$loader->load('layouts/controllers.yml');
4545
}
4646

@@ -61,7 +61,7 @@ public function prepend(ContainerBuilder $container)
6161
'framework/twig.yml' => 'twig',
6262
);
6363

64-
if ($this->hasLayouts($container)) {
64+
if ($this->hasLayouts($container->getParameter('kernel.bundles'))) {
6565
$configs['layouts/view.yml'] = 'netgen_block_manager';
6666
}
6767

@@ -76,11 +76,11 @@ public function prepend(ContainerBuilder $container)
7676
/**
7777
* Returns if Netgen Layouts is active or not.
7878
*
79-
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
79+
* @param array $activatedBundles
8080
*
8181
* @return bool
8282
*/
83-
protected function hasLayouts(ContainerBuilder $container)
83+
protected function hasLayouts(array $activatedBundles)
8484
{
8585
if (!class_exists('Netgen\BlockManager\Version')) {
8686
return false;
@@ -90,8 +90,26 @@ protected function hasLayouts(ContainerBuilder $container)
9090
return false;
9191
}
9292

93-
$activatedBundles = $container->getParameter('kernel.bundles');
94-
9593
return array_key_exists('NetgenBlockManagerBundle', $activatedBundles);
9694
}
95+
96+
/**
97+
* Returns if Netgen Tags v3+ is active or not.
98+
*
99+
* @param array $activatedBundles
100+
*
101+
* @return bool
102+
*/
103+
protected function hasTags(array $activatedBundles)
104+
{
105+
if (!class_exists('Netgen\TagsBundle\Version')) {
106+
return false;
107+
}
108+
109+
if (TagsBundleVersion::MAJOR_VERSION < 3) {
110+
return false;
111+
}
112+
113+
return array_key_exists('NetgenTagsBundle', $activatedBundles);
114+
}
97115
}

0 commit comments

Comments
 (0)