Folder::delete PHP Method

delete() public method

Deletes the directory
public delete ( boolean $keep = false ) : boolean
$keep boolean Set this to true to keep the directory but delete all its content
return boolean
    public function delete($keep = false)
    {
        $items = $this->content(array('.', '..'));
        foreach ($items as $item) {
            $item->delete();
        }
        return $keep ? true : @rmdir($this->root);
    }

Usage Example

Example #1
0
 /**
  * Execution method always used for tasks
  *
  * @return void
  */
 public function execute()
 {
     parent::execute();
     //引数のセット
     if (isset($this->params[self::KEY_APACHE_OWNER])) {
         $owner = Hash::get($this->params, self::KEY_APACHE_OWNER);
         $writables = array(APP . 'Config', APP . 'tmp', ROOT . DS . 'composer.json', ROOT . DS . 'bower.json');
         foreach ($writables as $file) {
             $messages = array();
             $ret = null;
             $cmd = sprintf('`which chown` %s -R %s 2>&1', $owner, $file);
             exec($cmd, $messages, $ret);
         }
     }
     if (array_key_exists(self::KEY_RELEASE, $this->params)) {
         $path = ROOT . DS . 'app' . DS . 'Plugin' . DS;
         $plugins = array_unique(array_merge(App::objects('plugins'), array_map('basename', glob($path . '*', GLOB_ONLYDIR))));
         $folder = new Folder();
         foreach ($plugins as $plugin) {
             $folder->delete($path . $plugin . DS . '.git');
         }
         $folder->delete(ROOT . DS . '.git');
         $folder->delete(ROOT . DS . '.chef');
     }
     Configure::write('NetCommons.installed', true);
     $this->InstallUtil->saveAppConf();
 }
All Usage Examples Of Folder::delete