API Enable requirements to persist between flushes

This commit is contained in:
Damian Mooyman 2016-05-12 12:46:30 +12:00
parent 06f0f558d4
commit 7041c5945c
2 changed files with 18 additions and 1 deletions

View File

@ -130,6 +130,9 @@ the third paramter of the `combine_files` function:
Requirements::combine_files('print.css', $printStylesheets, 'print');
By default, all requirements files are flushed (deleted) when ?flush querystring parameter is set.
This can be disabled by setting the `Requirements.disable_flush_combined` config to `true`.
## Clearing assets
:::php

View File

@ -8,11 +8,25 @@
*/
class Requirements implements Flushable {
/**
* Flag whether combined files should be deleted on flush.
*
* By default all combined files are deleted on flush. If combined files are stored in source control,
* and thus updated manually, you might want to turn this on to disable this behaviour.
*
* @config
* @var bool
*/
private static $disable_flush_combined = false;
/**
* Triggered early in the request when a flush is requested
*/
public static function flush() {
self::delete_all_combined_files();
$disabled = Config::inst()->get(__CLASS__, 'disable_flush_combined');
if(!$disabled) {
self::delete_all_combined_files();
}
}
/**