Created
October 18, 2011 12:21
-
-
Save junichi11/1295294 to your computer and use it in GitHub Desktop.
Clear Cache Shell for CakePHP2.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* CakePHP ClearCacheShell for 2.0 | |
* @author junichi11 | |
*/ | |
class ClearCacheShell extends AppShell { | |
public $uses = array(); | |
public $task = array(); | |
private $clearDir = array('models', 'persistent', 'views'); | |
public function main() { | |
$clearCache = null; | |
if(!empty($this->params['type'])){ | |
$clearCache = clearCache(null, $this->args[0], null); | |
$this->_viewResult($clearCache, $this->args[0]); | |
return; | |
} | |
foreach($this->clearDir as $dir){ | |
$clearCache = clearCache(null, $dir); | |
$this->_viewResult($clearCache, $dir); | |
} | |
} | |
protected function _viewResult($clearCache, $type) { | |
if ($clearCache) { | |
$this->out(__("%s : Success!", $type)); | |
} else { | |
$this->out(__("%s : Failure!", $type)); | |
} | |
} | |
public function getOptionParser(){ | |
$parser = parent::getOptionParser(); | |
return $parser->description(__('Clear files in the app/tmp/cache.')) | |
->addOption('type', array( | |
'help' => __('File type (directory name).'), | |
'boolean' => true | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment