Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
add artist clearcache command
Browse files Browse the repository at this point in the history
  • Loading branch information
devthejo committed Dec 19, 2015
1 parent 02b973d commit 4e08d9c
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions Artist/Clearcache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
namespace RedCat\Framework\Artist;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class Clearcache extends Artist{
protected $description = "Clear the content of .tmp directory at root of application";

protected $args = [];
protected $opts = [];

protected $output;
protected function execute(InputInterface $input, OutputInterface $output){
$this->output = $output;
$path = $this->cwd.'.config.php';
$rm = $this->rmdir($this->cwd.'.tmp');
if($rm===true)
$this->output->writeln('cache cleaned');
elseif($rm===false)
$this->output->writeln('cache cleaning failed');
else
$this->output->writeln('cache was allready empty');
}
private function rmdir($dir){
if(is_dir($dir)){
$dh = opendir($dir);
if($dh){
while(false!==($file=readdir($dh))){
if($file!='.'&&$file!='..'){
$fullpath = $dir.'/'.$file;
if(is_file($fullpath)){
if(unlink($fullpath))
$this->output->writeln('deleted '.$fullpath);
else
$this->output->writeln('deletion failed '.$fullpath);
}
else{
self::rmdir($fullpath);
}
}
}
closedir($dh);
}
if(rmdir($dir)){
$this->output->writeln('deleted '.$dir.'/');
return true;
}
else{
$this->output->writeln('deletion failed '.$dir.'/');
return false;
}
}
}
}

0 comments on commit 4e08d9c

Please sign in to comment.