Added process_assets config variable

This commit is contained in:
franck
2013-09-11 12:14:39 +02:00
parent 9473f2752f
commit ae786f2139
2 changed files with 22 additions and 18 deletions

View File

@@ -29,6 +29,7 @@ use Assetic\Filter;
use Assetic\Factory\AssetFactory; use Assetic\Factory\AssetFactory;
use Assetic\Factory\Worker\CacheBustingWorker; use Assetic\Factory\Worker\CacheBustingWorker;
use Assetic\AssetWriter; use Assetic\AssetWriter;
use Thelia\Model\ConfigQuery;
/** /**
* This class is a simple helper for generating assets using Assetic. * This class is a simple helper for generating assets using Assetic.
@@ -124,27 +125,30 @@ class AsseticHelper
// //
// before generating 3bc974a-ad3ef47.css, delete 3bc974a-* files. // before generating 3bc974a-ad3ef47.css, delete 3bc974a-* files.
// //
if (/*$dev_mode == true || */! file_exists($target_file)) { if ($dev_mode == true || ! file_exists($target_file)) {
// Delete previous version of the file if (ConfigQuery::read('process_assets', true)) {
list($commonPart, $dummy) = explode('-', $asset_target_path);
foreach (glob("$output_path/$commonPart-*") as $filename) { // Delete previous version of the file
@unlink($filename); list($commonPart, $dummy) = explode('-', $asset_target_path);
}
// Apply filters now foreach (glob("$output_path/$commonPart-*") as $filename) {
foreach ($filter_list as $filter) { @unlink($filename);
if ('?' != $filter[0]) {
$asset->ensureFilter($fm->get($filter));
} elseif (!$debug) {
$asset->ensureFilter($fm->get(substr($filter, 1)));
} }
// Apply filters now
foreach ($filter_list as $filter) {
if ('?' != $filter[0]) {
$asset->ensureFilter($fm->get($filter));
} elseif (!$debug) {
$asset->ensureFilter($fm->get(substr($filter, 1)));
}
}
$writer = new AssetWriter($output_path);
$writer->writeAsset($asset);
} }
$writer = new AssetWriter($output_path);
$writer->writeAsset($asset);
} }
return rtrim($output_url, '/').'/'.$asset_target_path; return rtrim($output_url, '/').'/'.$asset_target_path;

View File

@@ -17,8 +17,8 @@ INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updat
('image_cache_dir_from_web_root', 'cache/images', 0, 0, NOW(), NOW()), ('image_cache_dir_from_web_root', 'cache/images', 0, 0, NOW(), NOW()),
('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()), ('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml', 0, 0, NOW(), NOW()),
('page_not_found_view', '404.html', 0, 0, NOW(), NOW()), ('page_not_found_view', '404.html', 0, 0, NOW(), NOW()),
('use_tax_free_amounts', 1, 1, 0, NOW(), NOW()); ('use_tax_free_amounts', '1', 0, 0, NOW(), NOW());
('process_assets', '1', 0, 0, NOW(), NOW());
INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namespace`, `created_at`, `updated_at`) VALUES
(1, 'DebugBar', 1, 1, 1, 'DebugBar\\DebugBar', NOW(), NOW()); (1, 'DebugBar', 1, 1, 1, 'DebugBar\\DebugBar', NOW(), NOW());