delete() public method

public delete ( string $path ) : boolean
$path string
return boolean
Esempio n. 1
0
    /**
     * @param Bundle $bundle
     * @param $property
     * @return bool
     */
    public function saveFileBased(Bundle $bundle, $property)
    {
        $xml = $bundle->exportFileBased($property);
        $xmlFile = $bundle->getPropertyFilePath($property);
        $emptyXml = '<config>
  <bundle/>
</config>';
        if ($xml == $emptyXml) {
            if ($this->localFilesystem->has($xmlFile)) {
                return $this->localFilesystem->delete($xmlFile);
            } else {
                return true;
            }
        } else {
            return $this->localFilesystem->write($xmlFile, $xml);
        }
    }
Esempio n. 2
0
 /**
  * Copies or moves files to a destination.
  * If the source is a folder, it copies recursively.
  *
  * @static
  *
  * @param  array|string $source
  * @param  string       $target
  * @param  string       $action move|copy
  *
  * @return bool
  */
 public function paste($source, $target, $action = 'move')
 {
     $files = (array) $source;
     $action = strtolower($action);
     $result = false;
     foreach ($files as $file) {
         $oldFile = str_replace('..', '', $file);
         $oldFile = str_replace(chr(0), '', $oldFile);
         $oldFs = $this->getAdapter($oldFile);
         //if the $target is a folder with trailing slash, we move/copy the files _into_ it otherwise we replace.
         $newPath = '/' === substr($target, -1) ? $target . basename($file) : $target;
         $newFs = $this->getAdapter($newPath);
         $file = null;
         if ($newFs === $oldFs) {
             $file = $this->getFile($oldFile);
             $result = $newFs->{$action}($this->normalizePath($oldFile), $this->normalizePath($newPath));
         } else {
             //we need to move a folder from one file layer to another.
             $file = $oldFs->getFile($this->normalizePath($oldFile));
             if ($file->getType() == 'file') {
                 $content = $oldFs->read($this->normalizePath($oldFile));
                 $newFs->write($this->normalizePath($newPath), $content);
             } else {
                 if ('/' === $oldFs->getMountPath()) {
                     /** @var Local $oldFs */
                     //just directly upload the stuff
                     $this->copyFolder($oldFs->getRoot() . $oldFile, $newPath);
                 } else {
                     //we need to copy all files down to our local hdd temporarily
                     //and upload then
                     $folder = $this->downloadFolder($oldFile);
                     $this->copyFolder($folder, $newPath);
                     $this->cacheFilesystem->delete($folder);
                 }
             }
             if ('move' === $action) {
                 $oldFs->delete($this->normalizePath($oldFile));
                 if ($this) {
                     $file->setPath($this->normalizePath($newPath));
                     $file = $this->wrap($file);
                     $file->save();
                 }
             }
             $result = true;
         }
         if ('move' === $action) {
             $file = $this->wrap($file);
             $file->setPath($this->normalizePath($newPath));
             $file->save();
         }
     }
     return $result;
 }