ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
League\Flysystem\Plugin\ForcedRename Class Reference
+ Inheritance diagram for League\Flysystem\Plugin\ForcedRename:
+ Collaboration diagram for League\Flysystem\Plugin\ForcedRename:

Public Member Functions

 getMethod ()
 Get the method name.
Returns
string
More...
 
 handle ($path, $newpath)
 Renames a file, overwriting the destination if it exists. More...
 
- Public Member Functions inherited from League\Flysystem\Plugin\AbstractPlugin
 setFilesystem (FilesystemInterface $filesystem)
 Set the Filesystem object. More...
 

Additional Inherited Members

- Protected Attributes inherited from League\Flysystem\Plugin\AbstractPlugin
 $filesystem
 

Detailed Description

Definition at line 7 of file ForcedRename.php.

Member Function Documentation

◆ getMethod()

League\Flysystem\Plugin\ForcedRename::getMethod ( )

Get the method name.

Returns
string

Implements League\Flysystem\PluginInterface.

Definition at line 12 of file ForcedRename.php.

13  {
14  return 'forceRename';
15  }

◆ handle()

League\Flysystem\Plugin\ForcedRename::handle (   $path,
  $newpath 
)

Renames a file, overwriting the destination if it exists.

Parameters
string$pathPath to the existing file.
string$newpathThe new path of the file.
Exceptions
FileNotFoundExceptionThrown if $path does not exist.
Returns
bool True on success, false on failure.

Definition at line 27 of file ForcedRename.php.

References $path.

28  {
29  try {
30  $deleted = $this->filesystem->delete($newpath);
31  } catch (FileNotFoundException $e) {
32  // The destination path does not exist. That's ok.
33  $deleted = true;
34  }
35 
36  if ($deleted) {
37  return $this->filesystem->rename($path, $newpath);
38  }
39 
40  return false;
41  }

The documentation for this class was generated from the following file: