Permalink
Browse files

add cache directory

  • Loading branch information...
1 parent 2262293 commit 4c0728f4d0a9036e6b91728bf8d26bff4d7a0b88 @KuiKui KuiKui committed Oct 25, 2011
Showing with 44 additions and 0 deletions.
  1. +1 −0 cache/.gitignore
  2. +43 −0 lib/task/cacheClearTask.class.php
View
@@ -0,0 +1 @@
+*
@@ -0,0 +1,43 @@
+<?php
+
+class cacheClearTask extends sfBaseTask
+{
+ /**
+ * @return void
+ */
+ protected function configure()
+ {
+ $this->namespace = 'crew';
+ $this->name = 'clear-cache';
+ $this->aliases = array('ccc');
+ $this->briefDescription = 'Complete removal of cache (.gitignore file is not erased)';
+ }
+
+ /**
+ * @param array $arguments
+ * @param array $options
+ * @return int
+ */
+ protected function execute($arguments = array(), $options = array())
+ {
+ if (!sfConfig::get('sf_cache_dir') || !is_dir(sfConfig::get('sf_cache_dir')))
+ {
+ throw new sfException(sprintf('Cache directory "%s" does not exist.', sfConfig::get('sf_cache_dir')));
+ }
+
+ try
+ {
+ $this->getFilesystem()->remove(sfFinder::type('any')
+ ->discard('.sf')
+ ->discard('.gitignore')
+ ->in(sfConfig::get('sf_cache_dir'))
+ );
+ }
+ catch(Exception $e)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
+}

0 comments on commit 4c0728f

Please sign in to comment.