Webiny\Component\Storage\Storage::renameKey PHP Method

renameKey() public method

Renames a file
public renameKey ( string $sourceKey, string $targetKey ) : boolean
$sourceKey string Old key
$targetKey string New key
return boolean
    public function renameKey($sourceKey, $targetKey)
    {
        return $this->driver->renameKey($sourceKey, $targetKey);
    }

Usage Example

Example #1
0
 /**
  * @inheritdoc
  */
 public function rename($newKey)
 {
     if ($this->storage->renameKey($this->key, $newKey)) {
         $event = new StorageEvent($this);
         // Set `oldKey` property that will be available only on rename
         $event->oldKey = $this->key;
         $this->key = $newKey;
         $this->eventManager()->fire(StorageEvent::FILE_RENAMED, $event);
         return true;
     }
     return false;
 }
All Usage Examples Of Webiny\Component\Storage\Storage::renameKey