Added code to flush on build

Replaced unnecessary references to ?flush=1 and ?flush=all.
Added code to enable the build task to also flush.
This commit is contained in:
Michael Bollig 2014-08-22 12:04:45 +08:00
parent d85ecaa655
commit 8af231cf7f
3 changed files with 20 additions and 3 deletions

View File

@ -7,4 +7,7 @@ LeftAndMain:
- 'betternavigator/javascript/BN.LeftAndMain.Preview.js'
ContentController:
extensions:
- BetterNavigator
- BetterNavigator
DevelopmentAdmin:
extensions:
- FlushOnDevBuild

14
code/FlushOnDevBuild.php Executable file
View File

@ -0,0 +1,14 @@
<?php
/**
* via swaiba https://groups.google.com/d/msg/silverstripe-dev/RNWCiFAnRI0/bABhA5Otnl4J
*/
class FlushOnDevBuild extends Extension {
function beforeCallActionHandler($request,$action){
if(!$this->owner->response->isFinished() && $action=='build' && $request->getVar('flush')){
SS_TemplateLoader::instance()->getManifest()->regenerate(true);
SSViewer::flush_template_cache();
}
}
}

View File

@ -53,8 +53,8 @@
<a href="$Link?isDev=1"><span class="bn-icon-devmode"></span>Dev Mode</a>
<% end_if %>
<a href="$Link?flush=all"><span class="bn-icon-flush"></span>Flush Templates</a>
<a href="/dev/build/?flush=1" target="_blank"><span class="bn-icon-db"></span>Build Database</a>
<a href="$Link?flush"><span class="bn-icon-flush"></span>Flush</a>
<a href="/dev/build/" target="_blank"><span class="bn-icon-db"></span>Build &amp Flush</a>
<a href="/dev/" target="_blank"><span class="bn-icon-tools"></span>Dev Menu</a>
</div>