diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml
index 96e5941cd..198c49228 100755
--- a/core/lib/Thelia/Config/Resources/config.xml
+++ b/core/lib/Thelia/Config/Resources/config.xml
@@ -129,6 +129,7 @@
+ %kernel.environment%
diff --git a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php
index fbb93440a..cd7f06ac8 100755
--- a/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php
+++ b/core/lib/Thelia/Core/Template/Assets/AsseticHelper.php
@@ -43,15 +43,16 @@ class AsseticHelper
* Generates assets from $asset_path in $output_path, using $filters.
*
* @param string $asset_path the full path to the asset file (or file collection)
- * @param unknown $output_path the full disk path to the output directory (shoud be visible to web server)
- * @param unknown $output_url the URL to the generated asset directory
- * @param unknown $asset_type the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension.
- * @param unknown $filters a list of filters, as defined below (see switch($filter_name) ...)
- * @param unknown $debug true / false
+ * @param string $output_path the full disk path to the output directory (shoud be visible to web server)
+ * @param string $output_url the URL to the generated asset directory
+ * @param string $asset_type the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension.
+ * @param array $filters a list of filters, as defined below (see switch($filter_name) ...)
+ * @param boolean $debug true / false
+ * @param boolean $dev_mode true / false. If true, assets are not cached and always compiled.
* @throws \InvalidArgumentException if an invalid filter name is found
* @return string The URL to the generated asset file.
*/
- public function asseticize($asset_path, $output_path, $output_url, $asset_type, $filters, $debug)
+ public function asseticize($asset_path, $output_path, $output_url, $asset_type, $filters, $debug, $dev_mode = false)
{
$asset_name = basename($asset_path);
$asset_dir = dirname($asset_path);
@@ -112,6 +113,7 @@ class AsseticHelper
$asset = $factory->createAsset($asset_name);
$asset_target_path = $asset->getTargetPath();
+
$target_file = sprintf("%s/%s", $output_path, $asset_target_path);
// As it seems that assetic cannot handle a real file cache, let's do the job ourselves.
@@ -124,7 +126,7 @@ class AsseticHelper
//
// before generating 3bc974a-ad3ef47.css, delete 3bc974a-* files.
//
- if (! file_exists($target_file)) {
+ if ($dev_mode == true || ! file_exists($target_file)) {
// Delete previous version of the file
list($commonPart, $dummy) = explode('-', $asset_target_path);
@@ -143,8 +145,6 @@ class AsseticHelper
}
}
- //$cache = new AssetCache($asset, new FilesystemCache($output_path));
-
$writer = new AssetWriter($output_path);
$writer->writeAsset($asset);
diff --git a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php
index 17fe122d3..f19eded95 100755
--- a/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php
+++ b/core/lib/Thelia/Core/Template/Smarty/Assets/SmartyAssetsManager.php
@@ -34,18 +34,22 @@ class SmartyAssetsManager
private $web_root;
private $path_relative_to_web_root;
+ private $developmentMode;
/**
* Creates a new SmartyAssetsManager instance
*
- * @param string $web_root the disk path to the web root
- * @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated
+ * @param string $web_root the disk path to the web root
+ * @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated
+ * @param boolean $developmentMode true / false. If true, assets are not cached, and always generated.
*/
- public function __construct($web_root, $path_relative_to_web_root)
+ public function __construct($web_root, $path_relative_to_web_root, $developmentMode)
{
$this->web_root = $web_root;
$this->path_relative_to_web_root = $path_relative_to_web_root;
+ $this->developmentMode = $developmentMode;
+
$this->assetic_manager = new AsseticHelper();
}
@@ -73,7 +77,8 @@ class SmartyAssetsManager
URL::getInstance()->absoluteUrl($this->path_relative_to_web_root, null, URL::PATH_TO_FILE /* path only */),
$assetType,
$filters,
- $debug
+ $debug,
+ $this->developmentMode
);
return $url;
diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php
index f8ea1c2ef..b7bb95b83 100755
--- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php
+++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Assetic.php
@@ -32,13 +32,13 @@ class Assetic extends AbstractSmartyPlugin
{
public $assetManager;
- public function __construct()
+ public function __construct($developmentMode)
{
$web_root = THELIA_WEB_DIR;
$asset_dir_from_web_root = ConfigQuery::read('asset_dir_from_web_root', 'assets');
- $this->assetManager = new SmartyAssetsManager($web_root, $asset_dir_from_web_root);
+ $this->assetManager = new SmartyAssetsManager($web_root, $asset_dir_from_web_root, $developmentMode == 'dev');
}
public function blockJavascripts($params, $content, \Smarty_Internal_Template $template, &$repeat)
diff --git a/templates/admin/default/assets/less/main.less b/templates/admin/default/assets/less/main.less
index 862810f6d..7ad14e013 100644
--- a/templates/admin/default/assets/less/main.less
+++ b/templates/admin/default/assets/less/main.less
@@ -3,6 +3,4 @@
/* Thelia Admin */
@import "thelia/thelia.less";
-// @import "thelia/responsive.less";
-
-//mmm
\ No newline at end of file
+// @import "thelia/responsive.less";
\ No newline at end of file