[icinga-checkins] icinga.org: icinga-web/jmosshammer/default: * Changed clear cache to agavi way

git at icinga.org git at icinga.org
Tue Jun 28 18:55:02 CEST 2011


Module: icinga-web
Branch: jmosshammer/default
Commit: a216431bb4af0d8b1c927d1c73f32747e42ab579
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=a216431bb4af0d8b1c927d1c73f32747e42ab579

Author: Marius Hein <marius.hein at netways.de>
Date:   Sun Jun 26 12:06:27 2011 +0200

* Changed clear cache to agavi way

---

 Makefile.in                                        |    3 +-
 .../AppKit/models/Tasks/ClearCacheModel.class.php  |   47 ++------------------
 app/modules/Cronks/config/cronks.xml               |    4 +-
 app/modules/Cronks/config/cronks_categories.xml    |    4 +-
 etc/build.xml                                      |    6 +++
 etc/lib/agaviClearCache.php                        |   12 +++++
 6 files changed, 27 insertions(+), 49 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index fcefd4c..60026e8 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -96,8 +96,7 @@ locclean:
 		$(LOC_MO)/*.json
 
 cacheclean:
-	rm -rf app/cache/config/*.php
-	rm -rf app/cache/content
+	$(PHING_CALL) agavi-clear-cache	
 
 distclean:
 	rm -rf \
diff --git a/app/modules/AppKit/models/Tasks/ClearCacheModel.class.php b/app/modules/AppKit/models/Tasks/ClearCacheModel.class.php
index 7fe48d1..ec5a27a 100644
--- a/app/modules/AppKit/models/Tasks/ClearCacheModel.class.php
+++ b/app/modules/AppKit/models/Tasks/ClearCacheModel.class.php
@@ -3,50 +3,11 @@
 class AppKit_Tasks_ClearCacheModel extends AppKitBaseModel {
 
     public function clearCache() {
-        $cache_dir = AgaviConfig::get('core.cache_dir');
-
-        $content_dir = $cache_dir. '/content';
-
-        if (is_dir($content_dir)) {
-            $config_count = $this->removeFilesRecursive($content_dir);
-            $this->getContext()->getLoggerManager()->log(sprintf('ClearCache: Deleted %d cache (content) objects', $config_count), AgaviLogger::INFO);
-        }
-
-        $config_files = glob($cache_dir. '/config/*.php', GLOB_NOSORT);
-        $config_count = count($config_files);
-
-        if ($config_count > 0) {
-            foreach($config_files as $config_file) {
-                unlink($config_file);
-            }
-            $this->getContext()->getLoggerManager()->log(sprintf('ClearCache: Deleted %d cache (config) files', $config_count), AgaviLogger::INFO);
-        }
+        AgaviToolkit::clearCache();
+        $this->log('Cache cleared through webinterface', AgaviLogger::INFO);
+        return true;
     }
-
-    private function removeFilesRecursive($path) {
-        $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
-
-        $order = array();
-
-        foreach($iterator as $fileObject) {
-            $order[] =$fileObject->getRealPath();
-        }
-
-        $count = count($order);
-
-        while (($file = array_pop($order))) {
-            if (is_dir($file)) {
-                rmdir($file);
-            }
-
-            elseif(is_file($file)) {
-                unlink($file);
-            }
-        }
-
-        return $count;
-    }
-
+    
 }
 
 ?>
\ No newline at end of file
diff --git a/app/modules/Cronks/config/cronks.xml b/app/modules/Cronks/config/cronks.xml
index 14f8e25..2b3c97b 100755
--- a/app/modules/Cronks/config/cronks.xml
+++ b/app/modules/Cronks/config/cronks.xml
@@ -49,8 +49,8 @@
 	</ae:configuration>
 	
 	<!-- Include the site config file *NEVER REMOVE THIS LINE* -->
-	<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="cronks.site.xml" xpointer="xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(cronk=http://icinga.org/cronks/config/parts/cronks/1.0) xpointer(//ae:configurations/ae:configuration)">
+	<!-- <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="cronks.site.xml" xpointer="xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(cronk=http://icinga.org/cronks/config/parts/cronks/1.0) xpointer(//ae:configurations/ae:configuration)">
 		<xi:fallback></xi:fallback>
-	</xi:include>
+	</xi:include>  -->
 	
 </ae:configurations>
diff --git a/app/modules/Cronks/config/cronks_categories.xml b/app/modules/Cronks/config/cronks_categories.xml
index b2c42cf..e0dde27 100644
--- a/app/modules/Cronks/config/cronks_categories.xml
+++ b/app/modules/Cronks/config/cronks_categories.xml
@@ -36,9 +36,9 @@
 			</category>
 			
 			<!-- Include the site config file *NEVER REMOVE THIS LINE* -->
-			<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="cronks.site.xml" xpointer="xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(cronk=http://icinga.org/cronks/config/parts/cronks/1.0) xpointer(//ae:configurations/ae:configuration/cronk:categories/cronk:category)">
+			<!-- <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="cronks.site.xml" xpointer="xmlns(ae=http://agavi.org/agavi/config/global/envelope/1.0) xmlns(cronk=http://icinga.org/cronks/config/parts/cronks/1.0) xpointer(//ae:configurations/ae:configuration/cronk:categories/cronk:category)">
 				<xi:fallback></xi:fallback>
-			</xi:include>
+			</xi:include> -->
 		
 		</categories>
 	</ae:configuration>
diff --git a/etc/build.xml b/etc/build.xml
index ce9e779..0ab55ac 100755
--- a/etc/build.xml
+++ b/etc/build.xml
@@ -45,6 +45,12 @@
 		</if>
 		
 	</target>
+	
+	<target name="agavi-clear-cache">
+		<taskdef name="agaviClearCache" classname="etc.lib..agaviClearCache"/>
+		<agaviClearCache />
+    </target>
+
 
 	<target name="db-prepare" depends="prepare">
 		<taskdef name="agaviDBExtractor" classname="etc.lib.agaviDBExtractorTask"/>	
diff --git a/etc/lib/agaviClearCache.php b/etc/lib/agaviClearCache.php
new file mode 100644
index 0000000..d5ca2d9
--- /dev/null
+++ b/etc/lib/agaviClearCache.php
@@ -0,0 +1,12 @@
+<?php
+
+require_once(dirname(__FILE__)."/agaviConsoleTask.php");
+
+class agaviClearCache extends agaviConsoleTask {
+    
+    public function main() {
+        parent::main();
+        AgaviToolkit::clearCache();
+    }
+    
+}
\ No newline at end of file





More information about the icinga-checkins mailing list