diff --git a/.travis.yml b/.travis.yml
index f637860..a9a4a7b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -36,7 +36,7 @@ matrix:
- php: 7.1
env: DEPENDENCIES=beta
allow_failures:
- - php: 5.6
+ - php: 7.2
env: SYMFONY_VERSION=@dev;ASSETIC=skip
before_install:
diff --git a/Controller/ThemeController.php b/Controller/ThemeController.php
index be9cd77..f7e62ce 100644
--- a/Controller/ThemeController.php
+++ b/Controller/ThemeController.php
@@ -36,7 +36,7 @@ class ThemeController
/**
* Options of the cookie to store active theme.
*
- * @var array
+ * @var array|null
*/
protected $cookieOptions;
@@ -45,9 +45,9 @@ class ThemeController
*
* @param ActiveTheme $activeTheme active theme instance
* @param array $themes Available themes
- * @param array $cookieOptions The options of the cookie we look for the theme to set
+ * @param array|null $cookieOptions The options of the cookie we look for the theme to set
*/
- public function __construct(ActiveTheme $activeTheme, array $themes, array $cookieOptions)
+ public function __construct(ActiveTheme $activeTheme, array $themes, array $cookieOptions = null)
{
$this->activeTheme = $activeTheme;
$this->themes = $themes;
@@ -74,19 +74,21 @@ public function switchAction(Request $request)
$this->activeTheme->setName($theme);
$url = $request->headers->get('Referer', '/');
+ $response = new RedirectResponse($url);
- $cookie = new Cookie(
- $this->cookieOptions['name'],
- $theme,
- time() + $this->cookieOptions['lifetime'],
- $this->cookieOptions['path'],
- $this->cookieOptions['domain'],
- (bool) $this->cookieOptions['secure'],
- (bool) $this->cookieOptions['http_only']
- );
+ if (!empty($this->cookieOptions)) {
+ $cookie = new Cookie(
+ $this->cookieOptions['name'],
+ $theme,
+ time() + $this->cookieOptions['lifetime'],
+ $this->cookieOptions['path'],
+ $this->cookieOptions['domain'],
+ (bool) $this->cookieOptions['secure'],
+ (bool) $this->cookieOptions['http_only']
+ );
- $response = new RedirectResponse($url);
- $response->headers->setCookie($cookie);
+ $response->headers->setCookie($cookie);
+ }
return $response;
}
diff --git a/DependencyInjection/Compiler/TemplateResourcesPass.php b/DependencyInjection/Compiler/TemplateResourcesPass.php
index 0e549ab..59f8c02 100644
--- a/DependencyInjection/Compiler/TemplateResourcesPass.php
+++ b/DependencyInjection/Compiler/TemplateResourcesPass.php
@@ -48,10 +48,6 @@ public function process(ContainerBuilder $container)
protected function setBundleDirectoryResources(ContainerBuilder $container, $engine, $bundleDirName, $bundleName)
{
- if (!$container->hasDefinition('assetic.'.$engine.'_directory_resource.'.$bundleName)) {
- throw new LogicException('The LiipThemeBundle must be registered after the AsseticBundle in the application Kernel.');
- }
-
$resources = $container->getDefinition('assetic.'.$engine.'_directory_resource.'.$bundleName)->getArgument(0);
$themes = $container->getParameter('liip_theme.themes');
foreach ($themes as $theme) {
@@ -70,10 +66,6 @@ protected function setBundleDirectoryResources(ContainerBuilder $container, $eng
protected function setAppDirectoryResources(ContainerBuilder $container, $engine)
{
- if (!$container->hasDefinition('assetic.'.$engine.'_directory_resource.kernel')) {
- throw new LogicException('The LiipThemeBundle must be registered after the AsseticBundle in the application Kernel.');
- }
-
$themes = $container->getParameter('liip_theme.themes');
foreach ($themes as $key => $theme) {
$themes[$key] = $container->getParameter('kernel.root_dir').'/Resources/themes/'.$theme;
diff --git a/Resources/meta/LICENSE b/LICENSE
similarity index 100%
rename from Resources/meta/LICENSE
rename to LICENSE
diff --git a/LiipThemeBundle.php b/LiipThemeBundle.php
index 1e979a7..e38fb65 100644
--- a/LiipThemeBundle.php
+++ b/LiipThemeBundle.php
@@ -11,6 +11,7 @@
namespace Liip\ThemeBundle;
+use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Liip\ThemeBundle\DependencyInjection\Compiler\ThemeCompilerPass;
@@ -22,8 +23,9 @@ class LiipThemeBundle extends Bundle
public function build(ContainerBuilder $container)
{
parent::build($container);
- $container->addCompilerPass(new ThemeCompilerPass());
- $container->addCompilerPass(new TemplateResourcesPass());
- $container->addCompilerPass(new AsseticTwigFormulaPass());
+
+ $container->addCompilerPass(new ThemeCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 100);
+ $container->addCompilerPass(new TemplateResourcesPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10);
+ $container->addCompilerPass(new AsseticTwigFormulaPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10);
}
}
diff --git a/Resources/config/controller.xml b/Resources/config/controller.xml
index c440c9d..f027a9e 100755
--- a/Resources/config/controller.xml
+++ b/Resources/config/controller.xml
@@ -4,12 +4,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-
- Liip\ThemeBundle\Controller\ThemeController
-
-
-
+
%liip_theme.themes%
%liip_theme.cookie%
diff --git a/Resources/config/templating.xml b/Resources/config/templating.xml
index b106f8f..c17f194 100644
--- a/Resources/config/templating.xml
+++ b/Resources/config/templating.xml
@@ -4,37 +4,31 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
- Liip\ThemeBundle\Locator\TemplateLocator
- Liip\ThemeBundle\Locator\FileLocator
Liip\ThemeBundle\Twig\Loader\FilesystemLoader
- Liip\ThemeBundle\ActiveTheme
- Liip\ThemeBundle\CacheWarmer\TemplatePathsCacheWarmer
- Liip\ThemeBundle\Helper\DeviceDetection
- Liip\ThemeBundle\CacheWarmer\TemplateFinder
-
+
-
+
%kernel.root_dir%/Resources
-
+
%kernel.cache_dir%
-
+
%kernel.root_dir%/Resources
@@ -42,9 +36,9 @@
%liip_theme.path_patterns%
-
+
-
+
%liip_theme.active_theme%
%liip_theme.themes%
diff --git a/Resources/config/theme_request_listener.xml b/Resources/config/theme_request_listener.xml
index 1213f48..61f2753 100644
--- a/Resources/config/theme_request_listener.xml
+++ b/Resources/config/theme_request_listener.xml
@@ -4,12 +4,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-
- Liip\ThemeBundle\EventListener\ThemeRequestListener
-
-
-
+
%liip_theme.cookie%
diff --git a/Tests/DependencyInjection/Compiler/ThemeCompilerPassTest.php b/Tests/DependencyInjection/Compiler/ThemeCompilerPassTest.php
index b239d18..72e5701 100644
--- a/Tests/DependencyInjection/Compiler/ThemeCompilerPassTest.php
+++ b/Tests/DependencyInjection/Compiler/ThemeCompilerPassTest.php
@@ -23,8 +23,8 @@ public function testProcess()
->method('getParameter')
->will($this->returnValueMap(
array(
- array('liip_theme.cache_warming', true),
- array('liip_theme.filesystem_loader.class', 'Liip\ThemeBundle\Twig\Loader\FilesystemLoader'),
+ array('liip_theme.cache_warming', true),
+ array('liip_theme.filesystem_loader.class', 'Liip\ThemeBundle\Twig\Loader\FilesystemLoader'),
)
)
)