renameKey() public method

Renames a file
public renameKey ( string $sourceKey, string $targetKey ) : boolean
$sourceKey string Old key
$targetKey string New key
return boolean
Beispiel #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;
 }
Beispiel #2
0
 /**
  * @dataProvider driverSet
  */
 public function testRename(Storage $storage)
 {
     $storage->renameKey($this->key, $this->newKey);
     $this->assertTrue($storage->keyExists($this->newKey));
 }