Skip to content

Commit

Permalink
add cache directory
Browse files Browse the repository at this point in the history
  • Loading branch information
KuiKui committed Oct 25, 2011
1 parent 2262293 commit 4c0728f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions cache/.gitignore
@@ -0,0 +1 @@
*
43 changes: 43 additions & 0 deletions lib/task/cacheClearTask.class.php
@@ -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.