diff --git a/CHANGELOG.md b/CHANGELOG.md index 17e5a13f..8ffb2d81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Netgen Admin UI Bundle changelog +## 2.1.1 (21.12.2017) + +* Fix a crash when Netgen Tags Bundle is installed but not activated + ## 2.1.0 (14.12.2017) * Mark all services as private/public for compatibility with Symfony 3.4 diff --git a/DependencyInjection/NetgenAdminUIExtension.php b/DependencyInjection/NetgenAdminUIExtension.php index e8dba099..0927e682 100644 --- a/DependencyInjection/NetgenAdminUIExtension.php +++ b/DependencyInjection/NetgenAdminUIExtension.php @@ -30,17 +30,17 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('controllers.yml'); $loader->load('services.yml'); - $activatedBundles = array_keys($container->getParameter('kernel.bundles')); + $activatedBundles = $container->getParameter('kernel.bundles'); - if (!in_array('EzCoreExtraBundle', $activatedBundles, true)) { + if (!array_key_exists('EzCoreExtraBundle', $activatedBundles)) { throw new RuntimeException('Netgen Admin UI Bundle requires EzCoreExtraBundle (lolautruche/ez-core-extra-bundle) to be activated to work properly.'); } - if (class_exists('Netgen\TagsBundle\Version') && TagsBundleVersion::MAJOR_VERSION >= 3) { + if ($this->hasTags($activatedBundles)) { $loader->load('tags/services.yml'); } - if ($this->hasLayouts($container)) { + if ($this->hasLayouts($activatedBundles)) { $loader->load('layouts/controllers.yml'); } @@ -61,7 +61,7 @@ public function prepend(ContainerBuilder $container) 'framework/twig.yml' => 'twig', ); - if ($this->hasLayouts($container)) { + if ($this->hasLayouts($container->getParameter('kernel.bundles'))) { $configs['layouts/view.yml'] = 'netgen_block_manager'; } @@ -76,11 +76,11 @@ public function prepend(ContainerBuilder $container) /** * Returns if Netgen Layouts is active or not. * - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container + * @param array $activatedBundles * * @return bool */ - protected function hasLayouts(ContainerBuilder $container) + protected function hasLayouts(array $activatedBundles) { if (!class_exists('Netgen\BlockManager\Version')) { return false; @@ -90,8 +90,26 @@ protected function hasLayouts(ContainerBuilder $container) return false; } - $activatedBundles = $container->getParameter('kernel.bundles'); - return array_key_exists('NetgenBlockManagerBundle', $activatedBundles); } + + /** + * Returns if Netgen Tags v3+ is active or not. + * + * @param array $activatedBundles + * + * @return bool + */ + protected function hasTags(array $activatedBundles) + { + if (!class_exists('Netgen\TagsBundle\Version')) { + return false; + } + + if (TagsBundleVersion::MAJOR_VERSION < 3) { + return false; + } + + return array_key_exists('NetgenTagsBundle', $activatedBundles); + } }