Skip to content
This repository has been archived by the owner on Mar 19, 2023. It is now read-only.

Commit

Permalink
Chore: Improvment on how checks theme
Browse files Browse the repository at this point in the history
  • Loading branch information
ceesvanegmond committed Nov 3, 2017
1 parent 456b394 commit 51b63a5
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions DependencyInjection/WearejustFormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use RuntimeException;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
Expand All @@ -25,7 +24,7 @@ public function load(array $configs, ContainerBuilder $container)
{
$loadedBundles = $container->getParameter('kernel.bundles');

if ($this->isWearejustSonataThemeLoaded($loadedBundles)) {
if ($this->isWearejustSonataThemeLoaded($container)) {
$this->guardAgainstInvalidOrderIfWearejustSonataTheme($loadedBundles);
}

Expand Down Expand Up @@ -54,12 +53,12 @@ public function load(array $configs, ContainerBuilder $container)
*/
public function prepend(ContainerBuilder $container)
{
$loadedBundles = $container->getParameter('kernel.bundles');

if (! $this->isWearejustSonataThemeLoaded($loadedBundles)) {
if (! $this->isWearejustSonataThemeLoaded($container)) {
return;
}

$loadedBundles = $container->getParameter('kernel.bundles');

$configs = $container->getExtensionConfig($this->getAlias());
$config = $this->processConfiguration(new Configuration(), $configs);

Expand All @@ -72,11 +71,9 @@ public function prepend(ContainerBuilder $container)
'extra_js_assets' => $assets['js']
];

try {
$container->getExtension('wearejust_sonata_theme');

if ($container->hasExtension('wearejust_sonata_theme')) {
$container->prependExtensionConfig('wearejust_sonata_theme', $assetConfig);
} catch (LogicException $e) {
}elseif ($container->hasExtension('just_sonata_theme')) {
$container->prependExtensionConfig('just_sonata_theme', $assetConfig);
}
}
Expand Down Expand Up @@ -164,12 +161,12 @@ private function guardAgainstInvalidOrderIfWearejustSonataTheme($loadedBundles)
}

/**
* @param array $bundles
* @param ContainerBuilder $container
*
* @return mixed
*/
private function isWearejustSonataThemeLoaded(array $bundles)
private function isWearejustSonataThemeLoaded(ContainerBuilder $container)
{
return array_key_exists('WearejustSonataThemeBundle', $bundles) || array_key_exists('JustSonataThemeBundle', $bundles);
return $container->hasExtension('wearejust_sonata_theme') || $container->hasExtension('just_sonata_theme');
}
}

0 comments on commit 51b63a5

Please sign in to comment.